Solved

canvas to procedure

Posted on 1997-03-26
5
267 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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Suggested Courses
Course of the Month6 days, 22 hours left to enroll

622 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