Solved

Timage descendent - designtime painting

Posted on 2003-11-05
7
322 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
indy tidtcpclient threading issue 8 63
Thread safe  opinion 7 126
error 1.1 400 Bad request idhttp delphi 18 54
CheckListBox usage 3 50
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

912 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

22 Experts available now in Live!

Get 1:1 Help Now