Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Smooth Graphics

Status
Not open for further replies.

seanbo

Programmer
Jun 6, 2003
407
GB
i have a rather complicated paint routine that takes the best part of a second to complete. the user is able to see the screen fill (a triangle here, a curve there), unless they blink; which looks terribly messy.

i didn't think the information would be passed to the screen until the method was complete, but it clearly is. is there a way to prevent this though? can i make the screen only update after averything is there

note/ i am painting an object that extends 'panel'. the paint event triggers a method that calls a number of terribly complicated and slow, static methods.
 
does this.SuspendLayout() ... make changes ...this.ResumeLayout() work ?

Steve
 
Actually I think this is more siutable
(available in MSDN by searching for DoubleBuffer enumeratin property)

Controls use this enumeration in various properties and methods to specify functionality. A control can enable a style by calling the SetStyle method and passing in the appropriate ControlStyles bit (or bits) and the Boolean value to set the bit(s) to. For example, the following line of Visual Basic code would enable double-buffering.

myControl.SetStyle(UserPaint Or AllPaintingInWmPaint Or DoubleBuffer, True)

If the AllPaintingInWmPaint bit is set to true, the window message WM_ERASEBKGND is ignored, and both OnPaintBackground and OnPaint methods are called directly from the window message WM_PAINT. This generally reduces flicker unless other controls send the window message WM_ERASEBKGND to the control. You might send the window message WM_ERASEBKGRND to achieve a pseudo-transparent effect similar to SupportsTransparentBackColor; for example, a ToolBar with flat appearance does this.

To fully enable double-buffering, you must set the UserPaint, AllPaintingInWmPaint, and DoubleBuffer bits to true.

If the SupportsTransparentBackColor bit is set to true, and the BackColor is set to a color whose alpha component is less than 255, OnPaintBackground will simulate transparency by asking its parent control to paint the background. This is not true transparency.

Note If there is another control between the control and its parent, the current control will not show the control in the middle.
When the UserMouse bit is set to true, the following methods are still called: Control.OnMouseDown, Control.OnMouseUp, Control.OnMouseEnter, Control.OnMouseMove, Control.OnMouseHover, Control.OnMouseLeave, and Control.OnMouseWheel.

When the control is clicked, if the StandardClick bit is set to true the Control.OnClick method is called and it raises the Control.Click event. When the control is double-clicked, and both the StandardClick and StandardDoubleClick bits are set to true, the click is passed on to the DoubleClick event. Then the Control.OnDoubleClick method is called and it raises the Control.DoubleClick event. However, the control can call OnClick or OnDoubleClick directly regardless of the StandardClick and StandardDoubleClick bit values. For more information on control click and double click behaviors, see the Control.Click and Control.DoubleClick topics.

Notes to Inheritors: Inheriting from a standard Windows Forms control and changing the StandardClick or StandardDoubleClick bit values to true can cause unexpected behavior or can have no effect at all if the control does not support the Click or DoubleClick events.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top