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. Need help with SendMessage

Need help with SendMessage

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabasehelptutorial
7 Posts 4 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.
  • D Offline
    D Offline
    David Fleming
    wrote on last edited by
    #1

    I'm trying to programmatically "click" a tab on a CTabCtrl. My understanding is that I can use SendMessage to do that by using TCN_SELCHANGE. But I am also assuming that I need *something* in the lParam and/or wParam values. It seems to me that the index of the tab "clicked" has to be included in there somewhere and somehow. My question is how (or where)? And where do I find things like this? For example, I happened to find here at CodeProject some info on sending a MOUSEMOVE message to a window with the coordinates of the mouse position: SendMessage(hWndTarget, WM_MOUSEMOVE, fFlags, MAKELPARAM(x,y)); Where do I find things like the fact that the lParam is for flags and the wParam is for the coordinates? Any info is greatly appreciated. Thanks.

    A L 2 Replies Last reply
    0
    • D David Fleming

      I'm trying to programmatically "click" a tab on a CTabCtrl. My understanding is that I can use SendMessage to do that by using TCN_SELCHANGE. But I am also assuming that I need *something* in the lParam and/or wParam values. It seems to me that the index of the tab "clicked" has to be included in there somewhere and somehow. My question is how (or where)? And where do I find things like this? For example, I happened to find here at CodeProject some info on sending a MOUSEMOVE message to a window with the coordinates of the mouse position: SendMessage(hWndTarget, WM_MOUSEMOVE, fFlags, MAKELPARAM(x,y)); Where do I find things like the fact that the lParam is for flags and the wParam is for the coordinates? Any info is greatly appreciated. Thanks.

      A Offline
      A Offline
      Andrew Walker
      wrote on last edited by
      #2

      If you're using MFC, most of the classes abstract away the idea of having to send messages. Check out the documentation for CTabCtrl::SetCurSel(int nItem)? Or do you actually need to move the mouse?


      If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling

      D 1 Reply Last reply
      0
      • D David Fleming

        I'm trying to programmatically "click" a tab on a CTabCtrl. My understanding is that I can use SendMessage to do that by using TCN_SELCHANGE. But I am also assuming that I need *something* in the lParam and/or wParam values. It seems to me that the index of the tab "clicked" has to be included in there somewhere and somehow. My question is how (or where)? And where do I find things like this? For example, I happened to find here at CodeProject some info on sending a MOUSEMOVE message to a window with the coordinates of the mouse position: SendMessage(hWndTarget, WM_MOUSEMOVE, fFlags, MAKELPARAM(x,y)); Where do I find things like the fact that the lParam is for flags and the wParam is for the coordinates? Any info is greatly appreciated. Thanks.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/tab/notifications/tcn\_selchange.asp MSDN is the answer to all your SendMessage-Questions ;)

        D 1 Reply Last reply
        0
        • A Andrew Walker

          If you're using MFC, most of the classes abstract away the idea of having to send messages. Check out the documentation for CTabCtrl::SetCurSel(int nItem)? Or do you actually need to move the mouse?


          If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling

          D Offline
          D Offline
          David Fleming
          wrote on last edited by
          #4

          Sure, that selects the tab, but unfortunately it does NOT call the OnSelchange code. Therefore, simply calling SetCurSel won't activate the code that goes along with clicking on a tab. That's why I need to actually do a SendMessage -- to call the OnSelchange routine as though a tab was actually clicked.

          1 Reply Last reply
          0
          • L Lost User

            http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/tab/notifications/tcn\_selchange.asp MSDN is the answer to all your SendMessage-Questions ;)

            D Offline
            D Offline
            David Fleming
            wrote on last edited by
            #5

            Yeah, I've been there. Personally I find it decidedly NOT helpful.

            TCN_SELCHANGE Notification


            Notifies a tab control's parent window that the currently selected tab has changed. This message is sent in the form of a WM_NOTIFY message.

            Syntax

            TCN_SELCHANGE

            lpnmhdr = (LPNMHDR) lParam; 
            

            Parameters

            lpnmhdr
            Pointer to an NMHDR structure. The hwndFrom member is the handle to the tab control. The idFrom member is the child window identifier of the tab control. The code member is TCN_SELCHANGE.
            Return Value

            No return value.

            Remarks

            To determine the currently selected tab, use the TabCtrl_GetCurSel macro.

            Notification Requirements

            Minimum DLL Version None
            Header commctrl.h
            Minimum operating systems Windows NT 3.51, Windows 95

            See Also

            TCN_SELCHANGING

            Then if I go to SendMessage itself, I get:

            SendMessage Function


            The SendMessage function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message.

            To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function.

            Syntax

            LRESULT SendMessage( HWND hWnd,
            UINT Msg,
            WPARAM wParam,
            LPARAM lParam
            );
            Parameters

            hWnd
            [in] Handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.
            Msg
            [in] Specifies the message to be sent.
            wParam
            [in] Specifies additional message-specific information.
            lParam
            [in] Specifies additional message-specific information.
            Return Value

            The return value specifies the result of the message processing; it depends on the message sent.

            And that doesn't tell me anything about what I need in lParam or wParam, nor does it tell me where I might go about finding such information. *That's* actually the info I'm hoping to get my hands on - and an actual code example would be swell.

            A 1 Reply Last reply
            0
            • D David Fleming

              Yeah, I've been there. Personally I find it decidedly NOT helpful.

              TCN_SELCHANGE Notification


              Notifies a tab control's parent window that the currently selected tab has changed. This message is sent in the form of a WM_NOTIFY message.

              Syntax

              TCN_SELCHANGE

              lpnmhdr = (LPNMHDR) lParam; 
              

              Parameters

              lpnmhdr
              Pointer to an NMHDR structure. The hwndFrom member is the handle to the tab control. The idFrom member is the child window identifier of the tab control. The code member is TCN_SELCHANGE.
              Return Value

              No return value.

              Remarks

              To determine the currently selected tab, use the TabCtrl_GetCurSel macro.

              Notification Requirements

              Minimum DLL Version None
              Header commctrl.h
              Minimum operating systems Windows NT 3.51, Windows 95

              See Also

              TCN_SELCHANGING

              Then if I go to SendMessage itself, I get:

              SendMessage Function


              The SendMessage function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message.

              To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function.

              Syntax

              LRESULT SendMessage( HWND hWnd,
              UINT Msg,
              WPARAM wParam,
              LPARAM lParam
              );
              Parameters

              hWnd
              [in] Handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.
              Msg
              [in] Specifies the message to be sent.
              wParam
              [in] Specifies additional message-specific information.
              lParam
              [in] Specifies additional message-specific information.
              Return Value

              The return value specifies the result of the message processing; it depends on the message sent.

              And that doesn't tell me anything about what I need in lParam or wParam, nor does it tell me where I might go about finding such information. *That's* actually the info I'm hoping to get my hands on - and an actual code example would be swell.

              A Offline
              A Offline
              Antti Keskinen
              wrote on last edited by
              #6

              Post a TCM_SETCURFOCUS message, assuming that your Tab control is NOT using TCM_BUTTONS style. This message's default handler causes TCM_SELCHANGING and TCM_SELCHANGE messages to be generated & sent to the tab control. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

              D 1 Reply Last reply
              0
              • A Antti Keskinen

                Post a TCM_SETCURFOCUS message, assuming that your Tab control is NOT using TCM_BUTTONS style. This message's default handler causes TCM_SELCHANGING and TCM_SELCHANGE messages to be generated & sent to the tab control. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

                D Offline
                D Offline
                David Fleming
                wrote on last edited by
                #7

                Fantastic! It works perfectly. Thanks a bunch.

                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