I'm trying to make a macro that expands a symbolic constant to a case
statement like this:
// #define WM_PAINT 0x000F
LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
BIND_MSG(WM_PAINT)
// -> case WM_PAINT: Wnd_Main_WM_PAINT (hWnd, wParam, lParam); break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
I tried many things. The best working macro I got was:
#define BIND_MSG(msg) case (msg): Wnd_Main_##msg (hWnd, wParam, lParam); break;
But this macro doesn't expand to Wnd_Main_WM_PAINT
, but to Wnd_Main_0x000F
. When I try Wnd_Main_ ## #msg
instead of Wnd_Main_##msg
, I don't get Wnd_Main_WM_PAINT
, but Wnd_Main_
. Is there any possibility to concatenate Wnd_Main_
with the name of the symbolic constant WM_PAINT
?
(Sorry, the Screenshot is German. Visual Studio says, that the identifier Wnd_Main_0x000F
isn't defined.)