Hi Igor
I have got one more question. The program consists of two windows, main window
in the background and sub window in the foreground initially. When I tap on
the main window in the background, it brings it to the foreground. This gets
EN_UPDATE, EN_CHANGE, and EN_SETFOCUS sent away in [Q 1]. But I don't see
WM_PAINT sent away three times in [Q2], but just once (the subwindow appears
to have received the message three times though). Is it normal?
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Function for our Sub Window Proc
LRESULT CALLBACK SubWindowPro(HWND _hWnd, unsigned int _unMsg, WPARAM _wParam, LPARAM _lParam)
{
static int x=0;
switch (_unMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
//default:
[Q1]case WM_LBUTTONUP://Tap on the touchpad on the dialogue window.
{cout<<"I am the king in Subwindow: "<<king<<" queen: "<<queen<<"\n"; x=x+10;
cout<<"x = "<<x<<"\n";
[Q2] InvalidateRect(_hWnd,NULL,FALSE);//Sends WM_PAINT when the update region is not empty &
//there are no other messages in the app queue for that window.
//The update region is the portion of the window's client
//area that must be redrawn.
}
return 0;
[Q 3] case WM_PAINT:
{ cout<<"chong king in WM_PAINT: "<<king<<" queen: "<<queen<<"\n";
cout<<"(LOWORD) "<<LOWORD(_wParam)<<"\n";
PAINTSTRUCT ps;
HDC hdc;
if (x<1){ps.rcPaint.left=(LONG)100;ps.rcPaint.top=(LONG)600;ps.rcPaint.right=(LONG)700;
ps.rcPaint.bottom=(LONG)10;}
hdc= BeginPaint(_hWnd, &ps);//BeginPaint() works only in WM_PAINT handler.
FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+x));//Fills the rectangle in
//COLOR_WINDOW++x. Comment this & see the differernce.
//Uncommented, it is the same as 'InvalidateRect(_hWnd,NULL,TRUE)'.
TextOut(hdc, x ,x , L"2nd console", wcslen(L"2nd console"));
TextOut(hdc, x+100 ,x+100 , L"Chong is completed", wcslen(L"Chong is completed"));
EndPaint(_hWnd, &ps);
return 0;}
case IDOK:// cout<<"Chong\n";
return 0;
}
return DefWindowProc(_hWnd, _unMsg, _wParam, _lParam);
}
Regards
Chong