LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ static TCHAR msg[40]= TEXT("\0");
HDC hdc;
hdc=GetDC(hwnd); switch (message)
{ //detect position of non-client area mouse clicks case WM_NCHITTEST:
{
LRESULT hittest =DefWindowProc (hwnd, message, wParam, lParam); switch ( hittest)
{ case HTCAPTION:
wsprintf(msg,TEXT("You clicked in the Title Bar ")); break; case HTCLOSE:
wsprintf(msg,TEXT("You clicked the Close Button ")); break; case HTREDUCE:
wsprintf(msg,TEXT("You clicked the Minimize button ")); break; case HTGROWBOX:
wsprintf(msg,TEXT("You clicked the Restore button ")); break; case HTSYSMENU:
wsprintf(msg,TEXT("You clicked in the System menu ")); break; case HTZOOM:
wsprintf(msg,TEXT("You clicked the Restore button ")); break; case HTRIGHT:
wsprintf(msg,TEXT("You clicked the Right border ")); break; case HTLEFT:
wsprintf(msg,TEXT("You clicked the left border ")); break; case HTBOTTOM:
wsprintf(msg,TEXT("You clicked the bottom border ")); break; case HTTOP:
wsprintf(msg,TEXT("You clicked the top border ")); break;
} break;
} //respond to non-client area mouse clicks by displaying location of mouse click case WM_NCLBUTTONDOWN:
{ int strlen=lstrlen(msg);
TextOut(hdc,0,0,msg,strlen); return0;
} break; //respond to non-client area double click by closing windows case WM_NCLBUTTONDBLCLK:
PostQuitMessage (0) ; break; case WM_DESTROY:
DeleteDC(hdc);
PostQuitMessage (0) ; return0;
} return DefWindowProc (hwnd, message, wParam, lParam) ;
}