Solved

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

Posted on 1998-11-02
8
328 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 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
Independent Software Vendors: 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

Independent Software Vendors: 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

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 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