Sliderbar Problem
-
Hi, I am new to windows programming. In my code I would require to change the slider bar position (I am actually invoking the sliderbar from UI using win32 API, so I donot have source code of the application), which I have accomplished by sending message. ::SendMessage( aControlHWnd, TBM_SETPOS, (WPARAM) (BOOL) TRUE, (LPARAM)(LONG) aPosition ); The problem is with the updation of the window according to the new sliderbar position, I mean, when I change the position of the sliderbar it is changed visually, but the corresponding values in other objects (like textbox showing the value related to this sliderbar) are not updated. To accomplish this I tried ::NotifyWinEvent( EVENT_OBJECT_VALUECHANGE, theDialogHWnd, OBJID_HSCROLL, CHILDID_SELF ); where theDialogHWnd is the handle for the dialog window containing the sliderbar and the textbox, but it didn't work. I am not sure if the parameters I am using are correct, or the event I am trying to notify, or may be my approach to the problem itself is wrong. I do understand that this can be easily accomplished by sending a keyboard or mouse event, but I am tryin not to use it. Any help would be greatly appriciated. Thanks.
-
Hi, I am new to windows programming. In my code I would require to change the slider bar position (I am actually invoking the sliderbar from UI using win32 API, so I donot have source code of the application), which I have accomplished by sending message. ::SendMessage( aControlHWnd, TBM_SETPOS, (WPARAM) (BOOL) TRUE, (LPARAM)(LONG) aPosition ); The problem is with the updation of the window according to the new sliderbar position, I mean, when I change the position of the sliderbar it is changed visually, but the corresponding values in other objects (like textbox showing the value related to this sliderbar) are not updated. To accomplish this I tried ::NotifyWinEvent( EVENT_OBJECT_VALUECHANGE, theDialogHWnd, OBJID_HSCROLL, CHILDID_SELF ); where theDialogHWnd is the handle for the dialog window containing the sliderbar and the textbox, but it didn't work. I am not sure if the parameters I am using are correct, or the event I am trying to notify, or may be my approach to the problem itself is wrong. I do understand that this can be easily accomplished by sending a keyboard or mouse event, but I am tryin not to use it. Any help would be greatly appriciated. Thanks.
When slider bars are moved they post either a WM_HSCROLL or a WM_VSCROLL to its parent. Try posting these messages to the parent window of the slider bar. To determine which message should be sent check the slider control for the style TBS_VERT. See if something like this works: int iPos = m_slider->GetPos(); if (m_slider->GetStyle() & TBS_VERT) pWnd->PostMessage(WM_VSCROLL, (WPARAM)((iPos << 16) | SB_THUMBPOSITION), (LPARAM)NULL); else pWnd->PostMessage(WM_HSCROLL, (WPARAM)((iPos << 16) | SB_THUMBPOSITION), (LPARAM)NULL);