[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Canvas.Draw should stay on Form1.Refresh.. It doesn't

Posted on 1998-11-02
8
Medium Priority
?
330 Views
Last Modified: 2012-05-04
Say I have a form, and say that form's got a canvas (wow!).

If i'd have a bitmap like this:

var bmp : TBitmap

And I'd load a bitmap into it, much like this:

bmp := TBitmap.Create;
bmp.loadfromfile('bitma.bmp');

Then if I'd do this with my canvas:

form1.canvas.draw(10,10,bmp);

it would draw the bitmap with the left top corner on 10,10.
So far, so good..

However, if I now do a form1.refresh, the canvas gets reset
to the default form1.colour. This also happens if I drag
a window over pieces of the canvas that have been drawn over.

I would actually like the canvas to keep what it's got, even
on a refresh. I've tried this with a TPaintBox, but it did
quite the same.

binkzz
0
Comment
Question by:binkzz
[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
  • 4
  • 2
  • 2
8 Comments
 
LVL 4

Expert Comment

by:erajoj
ID: 1345477
Put it in "OnPaint".

/// John
0
 
LVL 4

Author Comment

by:binkzz
ID: 1345478
small example?
0
 
LVL 10

Accepted Solution

by:
viktornet earned 90 total points
ID: 1345479
Here is an example....

var
  BMP : TBitmap;

//OnCreate()
procedure TForm1.Form1Create(Sender : TObject);
begin
  BMP := TBitmap.Create;
  BMP.LoadFromFile('C:\windows\desktop\test.bmp');
end;
//OnDestroy()
procedure TForm1.Form1Destroy(Sender : TObject);
begin
  BMP.Free;
end;
//OnPaint()
procedure TForm1.Form1Paint(Sender : TObject);
begin
  Canvas.Draw(10,10, BMP);
end;

somewhere in your program just call Refresh...For example in the Form's OnResize()
//OnResize()
procedure TForm1.Form1Resize(Sender : TObject);
begin
  Refresh;
begin

Cheers,
Viktor
0
Technology Partners: 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!

 
LVL 10

Expert Comment

by:viktornet
ID: 1345480
oppps..... Sorry John.... PLease reject my answer and let John answer if the solution works...

Cheers,
Viktor
0
 
LVL 4

Author Comment

by:binkzz
ID: 1345481
John gave me the answer, you gave me the example requested. In
my opinion you both deserve the points for this, but as you did
most of the hard work, I'm affraid the points will have to go to
you.

Sorry john, life's a bitch, and then you marry one.

Binkzz
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1345482
:-|
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1345483
No tengo ningún problema con ese, muchacho.

/// John
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1345484
:-| . o O
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

656 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