Message Reflection?

Help
2004-10-01
2013-04-15
  • Steven Weiss

    Steven Weiss - 2004-10-01

    Hi,
    is message reflection possible? i know this from MFC, you can create a message-handler for, say a listctrl, and the notifications which the parent receives are reflected to the listctrl so that it can handle them too. this is good for creating subclassed ctrls

     
    • Steven Weiss

      Steven Weiss - 2004-10-02

      another issue related to messages: is message routing possible? what i mean is getting an edit's WM_LBUTTONUP-messages in the parent, for example a dialog? that would be great!

      and can you explain me the mechanism behind the message-handlers? perhaps i can help you a bit and code this feature if i understand the message-mechanism and if this feature isn't integrated yet

       
      • John Torjo

        John Torjo - 2004-10-02

        At this time, it's not possible to have that kind of message routing. But I will implement advanced subclassing in about 1 month - and I'm sure you'll love it ;)

        Anyway, could you tell me what you need this for? Maybe I can suggest a workaround or so.

        As for the mechanism behind message-handlers: In a nutshell, an event handler function automatically registers itself within the class it exists
        (example: my_dialog_handler::on_ok registers within my_dialog_handler).

        At runtime, when the window receives a message (event/command/notification), checks all registered event handlers. If an event handler matches, it simply calls it.

        Best,
        John

         
    • John Torjo

      John Torjo - 2004-10-02

      That's so funny ;) Somebody else also asked me this privately.

      I donot agree with this mechanism but it seems to be popular. I'll implement it in v1.5 - and it will first work for controls that are sitted on dialogs only.

      Best,
      John

       
    • Steven Weiss

      Steven Weiss - 2004-10-03

      great, you're so capable!

      i know how to workaround it:

      struct EditSource : wnd_extend<edit, EditSource>
      {
      };

      struct Edit_handler : event_handler<Edit_handler, edit, EditSource>
      {
          handle_event OnEditLButtonUp (l_param_lo x, l_param_hi y)
          {
              POINT pt = { x, y };       
              int pos = window()->char_from_pos(pt);       
              window()->parent()->send_msg(WM_FILENAMECLICK, pos, 0);
              return event<WM_LBUTTONUP> ().HANDLED_BY(&me::OnEditLButtonUp);
          }
      };

      and then doing a remap.
      but that's a lot of work, especially if you have many controls on a dialog, and in every control you only want to get one message. MFC's PreTranslateMessage() is the equivalent

      greetz steven

       
      • John Torjo

        John Torjo - 2004-10-06

        Yes, it does work.

        However, I'm not sure what you're trying to make. If you can tell me more about what you want to do (eventually privately - john at torjo dot com) maybe I  can suggest another solution.

        (as for MFC's PreTranslateMessage - that's a really error-prone solution - I hate it ;))

        Best,
        John

         
        • Steven Weiss

          Steven Weiss - 2004-10-06

          i want to react on some messages of the edit and some other childs in the parent-dialog. when the user clicks on the edit a new string should be created in the dialog

          how does it work? do you mean my workaround? or is there some special and top-secret routing mechanism :-) ?

           
          • John Torjo

            John Torjo - 2004-10-06

            when the user clicks on the edit, the parent receives a EN_SETFOCUS notification. You can simply handle it in the dialog.

            Best,
            John

             
            • Steven Weiss

              Steven Weiss - 2004-10-06

              right, but if the edit already has the input focus this notification won't be sent again...that's the problem

               
              • John Torjo

                John Torjo - 2004-10-06

                I'm still not sure why you want this ;)
                You know you can also monitor for EN_CHANGE - (any change on the text of the edit box).

                Again, could you explain a little the task at hand?

                Best,
                John

                 
                • Steven Weiss

                  Steven Weiss - 2004-10-06

                  ok, a better explanation is necessary :-)

                  i have an editbox in which a string appears e.g.
                  "some title - some album.mp3" (as you see, it's a filename)

                  now the user can set some separators in the options dialog, e.g. "-". now the user can click somewhere in the editbox and the string will be parsed and in another editbox the parsed string will be displayed. when the user clicks on "title" the string will be generated as follows "some title.mp3". and this is the reason why it would be nice to have a message dispatching to the parent window :-)

                   
                  • John Torjo

                    John Torjo - 2004-10-06

                    I think I somehow understand.
                    However, why not simply have two edit boxes instead?
                    You parse the title when you first show the dialog, and then keep the title & album apart. The user can modify them as he wishes and then he presses a button or so, you create the file name as you wish.

                    As a side-note, maybe you could use the save_dlg class (see examples/smart_dialog/* samples)

                    Best,
                    John

                     
                    • Steven Weiss

                      Steven Weiss - 2004-10-06

                      i already have editboxes for title, artist and album. but it's a bit more complicated...the user has the choice of which filepart corresponds to title/artist/album

                      but anyway - i wanted to show you that sometimes this feature would be needed and if you don't want to include it that's ok! the "workaround" works perfect, only more work to do

                       
                      • John Torjo

                        John Torjo - 2004-10-07

                        Ok.

                        Just remember that advanced subclassing will rock big time ;)

                        Best,
                        John

                         
                        • Steven Weiss

                          Steven Weiss - 2004-10-07

                          ok :-)

                           

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks