PDA

Click to See Complete Forum and Search --> : Auto-painting to Form from Component


Alan Liddle
Sep 5th, 2002, 06:40 PM
Hi All,

I have created a BorderClass which prints a document border to a panel or form. The only way I can get it to print is to call a method within the class from the OnPaint method of the panel or form, and this only works when you run the program. What I would like is the border to automatically print as soon as it is added to the panel or form. Also I would like it to appear at design time. I know this is possible, because the MainMenu class is a component and it draws itself automatically to a form, without the need to enter any code in the forms OnPaint method. I would also want the border to automatically set the Form or Panel's client area to be within the bounds of the border (Again the MainMenu class does this as well).

Any Clues?

Thanks in advance


Alan Liddle
:confused:

BrianHawley
Sep 17th, 2002, 06:39 AM
No time to go into this in depth, but a few possible hints;

1) You can call 'invalidate' to force a paint event.

2) If you want to paint on a control, use the control's paint event, NOT the paint event of the form it is on. Control might need a repaint when the form does not.

3) Look at the sample user control. Most of what you need is there.

4) If you get it all right, the control should repaint, even in design mode.