Article View: borland.public.cppbuilder.multimedia
Article #1Re: How do I draw on TCanvas from inside a function call ?
From: Joseph
Date: Thu, 06 Mar 2003 23:34
Date: Thu, 06 Mar 2003 23:34
81 lines
3622 bytes
3622 bytes
Ok I worked it out. The reason why I was getting "Cannot Draw on
Canvas" runtime message is that CANVAS parameter inside the function
points to a TControlCanvas "interface" but nothing to draw on (ie., to
real device context). So this is the fix ...
void TForm1::DrawOnCanvas ( TControlCanvas *CANVAS ) {
CANVAS = new TControlCanvas ;
CANVAS->Control = Tabsheet ; // draw on Tabsheet
CANVAS->Pen->Color = clBlue ;
CANVAS->MoveTo(0,0);
CANVAS->LineTo(100,200);
delete CANVAS ;
};
Actually, I don't even need to pass in a TControlCanvas parameter, so
the function can be simplified to this ...
void TForm1::DrawOnCanvas ( ) {
TControlCanvas *CANVAS = new TControlCanvas;
CANVAS->Control = Tabsheet ; // draw on Tabsheet
CANVAS->Pen->Color = clBlue ;
CANVAS->MoveTo(0,0);
CANVAS->LineTo(100,200);
delete CANVAS ;
};
Cheers,
Joseph 76.
joseph.redimerio@baesystems.com (Joseph) wrote in message news:<7b424d28.0303042203.21e36935@posting.google.com>...
> Hello All,
>
> Is it possible to draw on TControlCanvas from inside a function call ?
>
> I mean ...
>
> void __fastcall TForm1::ShowTabSheet (Object *Sender) {
>
> TControlCanvas *pCanvas = new TControlCanvas ;
>
> pCanvas->Control = Tabsheet ; // ie., TForm1::Tabsheet. Need to draw
> // on TabSheet, not on the main Form.
>
> DrawOnCanvas ( pCanvas ) ; //** I need to draw on pCanvas from here
>
> delete pCanvas ;
> };
>
>
>
> void TForm1::DrawOnCanvas ( TControlCanvas *CANVAS ) {
>
> CANVAS->Pen->Color = clBlue ;
> CANVAS->MoveTo(0,0);
> CANVAS->LineTo(100,200);
>
> };
>
>
> ... This compiles and Links OK, but when I run it I get an error
> message saying that "Canvas does not allow drawing". If I do the
> drawing from inside the calling function, it's ok. But if done via a
> function call, it won't draw.
>
> Is the above the appropriate way of drawing on TControlCanvas from
> inside a function ?
>
>
>
> Regards,
> Joseph 76
Technical Details
Message-ID:
<7b424d28.0303061534.606bca3@posting.google.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mailReferences:
<7b424d28.0303042203.21e36935@posting.google.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,69eca6f308d0a81a X-Google-Attributes: gid10cc67,public X-Google-Thread: 10e433,69eca6f308d0a81a X-Google-Attributes: gid10e433,public X-Google-Thread: 10d0fc,69eca6f308d0a81a X-Google-Attributes: gid10d0fc,public X-Google-Thread: 101d59,69eca6f308d0a81a X-Google-Attributes: gid101d59,public X-Google-Thread: f5ca7,69eca6f308d0a81a X-Google-Attributes: gidf5ca7,public X-Google-ArrivalTime: 2003-03-06 15:34:56 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail From: joseph.redimerio@baesystems.com (Joseph) Newsgroups: borland.public.cppbuilder.multimedia,borland.public.cppbuilder.nativeapi,borland.public.cppbuilder.graphics,borland.public.cppbuilder.winapi,borland.public.cppbuilder.vcl.components.writing Subject: Re: How do I draw on TCanvas from inside a function call ? Date: 6 Mar 2003 15:34:56 -0800 Organization: http://groups.google.com/ Lines: 81 Message-ID: <7b424d28.0303061534.606bca3@posting.google.com> References: <7b424d28.0303042203.21e36935@posting.google.com> NNTP-Posting-Host: 130.76.32.15 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1046993696 28208 127.0.0.1 (6 Mar 2003 23:34:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 6 Mar 2003 23:34:56 GMT