經過窗口句柄獲取窗口消息

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);函數

}指針

...更改it

{cas

HWND t_handle=.....;
g_pOldProc = (WNDPROC)GetWindowLong(t_handle, GWL_WNDPROC);//獲取舊的窗口過程函數指針保存return

SetWindowLong(t_handle, GWL_WNDPROC, long(NewWndProc));//設置新的窗口過程函數  message

}printf

.....還原

{

HWND t_handle=.....;

SetWindowLong(t_handle, GWL_WNDPROC, (long)g_pOldProc);//恢復舊的過程函數  

}

相關文章
相關標籤/搜索