SetWindowLong设置窗口新过程
2020-12-13 13:52
标签:style color ar for sp on cti bs ad 函数原型:LONG SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong); 主要说明函数的第二个参数为GWL_WNDPROC的情况。 GWL_WNDPROC Sets a new address for the window procedure. You cannot change this attribute if the window does not belong to the same process as the calling thread. 例子: WNDPROC pWindowProc = 0; void Ctest_HkDlg::OnBnClickedProc() LRESULT CALLBACK CallWindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) case WM_NCMOUSEMOVE: SetWindowLong设置窗口新过程 标签:style color ar for sp on cti bs ad 原文地址:http://www.cnblogs.com/zhangzfan/p/4056745.html
LRESULT CALLBACK CallWindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
{
pWindowProc = (WNDPROC)GetWindowLong(GetDlgItem(IDC_WND1)->m_hWnd, GWL_WNDPROC); //保存原来的窗口过程
LONG lValue = SetWindowLong(GetDlgItem(IDC_WND1)->m_hWnd,GWL_WNDPROC,(LONG)CallWindProc);
if (lValue==0)
{
int lErr = GetLastError();
char buf[32] = {0};
sprintf_s(buf, 32,"gle = %d \r\n", lErr);
OutputDebugString(buf);
}
}
{
switch(message)
{
case WM_ACTIVATE:
break;
case WM_NCACTIVATE:
break;
break;
case WM_MOUSEMOVE:
break;
case WM_SIZE:
break;
case WM_PAINT:
break;
}
if(pWindowProc)
return (*pWindowProc)(hwnd, message, wparam, lparam); //调用原来的窗口过程
return DefWindowProc(hwnd, message, wparam, lparam); //调用默认的窗口过程函数
}
上一篇:剑指Offer-数组
下一篇:C++传值和传引用