Thread: message loop for DialogBox?

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

    message loop for DialogBox?

    is this created automatically by the DialogBox macro? is it possible to access the MSG structs for a dialog inside its dialog procedure (the ones that would be passed to TranslateMessage and such functions)?

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    In Win32 API, you can call IsDialogMessage() to check the message destination. In MFC, check out PreTranslateMessage().

    Kuphryn

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    is this created automatically by the DialogBox macro?
    Yes. If you want to run your own message loop use CreateDialog() to create a modeless dialog. Remember the IsDialogMessage() call as mentioned by Kuphryn.

    is it possible to access the MSG structs for a dialog inside its dialog procedure (the ones that would be passed to TranslateMessage and such functions)?
    Not if you use DialogBox().

  4. #4
    Registered User
    Join Date
    Jun 2004
    Posts
    26
    Quote Originally Posted by kuphryn
    In Win32 API, you can call IsDialogMessage() to check the message destination. In MFC, check out PreTranslateMessage().

    Kuphryn
    yea, but both of these need the MSG struct, which is what i was asking for.

    is it ok to return the result of CreateDialog in WinMain?

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>is it possible to access the MSG structs<<

    Indirectly you can get the information. Consider
    Code:
    typedef struct {
        HWND hwnd;
        UINT message;
        WPARAM wParam;
        LPARAM lParam;
        DWORD time;
        POINT pt;
    } MSG, *PMSG;
    The hwnd, wParam, lParam and message are all available within your dialog procedure. For time there's GetMessageTime and for pt there's GetMessagePos.

    >>is it ok to return the result of CreateDialog in WinMain<<

    From msdn description of WinMain
    Return Value
    If the function succeeds, terminating when it receives a WM_QUIT message, it should return the exit value contained in that message's wParam parameter. If the function terminates before entering the message loop, it should return zero.
    ©2004 Microsoft Corporation. All rights reserved.
    edit: copyright notice included in msdn quote in accordance with 10% rule.
    Last edited by Ken Fitlike; 06-03-2004 at 12:14 PM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Desperate Over Ecs!
    By cookie in forum C Programming
    Replies: 17
    Last Post: 07-16-2008, 01:25 PM
  2. Window message loop (Keys)
    By Blackroot in forum Windows Programming
    Replies: 3
    Last Post: 09-12-2006, 05:15 PM
  3. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  4. Help, the window gets killed......
    By incognito in forum Game Programming
    Replies: 2
    Last Post: 05-28-2002, 02:22 PM