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

Skip to first unread message

Russell Potter

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

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", "",
> x, y, cx, cy, wnd, (HMENU)
> 0, GetWindowLong(wnd,

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

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?


James Brown

Nov 12, 2005, 1:10:39 PM11/12/05
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


Free win32 software, sourcecode and tutorials

"Russell Potter" <russellpotter AT optusnet DOTcom DOT au> wrote in message

Russell Potter

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


> 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

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

My apologies,

Norman Bullen

Nov 17, 2005, 9:17:04 AM11/17/05
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.


To reply, change domain to an adult feline.

Reply all
Reply to author
0 new messages