Drawing image in for Paint

alemargo

Member
Joined
Jan 2, 2004
Messages
16
The form flickers upon loading.
I do the following to prevent it, but that does not help at all.

Private Sub frmNmeaPlayer_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
e.Graphics.DrawImage(background, New Point(0, 0))
End Sub

I do set
SetStyle(ControlStyles.DoubleBuffer Or ControlStyles.UserPaint, True) in form Load event.


If anyone has any suggestions, please advise.
 
Originally posted by alemargo
I do set
SetStyle(ControlStyles.DoubleBuffer Or ControlStyles.UserPaint, True) in form Load event.

you missed one important part in that Statement:

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

if you dont set this style the system first redraws the background of the Form (the short gray flickering) and afterwards draws your custom drawing....

Andreas
 
Re: Re: Drawing image in for Paint

Originally posted by Hamburger1984
you missed one important part in that Statement:

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

if you dont set this style the system first redraws the background of the Form (the short gray flickering) and afterwards draws your custom drawing....

Andreas


Thanks for responding. The ControlStyles.AllPaintingInWmPaint causes some inconvenience. I have a bitmap image that I draw on the form as a background. I have transparency key set to make everything around that image transparent. When I use ControlStyles.AllPaintingInWmPaint, transparency does not work for some reason. I am using 32-bit color quality.
 
I dont know if it will help you,
but you can try overriding the WM_PAINT message:

C#:
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case WM_PAINT:
//base.WndProc(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}

LDV
 
Back
Top