Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sub-classed combo-box Control ID problem ...

968 views
Skip to first unread message

Russell Potter

unread,
Nov 11, 2005, 8:57:48 PM11/11/05
to

I have a combo-box control whose window procedure I've
sub-classed in order to perform some custom processing when
events (such as the selection of a combo-box choice) occurs

the statement which creates the combo-box (which I've
verified as working) is as follows: (Although note I haven't
included the code - also verified as working - which
sub-classes the control:)

> CreateWindow("ComboBox", "",
> WS_VISIBLE | WS_CHILD,
> x, y, cx, cy, wnd, (HMENU)
> 0, GetWindowLong(wnd,
> GWL_HINSTANCE), NULL);

Where "x", ""y, "cx" and "cy" are the position,
width and height of the control, respectively, and
"wnd" is the control's parent.

Trouble is, in my subclassed combo-box's "WM_COMMAND"
message handler I found that the high-word of "wParam" (which
should contain the identifier of the control that sent the
"CBN_SELENDOK" message: namely - if things are working
as I want them to - zero), is actually instead decimal 1000,
which stuffs up lots of other code which depends on the ID being
correct

I'm guessing that at least part of my problem is that my
combo-box control's window procedure is trying to handle a
"CBN_SELENDOK" message sent by itself, when a
combo-box choice is made, rather than to whichever
window the message is sent when this occurs:

Is this guess even on the right track?. Could anyone tell me
the window to which the "CBN_SELENDOK"
"WM_COMMAND" message is sent? (I.e. if this was a
"WM_NOTIFY" message, MSDN tells me the message
would be sent to the window's parent, but it doesn't seem
to tell me where it's sent in the case of "WM_COMMAND"
- unless I just haven't looked hard enough).

but if I'm barking up the wring tree: what else could be
going wrong?

Thanks,
Russell


James Brown

unread,
Nov 12, 2005, 1:10:39 PM11/12/05
to
read the documentation for WM_COMMAND carefully.

the LOWORD of wParam is the control-id
the HIWORD of wParam is the nodification code (ie. CBN_xxx message )
lParam is the window-handle to the control

James

--
www.catch22.net
Free win32 software, sourcecode and tutorials


"Russell Potter" <russellpotter AT optusnet DOTcom DOT au> wrote in message
news:43754bfc$0$23947$afc3...@news.optusnet.com.au...

Russell Potter

unread,
Nov 15, 2005, 5:59:56 AM11/15/05
to

/James,

> the LOWORD of wParam is the control-id
> the HIWORD of wParam is the nodification code (ie. CBN_xxx message )
> lParam is the window-handle to the control

I checked my code more carefully and found I had actually
correctly checked the low-word of "wParam" for the ID of
sender.

I must have typed "high-word"in my haste without first
checking to the appropriate extent

My apologies,
Russell

Norman Bullen

unread,
Nov 17, 2005, 9:17:04 AM11/17/05
to
Controls send WM_COMMAND messages to their parent, not to themselves. If
you have subclassed a COMBOBOX control and your subclass routine is
receiving WM_COMMAND messages, they are from the LISTBOX and EDIT
controls which the COMBOBOX creates as children of itself. (As I
remember, it gives them control IDs of 1000 and 1001.)

Look for the WM_COMMAND messages that you want to handle being sent to
the parent of the COMBOBOX, the window the handle of which is in wnd
when you call CreateWindow(). You don't need to subclass the COMBOBOX to
get these messages.

Norm

--
--
To reply, change domain to an adult feline.

0 new messages