Solved

Timage descendent - designtime painting

Posted on 2003-11-05
7
320 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
Comment Utility
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
Comment Utility
If it works, give me the sample code. Thx.
0
 
LVL 5

Accepted Solution

by:
DeerBear earned 70 total points
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 12

Expert Comment

by:andrewjb
Comment Utility
?? 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
Comment Utility
@DeerBear : That works fine but : when the strech property is false, the object blinks.
0
 
LVL 5

Expert Comment

by:DeerBear
Comment Utility
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
Comment Utility
... or one of the vcl base classes has a 'DoubleBuffered' property, and it does it all for you.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This video discusses moving either the default database or any database to a new volume.
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: …

743 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

13 Experts available now in Live!

Get 1:1 Help Now