35541

通过窗口句柄获取窗口消息

WNDPROC g_pOldProc = NULL;
LRESULT CALLBACK NewWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_ACTIVATE:
printf("NewWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam).....WM_ACTIVATE\n");
break;
}
//继续调用原来的窗口过程函数  
return CallWindowProc(g_pOldProc, hwnd, message, wParam, lParam);

}

...更改

{

HWND t_handle=.....;
g_pOldProc = (WNDPROC)GetWindowLong(t_handle, GWL_WNDPROC);//获取旧的窗口过程函数指针保存

SetWindowLong(t_handle, GWL_WNDPROC, long(NewWndProc));//设置新的窗口过程函数  

}

.....还原

{

HWND t_handle=.....;

SetWindowLong(t_handle, GWL_WNDPROC, (long)g_pOldProc);//恢复旧的过程函数  

}

来源:博客园

作者:DoubleLi

链接:https://www.cnblogs.com/lidabo/p/11425630.html

Recommend