Solved

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

Posted on 1998-11-02
8
318 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
  • 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 30 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

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

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…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

22 Experts available now in Live!

Get 1:1 Help Now