MSDN:
The WindowProc function is an application-defined function that processes messages sent to a window. TheWNDPROC type defines a pointer to this callback function.WindowProc is a placeholder for the application-defined function name.
WindowProc函数是一个应用程序定义的函数处理消息的发送到一个窗口。指向的类型定义了一个指向这个回调函数。WindowProc是一个占位符为应用程序定义的函数名。
LRESULT CALLBACK WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
参数:
hwnd:指向窗口的句柄。
uMsg:指定消息类型。
wParam:指定其余的、消息特定的信息。该参数的内容与UMsg参数值有关。
IParam:指定其余的、消息特定的信息。该参数的内容与uMsg参数值有关。
返回值:返回值就是消息处理结果,它与发送的消息有关。
通过重写这个函数,我们可以自定义窗口消息响应,做出相应的处理。
LRESULT CToolTipDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_COMMAND:
{
AfxMessageBox("1");
if(wParam == SC_CLOSE)
{
afxMessageBox("Close");
AfxGetApp()->m_pMainWnd->ShowWindow(SW_HIDE);
return 0;
}
}
break;
}
return CDialog::WindowProc(message, wParam, lParam);
}
实例中做出了对 WM_COMMAND消息的响应处理