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

    PostMessage to childs ?

    Hello,

    I have a SDI application with some modeless dialogs to allow the user to edit the members of the document. As some of these dialogs also make use of document members which are edited in other dialogs, they have to update their calculations whenever an involved document member is changed through the appropriate other dialog. I therefore use the PostMessage function to send an WM_APP based message with a dialog identifying constant as wParam of the message whenever a document member is edited in a dialog. In every dialogs PreTranslateMessage function I try to catch this message and have the dialog update its contents whenever the originator of the message is the one in which related members are edited. Unfortunately the message reaches my MainFrame window, but doesn't reach the other dialogs which are all childs of the MainFrame. Even forwarding the Message with SendMessageToDescendants didn't do the job...
    So how to send a message in such a way that all my dialogs in the application receive it, no matter whether they are child of the same parent or whatever.

    Thanks a lot in advance
    Jens


  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: PostMessage to childs ?

    Why not just save pointers to the CDialog when they are created in a static CPtrArray stored in the mainframe class?

    When you need to send a message to all of the dialogs, just loop through the CPtrArray and send the message to each one of the CDialog pointers found.

    When a dialog is destroyed, you delete the pointer to it from the CPtrArray.

    Regards,

    Paul McKenzie



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