Re:ComboBox.OnChange Events from Keyboard Input
Quote
Kurt Barthelmess (TeamB) wrote:
> I sort of have to disagree with you here. First, the parent is sent
> a CBN_SELCHANGE method when arrowing through the list. Second,
> if the control is asked what the currently selected item is, it will
> answer with whatever you have arrowed to.
Both points are true. However...
Quote
> In order to make productive use of the CBN_SELENDOK or
> CBN_SELENDCANCEL messages, you have to first note the
> CBN_DROPDOWN... [snip description of process]
The control does all that for you. All you have to do is this:
1. Don't do anything in OnChange.
2. When you get CBN_SELENDOK you do what you have done in OnChange.
That's all there is! Windows will handle the rest.
Quote
> ... so unless the parent is clever enough to pass them
> on to the child before processing them (and be prepared
> to ignore them if the control says to),
Fortunately for us, Delphi is such a clever parent. :) The CBN_*
notifications come through the WM_COMMAND handler of the parent. Delphi
sends these back to the originator as CN_COMMAND messages which will give
your control first crack at the CBN_* notifications.
I can assure you that the things mentioned here actually do work. They have
been part of the Shell Control Pack since 1996!
Quote
> Ideally, the message should have been sent to the child
> in the first place
Nowadays yes, but when the 'parent does the work' idea was designed it
saved you subclassing (in the Windows sense) every dialog control. Of
course, now even MFC subclasses every control so what was a good idea then
is a pain in the {*word*82}now.
--
Tim Knipe | Plasmatech Software Design | http://plasmatech.com
Explorer controls for Delphi, C++Builder and soon ActiveX!