I want to display text only after I clicked with left mouse button into the client area of the window. I have this code, but it doesn't work. When I click left mouse button nothing happens:
void Text(HDC hdc)
{
SetTextColor(hdc, RGB(255, 0, 0));
SetBkColor(hdc, RGB(0, 0, 0));
TCHAR display_msg[] = _T("Message in window");
TextOut(hdc, RestartButtonWidth, 10, display_msg, _tcslen(display_msg));
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
bool Clicked = false;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
if (Clicked == true)
{
Text(hdc);
}
EndPaint(hWnd, &ps);
break;
case WM_LBUTTONDOWN:
Clicked = true;
break;
Why is the change of state of Clicked boolean not registered by WM_PAINT message?