Solved

canvas to procedure

Posted on 1997-03-26
5
254 Views
Last Modified: 2010-04-04
If I have a procedure which does some drawing on a canvas, how can I tell the procedure on WHICH canvas it should draw?
0
Comment
Question by:remcodek
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
mheacock earned 100 total points
ID: 1334962
You could pass a pointer to the canvas to the procedure...

type
  PCanvas = ^Canvas;

procedure Draw (i_pCanvas: PCanvas);
begin
   ...
   i_pCanvas^.Method(...);
   ...
end;

var
  cv: PCanvas;
begin
  pcv := @Form1.Canvas;
  Draw(pcv);
end;

Or something like this...test this out before grading me.
If you have further questions, feel free to comment.
0
 

Author Comment

by:remcodek
ID: 1334963
It looks like an elegant solution, yet Delphi won't swallow the type-declaration. On PCanvas=^canvas it replies Undeclared Identifier:'canvas'. What did I do wrong?
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1334964
My mistake...I apologize...

type
   PCanvas = ^TCanvas;

I made a simple mistake in the declaration...should be TCanvas...not Canvas.  Sorry.
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1334965
Oops...also...

  cv: PCanvas;

should be

  pcv: PCanvas;

I gotta proofread my answers being clicking the submit button.
0
 

Author Comment

by:remcodek
ID: 1334966
It's very simple:

procedure(x,y:integer;wCanvas:TCanvas);

begin
  wcanvas.pixels[x,y]:=.....
end;

works just fine.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now