Handle to scrollbar in CListCtrl
-
How can I get handle to the CScrollBar which is created automatically when I insert enough items to my report-view?
The CListCtrl is responsible for upkeeping and drawing it's scroll bar. The control itself handles the messages and drawing related to this window item, that is, there is no external control embedded. Or, at least none that I know of. You could use Spy++ to see if you can attach to the scroll bar itself on the control. If you can, then it exists, if you can't, then it's embedded. What is it that you'd need to accomplish using the handle ? To scroll the control ? To draw it yourself ? -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.
-
The CListCtrl is responsible for upkeeping and drawing it's scroll bar. The control itself handles the messages and drawing related to this window item, that is, there is no external control embedded. Or, at least none that I know of. You could use Spy++ to see if you can attach to the scroll bar itself on the control. If you can, then it exists, if you can't, then it's embedded. What is it that you'd need to accomplish using the handle ? To scroll the control ? To draw it yourself ? -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.
I Checked the control with spy++ and yeah, I'm not able to attach to it.. It seems that my whole approach for the problem was completely wrong. Perhaps I tried to do things too comlicated, since the actual problem is that I wan't to know when the scrollbar is created and when its destroyed, so that I can do something interesting.. Now I wrote a message handler for WM_PARENTNOTIFY thinking that also the creation of the scrollbar would cause this message to be sent to my custom-control.. but it seems that it is not sent in such cases. What would be a better approach? -Jussi
-
I Checked the control with spy++ and yeah, I'm not able to attach to it.. It seems that my whole approach for the problem was completely wrong. Perhaps I tried to do things too comlicated, since the actual problem is that I wan't to know when the scrollbar is created and when its destroyed, so that I can do something interesting.. Now I wrote a message handler for WM_PARENTNOTIFY thinking that also the creation of the scrollbar would cause this message to be sent to my custom-control.. but it seems that it is not sent in such cases. What would be a better approach? -Jussi
-
I Checked the control with spy++ and yeah, I'm not able to attach to it.. It seems that my whole approach for the problem was completely wrong. Perhaps I tried to do things too comlicated, since the actual problem is that I wan't to know when the scrollbar is created and when its destroyed, so that I can do something interesting.. Now I wrote a message handler for WM_PARENTNOTIFY thinking that also the creation of the scrollbar would cause this message to be sent to my custom-control.. but it seems that it is not sent in such cases. What would be a better approach? -Jussi
To determine if the window has a scrollbar(s) you can check it's style and look for WS_HSCROLL & WS_VSCROLL. I don't think there is a notification message for the scrollbar create/destroy event, but monitoring all the messages that might cause it should help. WM_SIZE (list view), , WM_NOTIFY: LVN_INSERTITEM, LVN_DELETEITEM (listview parent), HDN_BEGINTRACKA, HDN_BEGINTRACKA (listview). Edward
-
I Checked the control with spy++ and yeah, I'm not able to attach to it.. It seems that my whole approach for the problem was completely wrong. Perhaps I tried to do things too comlicated, since the actual problem is that I wan't to know when the scrollbar is created and when its destroyed, so that I can do something interesting.. Now I wrote a message handler for WM_PARENTNOTIFY thinking that also the creation of the scrollbar would cause this message to be sent to my custom-control.. but it seems that it is not sent in such cases. What would be a better approach? -Jussi
The best approach by far is to derive a custom control from CListCtrl, then add a CSrollBar member to it and manually create and destroy it as necessary. This allows complete control on how the scroll bar works, but if you are unfamiliar with custom control creation, it might prove somewhat difficult. There is an article available in CodeProject that discusses a list control with it's scroll bars removed. By looking at it's code, you might find some tips or clues on how to implement your solution. Lars Werner's article Hide scrollbars from a CListCtrl[^]. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.
-
To determine if the window has a scrollbar(s) you can check it's style and look for WS_HSCROLL & WS_VSCROLL. I don't think there is a notification message for the scrollbar create/destroy event, but monitoring all the messages that might cause it should help. WM_SIZE (list view), , WM_NOTIFY: LVN_INSERTITEM, LVN_DELETEITEM (listview parent), HDN_BEGINTRACKA, HDN_BEGINTRACKA (listview). Edward