Function prototype: Long SetWindowLong (hwnd hwnd, int nIndex, long dwnewlong);
The main explanation is that the second parameter of a function is gwl_wndproc.
Gwl_wndproc |
Sets a new address for the window procedure. You cannot the attribute if the Windows does not belong to the same process as the calling thread. |
Example:
wndproc pwindowproc = 0;
lresult callback callwindproc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM);
void Ctest_hkdlg::onbnclickedproc ()
{
pwindowproc = (WNDPROC) getwindowlong (GetDlgItem (IDC_WND1)->m_hwnd, gwl_wndproc ); //Save the original window procedure
LONG lValue = SetWindowLong (GetDlgItem (idc_wnd1)->m_hwnd,gwl_wndproc , (LONG) Span style= "color: #3366ff;" >callwindproc );
if (lvalue==0)
{
int lerr = GetLastError ();
char buf[32] = {0};
sprintf_s (buf, "gle =%d \ r \ n", Lerr);
OutputDebugString (BUF);
}
}
LRESULT CALLBACK Callwindproc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM)
{
Switch (message)
{
Case Wm_activate:
Break
Case Wm_ncactivate:
Break
Case Wm_ncmousemove:
Break
Case WM_MOUSEMOVE:
Break
Case WM_SIZE:
Break
Case WM_PAINT:
Break
}
if (Pwindowproc)
Return (*PWINDOWPROC) (HWND, message, wparam, lparam); Call the original window procedure
return DefWindowProc(hwnd, message, wparam, lparam); Call the default window procedure function
}
SetWindowLong setting up Windows new process