469,272 Members | 1,416 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

Suppressing redraw of PictureBox after moving?

Hello Newsgroup,
I try to resize and move a picturebox. However, after each operation
the picture box is being redrawn. This causes flickering. Is it
possible to suppress the first redraw and draw both operations at once
after they have been completed?
I have tried overriding OnPaint, OnBackgroundErase, etc. Double
Buffering, AllPaintingInWmPaint, etc. has been set to true.
No success so far.
Now I'm trying to catch Windows Messages like WM_WINDOWPOSCHANGING by
overriding WndProc.
I have figured out, these messages are being sent while resizing and
moving the picturebox:
WM_WINDOWPOSCHANGING
WM_NCPAINT
WM_ERASEBKGND
WM_WINDOWPOSCHANGED
WM_MOVE
WM_NCCALCSIZE
WM_SIZE
WM_GETTEXTLENGTH
WM_GETTEXT
Any idea, where to start?
Thanks a lot,
Bart

Jul 26 '06 #1
3 2136
Hi,

Take a look at suspendlayout and resumelayout

http://msdn.microsoft.com/library/de...ayouttopic.asp

http://msdn.microsoft.com/library/de...ayouttopic.asp

Ken
-----------------
<b7******@yahoo.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hello Newsgroup,
I try to resize and move a picturebox. However, after each operation
the picture box is being redrawn. This causes flickering. Is it
possible to suppress the first redraw and draw both operations at once
after they have been completed?
I have tried overriding OnPaint, OnBackgroundErase, etc. Double
Buffering, AllPaintingInWmPaint, etc. has been set to true.
No success so far.
Now I'm trying to catch Windows Messages like WM_WINDOWPOSCHANGING by
overriding WndProc.
I have figured out, these messages are being sent while resizing and
moving the picturebox:
WM_WINDOWPOSCHANGING
WM_NCPAINT
WM_ERASEBKGND
WM_WINDOWPOSCHANGED
WM_MOVE
WM_NCCALCSIZE
WM_SIZE
WM_GETTEXTLENGTH
WM_GETTEXT
Any idea, where to start?
Thanks a lot,
Bart

Jul 27 '06 #2
Hi Ken,
thanks a lot!
I tried once more suspend/resume layout. I tried to suspend the layout
of my form, my UserControl and the PictureBox on the UserControl.
Unfortunately, I can still see both actions: Redrawing after moving the
PictureBox and again after Resizing it.
Maybe I should explain shortly, which effect I'd like to achieve:
I'd like to be able to point with the mouse cursor on the picture and
move the scroll wheel. Than there should be a zooming effect around the
center of the zoom, which should be the mouse pointer. These effects
work fine now. However, I still have that flickering effect and I'm
desperate to get rid of it. One can clearly see, that this flickering
comes from the moving and resizing effect. I have tried to to use
DrawImage instead but encountered a lot of different problems. So I
decided to stick with the idea of moving and resizing the PictureBox on
my UserControl.
Thanks a lot for any hints.
Sincerely,
Bart

Ken Tucker [MVP] wrote:
Hi,

Take a look at suspendlayout and resumelayout

http://msdn.microsoft.com/library/de...ayouttopic.asp

http://msdn.microsoft.com/library/de...ayouttopic.asp

Ken
Jul 27 '06 #3
Hello Ken & the Newsgroups,
I tried suspend layout in a simple context.
Please have a look below.
Suspend Layout does not seem to have any effect.
When Button1 is clicked, the picture box moves and this movement is
being redrawn despite the fact that the layout has been suspended.
Resuming layout by clicking Button2 does not have any effect. I have
expected, that the PictureBox movement will be drawn after clicking
Button2.
Any ideas or help?
Thank you,
Bart
Needed: Form, PictureBox1, Button1, Button2.
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Picturebox1.left = 20
PictureBox1.Top = 20
PictureBox1.BackColor = Color.White
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
PictureBox1.SuspendLayout()
Me.SuspendLayout()
PictureBox1.Left = 200
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
PictureBox1.ResumeLayout()
Me.ResumeLayout()
End Sub
End Class

Jul 27 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Charles A. Lackman | last post: by
reply views Thread by Paul L | last post: by
8 posts views Thread by Yogiman | last post: by
3 posts views Thread by Tyson Ackland | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.