Thread: Multiple Trackbars and controling them both

  1. #1
    Registered User AtomRiot's Avatar
    Join Date
    Jan 2003
    Posts
    120

    Multiple Trackbars and controling them both

    How would one go about controlling two horizontal slider bars created from the trackbar_class and be able to process the message for each one of them independantly.

    I tried somehting like this:
    Code:
    case WM_HSCROLL:
    {
        switch(LOWORD(lParam))
        {				
            case TB_LINEUP:
            { 
                switch(LOWORD(wParam))
                {
                    case HSCROLLTOP:
                }
            }
        }
    }
    MSDN says that the wParam is the source of the message but I have not found this to be the case so I am obviously doing something wrong.
    All Your Base Are Still Belong to Someone!!!
    And you Remember that!!!

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Quote Originally Posted by MSDN: About Trackbar Controls
    A trackbar notifies its parent window of user actions by sending the parent a WM_HSCROLL or WM_VSCROLL message. A trackbar with the TBS_HORZ style sends WM_HSCROLL messages. A trackbar with the TBS_VERT style sends WM_VSCROLL messages. The low-order word of the wParam parameter of WM_HSCROLL or WM_VSCROLL contains the notification code. For the TB_THUMBPOSITION and TB_THUMBTRACK notifications, the high-order word of the wParam parameter specifies the position of the slider. For all other notifications, the high-order word is zero; send the TBM_GETPOS message to determine the slider position. The lParam parameter is the handle to the trackbar.
    So to get the three required bits of information we have:
    Code:
    case WM_HSCROLL:
        int ctrlID = GetDlgCtrlID((HWND) lParam);
        int requestID = LOWORD(wParam);
        int position = SendMessage((HWND) lParam, TBM_GETPOS, 0, 0);
    
        switch (requestID)
        {
            case TB_LINEUP:
            {
                switch (ctrlID)
                {
                    case TRACKBAR1:
                    ...
    
                    case TRACKBAR2:
                    ...
                }
            }
        }

  3. #3
    Registered User AtomRiot's Avatar
    Join Date
    Jan 2003
    Posts
    120
    ah hok, excellent. I see where my mistake was. I was not doing the GetControlID. Thanks
    All Your Base Are Still Belong to Someone!!!
    And you Remember that!!!

Popular pages Recent additions subscribe to a feed