Huahe said:
Hi,
I have an checkedlistbox with a lot of items, so there is a vertical
scrollbar in the checkedlistbox.
I want to make the checkedlistbox invisible when the mouseleave event goes
off.
The mouseleave event goes off when I move the mouse to the scrollbar. Can
someone explain this to me? Isn't the scrollbar a part of the checkedlistbox?
It is, but it's part of it's non-client area. All Windows windows
(which includes what we think of as forms, and also controls) have a
client area - that part that the window can draw - and a non-client
area - that part that Windows draws. This is most obvious with a
regular Form - the titlebar (including min max buttons etc), and the
border, are the non-client area. As far as the form is concerned, it
only has access to its own client area - so for instance (0,0) is the
top left corner not of the form as the user sees it, but of the bit
within the Windows-drawn border, below the title bar.
It appears MouseLeave is triggred when the client area is left, not the
control as a whole. There are probably two acceptable solutions:
1) As per <
http://tinyurl.com/b95mc> you could create a Timer that
watches for when the mouse pointer actually leaves the entire control
2) As per <
http://tinyurl.com/9bbcg> you could subclass the listbox and
watch for the non-client mouse messages
Option 1 is probably easier, but neither are particularly elegant.