473,567 Members | 3,176 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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, OnBackgroundEra se, etc. Double
Buffering, AllPaintingInWm Paint, etc. has been set to true.
No success so far.
Now I'm trying to catch Windows Messages like WM_WINDOWPOSCHA NGING by
overriding WndProc.
I have figured out, these messages are being sent while resizing and
moving the picturebox:
WM_WINDOWPOSCHA NGING
WM_NCPAINT
WM_ERASEBKGND
WM_WINDOWPOSCHA NGED
WM_MOVE
WM_NCCALCSIZE
WM_SIZE
WM_GETTEXTLENGT H
WM_GETTEXT
Any idea, where to start?
Thanks a lot,
Bart

Jul 26 '06 #1
3 2351
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.goo glegroups.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, OnBackgroundEra se, etc. Double
Buffering, AllPaintingInWm Paint, etc. has been set to true.
No success so far.
Now I'm trying to catch Windows Messages like WM_WINDOWPOSCHA NGING by
overriding WndProc.
I have figured out, these messages are being sent while resizing and
moving the picturebox:
WM_WINDOWPOSCHA NGING
WM_NCPAINT
WM_ERASEBKGND
WM_WINDOWPOSCHA NGED
WM_MOVE
WM_NCCALCSIZE
WM_SIZE
WM_GETTEXTLENGT H
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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Picturebox1.lef t = 20
PictureBox1.Top = 20
PictureBox1.Bac kColor = Color.White
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
PictureBox1.Sus pendLayout()
Me.SuspendLayou t()
PictureBox1.Lef t = 200
End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click
PictureBox1.Res umeLayout()
Me.ResumeLayout ()
End Sub
End Class

Jul 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
15488
by: Chris | last post by:
Hi, I am trying to set the position of a picture inside a picturebox with the folowing code: pctOutput.Picture = LoadPicture(App.Path & "\picture.bmp", , , , ) I didn't know what to fill in at and so the result was:
1
1874
by: Charles A. Lackman | last post by:
Hello, I am trying to rotate a picturebox control. I have done some experimenting with rotating the image inside the picturebox, but I am trying to get the affect of grabbing the corner of the picturebox and moving the mouse to change the angle. I am sure I can implement the code to grab the corners as I have already implemented code to...
0
2090
by: Paul L | last post by:
I've created a picturebox inside a panel control with autoscroll enabled. The picturebox is twice the size of the panel so scrollbars are always shown. What I would like to do, is when the user presses the left mouse button and moves the mouse, the mouse cursor stays frozen on screen, but the image within the picturebox is panned around (the...
1
1785
by: Crirus | last post by:
Hi! I have a seamless image drawn onto a PictureBox. I wrote a mouseMove handle that allow me to drag the image around in that pictureBox. I whould like to do this When the border of the image enter the picturebox area, to draw on that direction the same picturebox with a height or width offset, and that way, no metter how farr I drag the...
8
10455
by: Yogiman | last post by:
Hi Can anybody tell me how would I attach scrollbars to a picturebox ? The example given in MSDN is pretty good.But I have a different problem. I have to do other stuff with the picturebox as well like moving it, rotating it. Therefore, a solution with two pictureboxes (like the one given in MSDN) is of no use to me.Thanks in advance.
10
23468
by: Liz | last post by:
All: Can anyone tell me why my animated GIF does not show up as animated when put into a pictureBox?? Thanks. Liz
3
3930
by: Tyson Ackland | last post by:
Can someone tell me how you go about handling events where your window might be obscured and then when you bring it to the foreground, you want your picturebox control to be repainted instead of showing large, blocked out areas created by overlapping windows. I have seen numerous references to onpaint etc but I haven't found an example to...
1
1415
by: The Confessor | last post by:
(ellipses in place of code sections which do not deviate from defaults) Private Sub Form_Main_Load(...) Handles MyBase.Load For A = 0 To 16 For B = 0 To 14 PictureBox_MapEditor_Map.CreateGraphics.DrawImage (System.Drawing.Image.FromFile("C:\The RPG Project\Test 2.bmp"), A * 40, B * 40) Next Next
6
7491
by: bradyounie | last post by:
I'm writing a program that displays a user-supplied Bitmap and then writes text fields to it. These "text fields" are things that the user can move around on the image, but to render them efficiently, I draw the text directly to the image. It's faster that way. The problem is that right now I have to redraw the original (unwritten-to) bitmap...
0
7686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8115
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6272
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5488
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3648
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1205
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
930
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.