Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

canvas to procedure

Posted on 1997-03-26
5
Medium Priority
?
269 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
mheacock earned 300 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

730 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