My ActiveX control, drawing its child controls etc.
I have written an ActiveX control losely based of the instructions on
this guys website:
Now my control has two sub controls on it. On the left theres a
TreeCtrl, and on the right is a GridCtrl (this is the free MFC
CGridCtrl available on the Code Projects and Code Guru websites)
There is no dialog resource that I painted the controls on, they are
created dynamically, as in the URL example I pasted in above. The IDs
for the 2 controls were therefore manually included in resource.h
The idea is that there is really a lot of CGridCtrls hidden in the
background, but I only want one to appear at a time, selected when the
user clicks on an item in the TreeCtrl.
However I have two issues.
When I create each of the CGridCtrls, that takes an ID as a parameter,
should I give each one the same ID as defined in the resource.h file,
or should I give each one its own. Currently I only give the first one
the ID specified in the resource.h, and each subsequent one gets a new
Second issue, is that ALL my CGridCtrls get drawn. This is strange,
because my control knows which of the grids should be drawn and only
calls MoveWindow and ShowWindow on that particular grid. However I end
up with all of them being painted, and the correct one only appears
(with larger grids still visible behind) if I click on the control.
So I commented out my OnDraw and I get the same behaviour! Somewhere,
windows or something is sending either draw or paint, (or something)
messages directly to the controls themselves, and permitting them ALL
to draw themselves.
If this is the standard behaviour then why do you think the author of
the above URL bothered to handle OnDraw, if all he does is call
functions in the child control that get called eventualy anyway?
Did I do something wrong somewhere? Could this be something to do with
windowed vs windowless controls?
And the most important question, how can I prevent messages getting to
certain controls, or at least prevent certain controls from being drawn
or even visibile, unless I explicitly say? Assuming of course the child
control itself doesnt provide that feature.
Ideally I would do this just for certain messages, as I still want
certain messages to get straight to the child controls, (so I dont have
to write wrappers for when someone clicks on a tree item, or enters
info into the grid for example).