CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2003
    Posts
    11

    Dialog Activation

    My application consists of a mainframe window that can display multiple modeless dialogs. At a given time multiple dialogs can be open.

    My question is:
    What message can the dialog trap to know that it is brought into focus? I need to know this so that when the dialog is brought into focus it can set certain global variables.

    I tried trapping the WM_SETFOCUS message...but that does not get message does not get activated when the dialog is brought into focus.

    Any help is greatly appreciated.
    Thanks,
    MD

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635
    WM_ACTIVATE

  3. #3
    Join Date
    Sep 1999
    Location
    Colorado, USA
    Posts
    1,002
    Try trapping WM_ACTIVATE.

    Steve

  4. #4
    Join Date
    Sep 2003
    Posts
    11
    Thanks for your replies.

    I did try WM_ACTIVATE in my dialog....but that does not get invoked.

    Does this have something to do with the fact that my dialogs are modeless?

    This is a sample:

    void SReviewInterestDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
    {

    SViewDlg::OnActivate(nState, pWndOther, bMinimized);

    // TODO: Add your message handler code here

    }

    Thanks
    MD

  5. #5
    Join Date
    Sep 1999
    Location
    Colorado, USA
    Posts
    1,002
    Put a trace statement in your OnActivate() handler, before the base class fxn is called. You should see that it gets called when the modeless dialog gets the focus and loses the focus. I just tried it and confirmed that a modeless dialog does get the WM_ACTIVATE message.

    Steve

  6. #6
    Join Date
    Sep 2003
    Posts
    11
    sstofka - Thanks for your reply again....my problem was:

    I just realized that my modeless dialog was a child window of CMDIChildWnd. The activate calls were being trapped CMDIChildWnd. So WM_ACTIVATE was not invoked for my dialog. But WM_MDIACTIVATE was invoked for CMDIChildWnd. In this method I was able to receive a handle to my modeless dialog...which is of type CWnd and I cast it to CDialog.


    Thanks,
    MD

  7. #7
    Join Date
    Sep 1999
    Location
    Colorado, USA
    Posts
    1,002
    That's an interesting point, md, with the MDI window. Thanks for the follow up.

    Steve

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

Featured