Re: Getting Combo Box Drop Down Button hWnd?

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

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

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

Search



Quick Links

User menu

Not signed in.

Misc Menu