dialog procedure

This is a discussion on dialog procedure within the Windows Programming forums, part of the Platform Specific Boards category; is it possible for a DialogBox to catch WM_KEYDOWN and similar messages no matter which control has the focus?...

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    26

    dialog procedure

    is it possible for a DialogBox to catch WM_KEYDOWN and similar messages no matter which control has the focus?

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Definitely. One solution in MFC is to override PreTranslateMessage(). In Win32 API, one solution is hooking.

    Kuphryn

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    26
    ah, hooking..anyone care to give more info on that?
    as for MFC, since its basically an api wrapper, how would the PreTranslateMessage be implemented in win32?

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Check out SetWindowHook() and SetWindowHookEx().

    Kuphryn

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    how would the PreTranslateMessage be implemented in win32?
    PreTranslateMessage()'s equivalent in Win32 would be placing code in the message loop, before the message is translated and dispatched, or just hooking the window procedure. Check out the functions that kuphryn mentioned.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  6. #6
    Registered User
    Join Date
    Jun 2004
    Posts
    26
    hm, MSDN doesnt have SetWindowHook() although SetWindowsHookEx() is there. Unfortunately we can't get to the message loop of a DialogBox..

  7. #7
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Get the HWND of the dialog window and then hook it's window procedure using SetWindowLong(). That's how I used to do it.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Reusing dialog procedure and resource file code
    By elad in forum Windows Programming
    Replies: 3
    Last Post: 12-23-2006, 09:45 AM
  3. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 03:42 PM
  4. Handling keyboard input in a dialog procedure.
    By ganonl in forum Windows Programming
    Replies: 2
    Last Post: 08-23-2003, 12:14 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21