Making a drop down control

I am trying to build a custom drop down control. Basically, in this case, I have an ActiveX control that has a text box and a down arrow button. When the arrow button is clicked, I want to display a form that is stored in the control. Now I can do this part.

What I need help with is possitioning the form directly under the ActiveX control on the user's form and how to detect if a mouse click was outside of the newely displayed form.

For the sake of this question, the form being opened can be blank. Later i will add various controls to it that will be used to populate the textbox in the activex control.

Anyone have a chunk of code that can popup a form under any given control then hide it if a mouse click happens outside of the popped form?
LVL 3
schworakAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

anthonycCommented:
I wrote a drop down calendar control once if you want to see it  Let me know..

but as on how to do it.. Do this..

When you show the form (drop down), call "SetCapture" API with the HWND of the form.  Now that will force ALL mouse events to go to the form, NO MATTER where you click.  You'll need to write a function to pass the mouse to the control on your form it really clicked on.  You can do that by passing the X, Y in the mousedown event on the form to a function to find the control.  If the X, Y are negative, OR OUTSIDE the boundaries of the form (width, height) then you can assume it is outside of the control and close the form.

Does that make ssense? W hen you close the form, Call releasecapture to get normal mouse operation back
0
schworakAuthor Commented:
anthonyc:

Well, that is part of the answer. I will give you the points, but the only way I can add a comment without accepting first is to reject. So add a little more info as an answer and I will accept that.

Yeah, I would love to see that drop calendar too. glenn@g-world.com if you want to EMail it to me.

Anyway, I will give the set capture to check for the mouse clicks. But could you tell me how you get the form to line up directly under your main control when you do the Drop Down trick? I can't figure out what API to use to capture my control's position relative to the screen not the form it sits on.
0
anthonycCommented:
oh I forgot to type that...

Private Sub PositionDropDown()
    Dim rct As RECT
    GetWindowRect UserControl.hwnd, rct
    SetWindowPos m_frmDown.hwnd, -1, rct.Left, rct.Top + UserControl.ScaleY(picCombo.Height, vbTwips, vbPixels), _
                                 0, 0, SWP_NOSIZE
End Sub


The drop down is on the way to glenn@g-world.com
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

schworakAuthor Commented:
Thank you so much!
0
schworakAuthor Commented:
Oops! Ran into one little snag...

SetCapture doesn't work for me. I have several controls on the dropdown form that need to be able to be selected/changed. One is a list box.

SetCapture intercepts the first click and loses it's capture on the second click and I can't seem to get it to regain capture.

How do I keep the capture of the mouse events and also allow the control being clicked to also get the mouse events? Do I need some type of subclassing?
0
anthonycCommented:
did you remmeber to use releasecapture when the mouse goes up?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.