Board index » cppbuilder » Drawing on an other form's canvas

Drawing on an other form's canvas

Hi all,

I have a question regarding drawing on canvases:

I want to make a class THupseflups, in which I have a method:

void
THupseflups::DrawPolygon(TFrmDraw *Form)
{
....
Form->Canvas->Polygon(points, 5);
...

Quote
}

The form will appear with the polygon, only if I Show() it BEFORE drawing
the polygon, and issuing an Application->MessageBox or so on top of the form
will destroy the picture.

My question: How can I use a method outside the form to draw persistent
pictures on it?

Thanks

Walter
wal...@lvpres.nl

 

Re:Drawing on an other form's canvas


On Wed, 9 Dec 1998 12:11:59 +0100, "Walter Rutten"

Quote
<wal...@lvpres.nl.REMOVETHISTOREPLY> wrote:
>The form will appear with the polygon, only if I Show() it BEFORE drawing
>the polygon, and issuing an Application->MessageBox or so on top of the form
>will destroy the picture.

>My question: How can I use a method outside the form to draw persistent
>pictures on it?

You need to intercept the WM_PAINT message. Since the form belongs
to the same process you can replace its WindowProc member to do this.
See the docs for more details.

Re:Drawing on an other form's canvas


There's not much about replacing WindowProc in the docs. Can you give me
some more hints?

*Walter*

Quote
>>My question: How can I use a method outside the form to draw persistent
>>pictures on it?

>You need to intercept the WM_PAINT message. Since the form belongs
>to the same process you can replace its WindowProc member to do this.
>See the docs for more details.

Re:Drawing on an other form's canvas


On Wed, 9 Dec 1998 17:18:36 +0100, "Walter Rutten"

Quote
<wal...@lvpres.nl.REMOVETHISTOREPLY> wrote:
>There's not much about replacing WindowProc in the docs. Can you give me
>some more hints?

Store it then set it to your own routine, calling the stored one at
the end of your routine if you want the msg to be handled in the
normal way. Remember to restore the original WindowProc before
deleting the component.

I don't have any example code, sorry.

Other Threads