Solved

Timage descendent - designtime painting

Posted on 2003-11-05
7
323 Views
Last Modified: 2013-11-23
My component has to paint some rectangles on itself's canvas, according to some parameters.

How can my component show the rectangles even at designtime ? (like all vcl components in delphi : when you place/resize/etc the component on the form, you _see_ it , not only the contour.
0
Comment
Question by:Catalin80
  • 3
  • 2
  • 2
7 Comments
 
LVL 5

Expert Comment

by:DeerBear
ID: 9693209
Hi,

Why do you use TImage as base class?
Wouldn't a TPaintBox have been better?

Anyway, the only "pictures" you can see at design time are
loaded files, which get displayed in the "Paint" method or the
Update one, I didn't look at the sources.

So, my guess is that you should look in the TImage class where
this happens and act accordingly.

HTH,

Andrew

P.S. As a last chance, you can always override the WM_PAINT method.
If you want a sample just let me know.
0
 

Author Comment

by:Catalin80
ID: 9693568
If it works, give me the sample code. Thx.
0
 
LVL 5

Accepted Solution

by:
DeerBear earned 70 total points
ID: 9693588
Hi,

This example shows a form intercepting WM_PAINT, but the
same concept applies to controls:

Type

  TMyForm = class( TForm )
   private
      procedure HandleWM_PAINT( var Mesg : TMessage );message WM_PAINT;
  end;

procedure TMyForm.HandleWM_PAINT( var Mesg : TMessage );
begin
  Inherited;// REMEMBER TO CALL INHERITED OTHERWISE THE COMPONENT WON'T WORK!!!!!!!!!!
  // Place your code here!
end;

HTH,

Andrew
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 12

Expert Comment

by:andrewjb
ID: 9694687
?? There's no difference. At design time Delphi runs your code, just like at run time. If you component view OK at runtime, it should work at design time, too.

(Obviously non-visual controls don't display, but then you can't see them at runtime either)

0
 

Author Comment

by:Catalin80
ID: 9696972
@DeerBear : That works fine but : when the strech property is false, the object blinks.
0
 
LVL 5

Expert Comment

by:DeerBear
ID: 9699508
Hi,

Use double buffering to avoid flickering.

Draw your image on a temporary bitmap and then transfer it on the
drawing surface.

HTH,

Andrew
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 9700139
... or one of the vcl base classes has a 'DoubleBuffered' property, and it does it all for you.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
proper way to parse url in delphi 2 194
Convert Jpg /PNG To GIF 5 135
Working this component WebCopy with proxy, help 3 84
Firemonkey allowing RTL on android 6 29
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…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

808 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