Results 1 to 2 of 2

Thread: Auto-painting to Form from Component

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    Brisbane, Australia
    Posts
    2

    Auto-painting to Form from Component

    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

  2. #2
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    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.
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width