Overriding WindowProc

Giganews Newsgroups
Subject: Overriding WindowProc
Posted by:  NickP (..@a.com)
Date: Thu, 12 Apr 2007

Hi there,

    I am using the following code to overwrite a window proc,

    -------------

    ::SetWindowLongPtr(pWndFocusWindow, GWLP_WNDPROC, (LONG)OnHookMsg);

    ...

    LRESULT WINAPI CMainFrame::OnHookMsg(HWND hWnd, UINT uMsg, WPARAM
wParam, LPARAM lParam)
    {
        return(::DefWindowProc(hWnd, uMsg, wParam, lParam));
    }

    -------------

    OnHookMsg is a static method of CMainFrame and pWndFocusWindow is a
child window of CMainFrame that has just obtained window focus.

    OnHookMsg fires but then the window locks up, I presume tis is because a
value has not been returned to the original SendMessage call.  But I have
included DefWindowProc, so surely this should work right?

    Basically I don't want to effect any of the messages, simple monitor
them.

    Many thanks in advance.

Nick.

Replies