The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Biterider on September 26, 2007, 05:54:28 AM

Title: ListBox outside parent window
Post by: Biterider on September 26, 2007, 05:54:28 AM
Hi
I'm running into troubles while building a new control in asm like a ComboBox and I need some help.
What I want to achieve is to have a ListBox like the ComboLBox has, that can extend outside of the parent window.
I found that the classic ComboBox uses the ComboLBox class and sets its parent to the desktop window. So far so good, but the problem is that I lost the focus of the parent window, unlike the behaviour of a regular ComboBox.
At this point I'm unsure if I have to return the focus to the original control and capture the mouse to finally send these messages to the ComboLBox...
If this is not the way to go I have no clue how MS arranged things to work nicely.
Any idea?

Regards,

Biterider
Title: Re: ListBox outside parent window
Post by: Tedd on September 27, 2007, 05:39:32 PM
Would it work better if you create the listbox with WS_EX_TOOLBAR style (in exstyle) and "WS_VISIBLE or WS_POPUP or WS_BORDER" (in the 'normal' style) - which would allow it to be a 'separate' window, but still a child of your main window?
Title: Re: ListBox outside parent window
Post by: Biterider on September 27, 2007, 06:23:28 PM
Hi Ted
Yes, you are right, the styles you mentioned are necessary to setup the pseudo child properly. Unfortunately, it doesnt solve the focus problem.
In the meantime I got the sourcecode of the ComboBox control from the ReactOS project. I'm reading it right now, but I can say that I wasn't too far away from this particular solution with my assumptions.

Regards,

Biterider
Title: Re: ListBox outside parent window
Post by: MichaelW on September 27, 2007, 06:27:21 PM
According to  this (http://home.att.net/~secondcut/nitecomb.htm) the list captures the mouse when it is dropped down.
Title: Re: ListBox outside parent window
Post by: Tedd on September 28, 2007, 12:15:14 PM
What's the focus problem then?
I would expect (I guess I should test it first ::)) with a toolwindow in focus, its parent should still have the indicated focus.
You can use WM_KILLFOCUS to find out which window you're main one is losing focus to (either your listbox, or another window); and possibly WM_ACTIVATE/ACTIVATEAPP will come in useful?
Title: Re: ListBox outside parent window
Post by: Biterider on September 28, 2007, 01:38:52 PM
Hi Tedd
Unfortunately the WS_EX_TOOLWINDOW style does not preserve the parent focus.

Biterider
Title: Re: ListBox outside parent window
Post by: Tedd on September 29, 2007, 12:52:37 PM
Okay, I've had a little play and... got nowhere :dazzled:
I see what you mean with toolwindow. It seems the window does need WS_CHILD, but then it's cropped to the parent.
And setting the parent to the desktop results in some weird effects. But if that's what the actual combobox does, then I suppose it's a matter of setting the correct styles and then fiddling the focus and capture ::)