Is it possible to create a C++ preprocessor macro based on a function result?
For example, I'd like to save the screen height dynamically in a preprocessor macro definition:
#define SCREEN_HEIGHT GetSystemMetrics(SM_CYVIRTUALSCREEN)
Then I want to use the result to set values based on the screen height:
#if SCREEN_HEIGHT < 1200
#define TOP_COORD 200
#define BOTTOM_COORD 500
#define LEFT_COORD 0
#define RIGHT_COORD 1280
#else
#define TOP_COORD 1100
#define BOTTOM_COORD 1400
#define LEFT_COORD 0
#define RIGHT_COORD 1280
#endif
This doesn't work, as SCREEN_HEIGHT doesn't seem to be getting defined properly.
Is there a better way to accomplish this? Is this even possible? I want to be able to get this screen height info in the header file if possible, as this is part of a large chunk of legacy code.