CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2018
    Posts
    4

    Organizing Buttons Event Handlers in another class doesn't working

    Hi,

    I have started a clean MFC proiect with dialog based option with CWinApp base class.

    I want to organize event handlers functions for buttons in other class that in the main dlg class, but the buttons event handlers that are assigned to the class that I want to use, aren't trigger, the innterupts that are setted to their button click function aren't triggered.

    If I put the event handlers in the dlg class it's working, but I want to organize in other class, how can I do that?

    Thank you in advance.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Organizing Buttons Event Handlers in another class doesn't working

    Quote Originally Posted by coco243 View Post
    ...
    I want to organize event handlers functions for buttons in other class that in the main dlg class...
    Why " in other class"?
    Control notifications are usually sent to the parent window of the control which in your case is the dialog containing the buttons.
    Victor Nijegorodov

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

    Re: Organizing Buttons Event Handlers in another class doesn't working

    Victor is right in that that's a bad design. What does your message map look like? How are you trying to get this other class to handle your dialog's messages?

  4. #4
    Join Date
    Dec 2018
    Posts
    4

    Re: Organizing Buttons Event Handlers in another class doesn't working

    Thank you guys for your attention.
    Yes, you opened my eyes. The functions from button handlers should be in the dialog class. ( I had looked in other programs that I have as example and I understood what you
    are trying to explain to me.) I will call the functions that I need from dialog class and try to organize this functions in a separated class.
    I think that it had no sense trying in this direction.

    Thank you very much.

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Organizing Buttons Event Handlers in another class doesn't working

    Quote Originally Posted by coco243 View Post
    Thank you guys for your attention.
    Yes, you opened my eyes. The functions from button handlers should be in the dialog class. ( I had looked in other programs that I have as example and I understood what you
    are trying to explain to me.) I will call the functions that I need from dialog class and try to organize this functions in a separated class.
    I think that it had no sense trying in this direction.

    Thank you very much.
    You are welcome!
    Victor Nijegorodov

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