GDI+ move scroll zoom

B

Boni

Dear all,
I need a picturebox on which I can with GDI+ draw rectangles. The scroll and
zoom should be supported. Do I have to manually resize rectangles,when zoom
button clicked and change position when scroll done and redraw with new
coordinates? Is there some standard procedure for that? Any link or advice
is greatly appreciated.
Thanks,
Boni
 
S

Some Guy

Boni, this should get you started.

Dim zoom As Integer = 1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
zoom += 1
PictureBox1.Invalidate()
End Sub



Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim rect As New Rectangle(10, 10, 50 * zoom, 50 * zoom)
e.Graphics.DrawRectangle(Pens.Blue, rect)
End Sub
 
C

Cor Ligthert [MVP]

Boni,

If the size of the image in width and height is not important and it is only
for showing you can use the picturebox.

If you want to keep things as they are, have than a look at the image sample
in VB 101 samples
http://msdn.microsoft.com/vbasic/downloads/2005/code/101samples/

I did not look in it however looking at the date is this the standard set
not especially for 2005

I hope this helps,

Cor
 
B

Boni

Ah, it is exactely what I would like to avoid.
With this approach I have to calculate zoom and scroll for each object
explicitely.
I thougth, that using transform matrix and working in absolute coordinates
would be better approach.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top