PPC flicker problem

  • Thread starter Thread starter pengjetty
  • Start date Start date
P

pengjetty

There is a picture(512*512) in the panel(300*200), when I move the
mouse, the picture in the panel should also move following the mouse...


But here comes the problem, when I deploy this program on the HP2790
and drag the picture, the screen is flicker.


I use the Bitblt, but it doesn't work.

Also, I override the OnPaintBackground and have it do nothing, but
nothing different happened.


Does anyone can solve it? Any advice is helpful.Thank you.


Here is my code(the event handle of mousemove and the paint handle of
the panel):


private void panelMap_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if (mouseIsDown == true)
{
this.presentPoint.X = this.lastPoint.X + (e.X -
this.downPoint.X) * 2;
this.presentPoint.Y = this.lastPoint.Y + (e.Y -
this.downPoint.Y) * 2;
this.panelMap.Refresh();
}
}


// Bitblt in C#
private void panelMap_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
Graphics g;


if (this.bufferMap == null)
{
this.bufferMap = new Bitmap(this.panelMap.Width,
this.panelMap.Height);
}


g = Graphics.FromImage(this.bufferMap);


g.DrawImage(this.imgMap, this.presentPoint.X, this.presentPoint.Y);


e.Graphics.DrawImage(this.bufferMap, 0, 0);
}
 
OK, I have slove it out.

Do not use panel to contain a graphics which is change frequently.

The function repaint() is spend much time.

We could handle the mousemove event and draw the graphics ourselves.
And then set pictureBox.Image to it.

Enjoy the WM programming.....

Not many skills, but many experience, good luck.
 
Back
Top