I have a problem with WM_PAINT. Basically I want WM_PAINT to be called after a user WM_COMMAND, but for some reason it's called anyway in the main function.
case WM_PAINT:
{
createFont();
PAINTSTRUCT ps;
HBRUSH hbruzh = CreateSolidBrush(RGB(0,0,0));
HDC hdz = BeginPaint(hWnd,&ps);
string s = "Memory Address";
SelectBrush(hdz,hbruzh);
SelectFont(hdz,hf);
TextOut(hdz,0,0,s.c_str(),s.length());
EndPaint(hWnd,&ps);
DeleteObject(hbruzh);
DeleteObject(hdz);
break;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
HWND hWnd;
WNDCLASSEX wc;
ZeroMemory(&wc, sizeof(WNDCLASSEX));
hThisInstance = hInstance;
LoadLibrary("Riched20.dll");
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU);
if(!(wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_MYICON)))) {
HRESULT res = GetLastError();
}
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszClassName = TEXT("Testcpp");
RegisterClassEx(&wc);
hWnd = CreateWindowEx(NULL,
wc.lpszClassName,
TEXT("uTest"),
WS_OVERLAPPEDWINDOW,
300,
200,
450,
300,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hWnd,nCmdShow);
MSG msg;
while (GetMessage(&msg, NULL,0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
According to MSDN, WM_PAINT is only called automatically after either UpdateWindow() or ReDrawWindow(), or when you SendMessage with it as message. I do none, however. I basically only want to call WM_PAINT after a user interaction, not before... is there any way to fix this? What is causing this? (I guess its some bizare side-effect I cant find documentation for >.<)