Re: Getting Combo Box Drop Down Button hWnd?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Derek Parnell wrote:
> 
> Al Getz wrote:
> 
> > BTW, what method is WinLib currently using to get ID's from hWnd's?
> 
> I only get the ID from hWnds that I've created. If I get a message from a
> foreign hWnd,
> I just do the default message processing for it.
> 
> Whenever a new control is created I allocate a spot in the control_hWnd
> sequence. The
> index for that spot is the new control's ID value. After creating the control
> and thus
> getting its hWnd, I save the hWnd in the sequence at control_hWnd[newid] and
> call SetWindowLong
> to save the new id in the control's User Data area.
> 
> In simple general terms I do this ...
> 
>     control_hWnd &= 0
>     newid = length(control_hWnd)
>     hWnd = call_c_func( CreateWindow, { . . . })
>     control_hWnd[newid] = hWnd
>     VOID = call_c_func( SetWindowLong, { hWnd, GWL_USERDATA, newid } )
> 
> Then in the message processing loop, when presented with a hWnd I call
> GetWindowLong
> to fetch the id for my control.
> 
>     id = c_func( GetWindowLong, {hWnd, GWL_USERDATA } )
>     if not integer(id) then
>        id = 0 -- Foreign hWnd
>     end if
> 
> The above code is greatly simplified as there a few fiddly bits when dealing
> with treeviews
> and combo boxes. 
> 
> For combo boxes, I get the first child hWnd which is the edit area and pretend
> to create
> a new edit box but use this info instead.
> 
>     control_hWnd &= 0
>     editid = length(control_hWnd)
>     edit_hWnd = call_c_func( GetWindow,{ hWnd, GW_CHILD})
>     control_hWnd[editid] = edit_hWnd
>     VOID = call_c_func( SetWindowLong, { edit_hWnd, GWL_USERDATA, edit_id } )
> 
> I've never needed to do any special processing of message from a combo box's
> button
> image. All the normal WM_COMMAND messages seem to cover that.
> 
> -- 
> Derek Parnell
> Melbourne, Australia
> irc://irc.sorcery.net:9000/euphoria
> 

Hello Derek,

I'm using a similar method but because i was worried about the user
of the lib wanting to use GWL_USERDATA i used an alternate method
for controls which didnt require exclusive setting of each id,
but now im not so worried so maybe i'll switch to using GWL_USERDATA
exclusively also.  This will mean i can reject id's too that are
zero (im assuming your's does that too).  Since the sub control listbox
will have an id of zero (when aquired with GetWindowLong) i can
simply default with those id's.

The only thing im wondering now is... if having an id assigned
to the sub control will add some sort of functionality to the
lib, in which case i would still seek to assign a private id.
I guess it doesnt matter that much though...


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu