Which is preferred, method 1 or method 2?
LRESULT CALLBACK wpMainWindow(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (
I like Method 3:
LRESULT wpMainWindowPaint(HWND hwnd)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rc;
GetClientRect(hwnd, &rc);
hdc = BeginPaint(hwnd, &ps);
// drawing here
EndPaint(hwnd, &ps);
return 0;
}
LRESULT CALLBACK wpMainWindow(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_PAINT: return wpMainWindowPaint(hwnd);
default: return DefWindowProc(hwnd, msg, wparam, lparam);
}
}
If it deserves its own scope for organization purposes, it deserves its own function. If you're worried about function call overhead, make it inline.