Solved

Timage descendent - designtime painting

Posted on 2003-11-05
7
327 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
[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
  • 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
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 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

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 227
LAN or WAN ? 11 121
Error E2158 compiling with Delphi XE10 Seattle 2 142
When i run adoquery my application freezes 26 214
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

752 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