Results 1 to 7 of 7

Thread: Simple Subclassing (in VB maybe).

  1. #1

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    This is VB(like tou didn't know).

    Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    WindowProc = CallWindowProc(PrevProc, hwnd, uMsg, wParam, lParam)
    If uMsg = WM_RBUTTONDOWN Then
    MsgBox "Ok..."
    End If
    End Function

    PrevProc = SetWindowLong(F.hwnd, GWL_WNDPROC, AddressOf WindowProc)


    How do i do this in VC++?
    To subclass a window, to make that msg pop on some WM.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  2. #2
    Guest
    I am not very good in C++. but I'll try


    Code:
    LONG WindowProc(HWND hwnd,LONG uMsg,LONG wParam,LONG lParam) 
    WindowProc = CallWindowProc(PrevProc, hwnd, uMsg, wParam, lParam);
    If (uMsg == WM_RBUTTONDOWN) { 
    MessageBox()//I am not sure of the Arg's of MessageBox right now 
    }
    } 
    
    PrevProc = SetWindowLong(F.hwnd, GWL_WNDPROC,&WindowProc)

  3. #3
    Guest
    Keep in mind that C++ datatypes are different from VB. In VB, we would declare almost everything as Long but here we can be more specific.
    Code:
    LRESULT CALLBACK WindowProc( HWND hwnd,	UINT uMsg, WPARAM wParam,	LPARAM lParam);
    Regarding MessageBox arguments:
    Code:
    int nRes = MessageBox("MessageBox Text", "MyProgram", MB_OK | MB_ICONEXCLAMATION);

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Megatron - you missed the first argument to MessageBox...
    Code:
    int MessageBox(HWND hWndOwner, LPCTSTR lpszText, LPCTSTR lpszTitle, UINT nFlags);
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5
    Guest
    Strange. The one I use is:
    Code:
    MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption, UNIT nType)

  6. #6
    Lively Member
    Join Date
    Jul 2000
    Posts
    94
    The MFC version doesnt need an HWND, the regular API one does. At least that is how I understand it.

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    In MFC, the function without an HWND is a member function of CWnd. Since CWnd has a member variable m_hwnd - it doesn't bother you with having to type it in. I think it expands to something like:
    Code:
    int CWnd::MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption, UINT nFlags) {
        return ::MessageBox(m_hWnd, lpszTest, lpszCaption, nFlags);
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width