Discussion:
Newbie Question - Child Window ID
(too old to reply)
Bucko
2003-07-14 21:37:04 UTC
Permalink
Hi

In Charlez Petzold's book "Programming Windows 5th Edition" he creates an
application called checker 3. This displays a grid of child windows, that
you can click on and they will fill in with an X shape. Now, in a later
chapter, Petzold says "If we wanted to, we could add a facility to ChildProc
to send a message to its parent window procedure (WndProc) whenever a
rectangle is checked or unchecked" I understand (and indeed have
implemented) this concept. However he also says "Perhaps for this message
the child window could set wParam to its child window ID" Now, this is
exactly what I want to do, but I cant for the life of me find out how to get
the child window ID variable in ChildProc, where is it? How do I set wParam
(or indeed any variable) to the child window ID within ChildProc?

Appreciate any help anyone can offer!

Thanks

Matt
Anaz
2003-07-18 06:12:27 UTC
Permalink
Hi Matt,
The child window will send messages notifying the parent window when
its state has changed. The child window sends WM_COMMAND messages to
the parent window with its control ID in the low word of wParam, the
notification code in the high word of wParam, and its window handle in
lParam. Each child window control has different notification codes,
refer to your Win32 API reference for more information.
The parent window can send commands to the child windows too, by
calling SendMessage function. SendMessage function sends the specified
message with accompanying values in wParam and lParam to the window
specified by the window handle. It's an extremely useful function
since it can send messages to any window provided you know its window
handle.
So, after creating the child windows, the parent window must process
win.WM_COMMAND messages to be able to receive notification codes from
the child windows.
Regards
[Anaz K Kabeer]

Loading...