Drac's questions on drop down lists in combo boxes 
Author Message
 Drac's questions on drop down lists in combo boxes

Drac, I tried to e-mail you but my server rejected your address, so I am
posting the answer to your question here...

<We have a dropdown usercontrol not written by me>
<but I am now responsable for maintaining it.  The>
<problem I have is that it uses setcapture while>
<the dropdown part is shown.  This causes a problem>
<when the list has enough items in it to cause the>
<scollbar to be shown.>
<>
<The mouseclick is captured by the listbox but has>
<no effect the scrollbar.>
<>
<I can't seem to get the hwnd of this scrollbar.>
<>
<How can I make it work so that if the user has>
<clicked on the scollbar then the scollbar moves?>
<>
<The only alternative I have at the moment it to>
<remove the setcapture, which as you know causes>
<the dropdown part to remain on screen under>
<certain circumstances.>
<>
< appreciate any enlightenment.>

You just asked the $60,000 question, or, in your case, the 60,000 Question.

The MouseMove event for the DropDown picturebox needs to ReleaseCapture from
the dropdown and SetCapture to the scrollbar when the mouse is over the
scroll bar.

This allows the mouse to interact with the scroll bar, letting the user drag
the thumbtrack or click on the slider bar or the buttons. If the scroll bar
supported a MouseMove event as well, we could use it to pass control back to
the DropDown when the mouse moves away from the scroll bar. However, the
scroll bar doesnt support any such event, so I had to code around it!

Now comes the tricky bit...

Include a timer in the user control. When the SetCapture is given to the
scroll bar, enable the timer with an interval of 10 (1/100th of a second).
Each time the timer goes off (Timer1_Timer event), get the current position
of the mouse cursor on the screen (GetCursorPos API). If the mouse cursor is
no longer over the scroll bar, SetCapture back to the DropDown picture box
and disable the timer!

You can get the RECT of the scroll bar and DropDown picture box using the
GetWindowRect API, passing the handle (.hwnd property) of the scroll bar and
picture box. If, for some reason, you are not getting the hwnd property of
the scroll bar supported, call Microsoft! Just kidding. The hwnd property
has been supported on all controls since VB 4.

Hope this helps! Martin.



Sun, 13 May 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Drop Down List Box - Drop Down portion does not always disappear after Click event

2. Creating Drop down lists (non combo boxes) in VB5 Toolbar

3. Make Combo or list boxes drop down????

4. Modify the Width of the Drop Down List in a Combo Box

5. Combo box with Multiselect (drop down list with multiselect)

6. HELP: Combo Box Drop Down List Questin, Thanks in advance

7. Inserting data into combo box with style 2 - drop down list

8. Making Combo-List Box drop-down automatically

9. how to drop down a combo box list (newbie)

10. Size of Combo-box's drop-down window

11. Drop Down Combo box with smaller down arrow icon

12. Drop-Down List (ComboBox) and Text Box questions

 

 
Powered by phpBB® Forum Software