Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Timage descendent - designtime painting

Posted on 2003-11-05
7
Medium Priority
?
331 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 210 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
Technology Partners: 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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 this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

705 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