Re: Problem drawing with GDI+ within a CStatic
Having to call a method in your CStatic derived class to tell it that it
needs to change it's states is actually the elegent way of doing things.
Much like MFC's ShowWindow, ModifyStyle, EnableWindow, and so on.
You don't want to access the parent dialogs memebers from the child control.
That will spell disaster when you try to put the control on another dialog
that might not have the same members, or their names are different.
With all that said, my answer is somewhat close minded since I don't know
exactly what information the static control needs from the parent dialog
box. If calling methods is not that elegent, for example if you have a 100
controls and if you end up having to call a method for every control on the
dialog box, then some rethinking is in order.
AliR.
<shanehopcroft@hotmail.com> wrote in message
news:1153153120.416550.58960@h48g2000cwc.googlegroups.com...
Apologies in advance if this is the wrong place to post this, or if it
just a silly question.
I am trying to make a little application which behaves a bit like a
paint program. It has several controls, one of which is a static which
I want to draw lines on with GDI+. The behaviour of the lines drawn on
the static depends on the other controls on the dialog (i.e. some lines
are not drawn if a checkbox is checked, etc. Also, the user needs the
ability to click on the lines and have them change colour.
I got this working quite well, but I couldn't work out how to get the
lines to draw within (on) the static. I worked out that I needed to
sub-class the static to make my own control, with it's own OnPaint
method.
That worked quite well - the lines were only drawn within the
boundaries of the control, but now I can't work out how to access the
controls in the main dialog. E.g., how does my new control know if the
check box on the dialog is checked or not?
The only way that I can see to do it is to set the data in my new
control using function calls from the dialog. I think this would work,
but it seems terribly inelegant.
Is subclassing the control the right thing to do in this case? If so,
how can I access members in the parent dialog?
If subclassing is not the right way to go, can anyone suggest if there
is a way of specifying the exact region on a dialog that I want to draw
in?
Thanks in advance for any help.