Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Windows message,

Windows message,

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    birajendu
    wrote on last edited by
    #1

    Hi, How can i capture a Message/notification from a Child control which is again a child of another window. Window->Child->Child1. My question is how can i capture Child1's message in Window? for me Window is the parent window of the application, Child is a tab control, Child1 is aedit control.

    Birajendu SonicWALL Bangalore India

    S 1 Reply Last reply
    0
    • B birajendu

      Hi, How can i capture a Message/notification from a Child control which is again a child of another window. Window->Child->Child1. My question is how can i capture Child1's message in Window? for me Window is the parent window of the application, Child is a tab control, Child1 is aedit control.

      Birajendu SonicWALL Bangalore India

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      Get Child to re-send Child1 messages to window? Put in a WM_NOTIFY handler for Child1 in Child and forward all of those messages to Window. Add a WM_NOTIFY handler for Child in Window. Look at the hwndFrom member of the NMHDR part of the notification message to see which window originally sent the message.

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      B 1 Reply Last reply
      0
      • S Stuart Dootson

        Get Child to re-send Child1 messages to window? Put in a WM_NOTIFY handler for Child1 in Child and forward all of those messages to Window. Add a WM_NOTIFY handler for Child in Window. Look at the hwndFrom member of the NMHDR part of the notification message to see which window originally sent the message.

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        B Offline
        B Offline
        birajendu
        wrote on last edited by
        #3

        I wrote only messgae loop for parent window, can you tell me how i can incorporate message loop for child windows.

        Birajendu SonicWALL Bangalore India

        _ S 2 Replies Last reply
        0
        • B birajendu

          I wrote only messgae loop for parent window, can you tell me how i can incorporate message loop for child windows.

          Birajendu SonicWALL Bangalore India

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          A message loop is the same irrespective of whether it is for a parent window or a child window or a window in another thread.

          «_Superman_» I love work. It gives me something to do between weekends.

          B 1 Reply Last reply
          0
          • _ _Superman_

            A message loop is the same irrespective of whether it is for a parent window or a child window or a window in another thread.

            «_Superman_» I love work. It gives me something to do between weekends.

            B Offline
            B Offline
            birajendu
            wrote on last edited by
            #5

            Let me descrip my problem more precisely: Window->Childwindow(Tab control)->ChildWindow1(edit control). In windows message loop { case WM_NOTIFY: { switch(nmhdr->idFrom) { case IDC_MAIN_TREEVIEW: //childwindow's Id switch(nmhdr->code) { //I am expeccting notify messages from ChildWindow1? } } } } Please let me know weather i am doing correctly.?

            Birajendu SonicWALL Bangalore India

            S 1 Reply Last reply
            0
            • B birajendu

              I wrote only messgae loop for parent window, can you tell me how i can incorporate message loop for child windows.

              Birajendu SonicWALL Bangalore India

              S Offline
              S Offline
              Stuart Dootson
              wrote on last edited by
              #6

              The message loop will handle all windows created on the thread it's in (a simplification, but close enough). To modify the behaviour of the child windows, you need to subclass them, to handle messages sent to them differently than the default. I would suggest you read up about window subclassing - this[^] is a good starting point. For example, to subclass a tab control created in your topmost window, you might use this to create and then subclass the control.

                   RECT rcCLient;
                   GetClientRect(hWnd, &rcCLient);
                   hwndTab = CreateWindow(WC\_TABCONTROL, \_T("tab"), WS\_VISIBLE|WS\_CHILDWINDOW, 0, 0, rcCLient.right, rcCLient.bottom, hWnd, 0, hInst, 0);
                   oldTabProc = (WNDPROC)::SetWindowLongPtr(hwndTab, GWLP\_WNDPROC, LONG\_PTR(&TabWndProc));
              

              This next code fragment is my definition of a window procedure for the tab control that will forward notifications from an edit control contained inside it to the tab control's parent window. It's a bit evil, 'cause it uses a global for the tab control's old WNDPROC, but it illustrates the point.

              WNDPROC oldTabProc;
              LRESULT CALLBACK TabWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
              {
              if (message == WM_COMMAND && HWND(lParam) == hwndEdit)
              return ::SendMessage(GetParent(hWnd), message, wParam, lParam);
              return oldTabProc(hWnd, message, wParam, lParam);
              }

              Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

              B 1 Reply Last reply
              0
              • B birajendu

                Let me descrip my problem more precisely: Window->Childwindow(Tab control)->ChildWindow1(edit control). In windows message loop { case WM_NOTIFY: { switch(nmhdr->idFrom) { case IDC_MAIN_TREEVIEW: //childwindow's Id switch(nmhdr->code) { //I am expeccting notify messages from ChildWindow1? } } } } Please let me know weather i am doing correctly.?

                Birajendu SonicWALL Bangalore India

                S Offline
                S Offline
                Stuart Dootson
                wrote on last edited by
                #7

                birajendu wrote:

                In windows message loop

                Do you mean in the message loop or in the WNDPROC for Window (I think it's the second one).

                birajendu wrote:

                //I am expeccting notify messages from ChildWindow1?

                No - they get sent to the Tab control - which has a different WNDPROC. You need to subclass it so that you can process the window messages sent to it. See the message I previously posted about subclassing windows.

                Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                1 Reply Last reply
                0
                • S Stuart Dootson

                  The message loop will handle all windows created on the thread it's in (a simplification, but close enough). To modify the behaviour of the child windows, you need to subclass them, to handle messages sent to them differently than the default. I would suggest you read up about window subclassing - this[^] is a good starting point. For example, to subclass a tab control created in your topmost window, you might use this to create and then subclass the control.

                       RECT rcCLient;
                       GetClientRect(hWnd, &rcCLient);
                       hwndTab = CreateWindow(WC\_TABCONTROL, \_T("tab"), WS\_VISIBLE|WS\_CHILDWINDOW, 0, 0, rcCLient.right, rcCLient.bottom, hWnd, 0, hInst, 0);
                       oldTabProc = (WNDPROC)::SetWindowLongPtr(hwndTab, GWLP\_WNDPROC, LONG\_PTR(&TabWndProc));
                  

                  This next code fragment is my definition of a window procedure for the tab control that will forward notifications from an edit control contained inside it to the tab control's parent window. It's a bit evil, 'cause it uses a global for the tab control's old WNDPROC, but it illustrates the point.

                  WNDPROC oldTabProc;
                  LRESULT CALLBACK TabWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
                  {
                  if (message == WM_COMMAND && HWND(lParam) == hwndEdit)
                  return ::SendMessage(GetParent(hWnd), message, wParam, lParam);
                  return oldTabProc(hWnd, message, wParam, lParam);
                  }

                  Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                  B Offline
                  B Offline
                  birajendu
                  wrote on last edited by
                  #8

                  Thanks a Lot. This served my purpose....

                  Birajendu SonicWALL Bangalore India

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups