CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2012
    Location
    UAE
    Posts
    62

    how to send event from MDI window to child window

    I have a simple question :

    my project is two windows = main window + child window
    I added button1 in main window

    When I click in Butten1 I want to send this event to Child window to Draw Line in A Child Window...

    Thanks in advance for helping.

  2. #2
    Join Date
    Jun 2012
    Location
    UAE
    Posts
    62

    Re: how to send event from MDI window to child window

    I hope to find answer to this question..
    I am using VS 2008 and OS win7 64 Bit ...

    I have a strong understanding for Win API programming but I am new for CS..

    Many thanks in advance for your support..

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: how to send event from MDI window to child window

    The simple way is to create an event in the main window which gets fired when you click the button. The child window would subscribe to the event and draw the line. Search bing or google for EventArgs examples.

    That would be the easy way, but a better way (although more complicated) is to use MVC or MVVM design pattern. In general you want to try to avoid tight coupling between windows forms and using one of the design patterns is a good way to avoid it.

    Essentially with the design patterns a form would not have any idea that there is a child form (or the child form doesn't know about its parent). With MVC, the view communicates with its controller and in MVVM the form communicates with the ViewModel. Using this approach it's easier to have a form used as a child in one form to be used as a form somewhere else. This is not so easy when the child depends on getting data (or operations) from a specific form (or parent of a parent form).

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