Hi,
I have a picture in a picture box , and the picture is lager then the picturebox , I want to use the stylus to drag and move the picture in the picturebox , how to do this ?
does somebody have a code for this? it would be very helpfull.
thanks
Printable View
Hi,
I have a picture in a picture box , and the picture is lager then the picturebox , I want to use the stylus to drag and move the picture in the picturebox , how to do this ?
does somebody have a code for this? it would be very helpfull.
thanks
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
bDragging = True
sx = e.X
sy = e.Y
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
bDragging = False
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If bDragging Then
With PictureBox1
nx = .Left - sx + e.X
ny = .Top - sy + e.Y
.Location = New System.Drawing.Point(nx, ny)
End With
End If
End Sub
seems to be good , but what should I do with this errors I got.
what to declare these variables?
http://swf.co.il/filestore/28/fY-kyR...19-24-05.jpg._
Thanks.
declare sx, sy and bdragging
private sx as double
private sy as double
private ny as double
private nx as double
private bDragging as boolean
hi Petevick,
it doesn't allow to declare the variables as private, so I declared them as dim,
is it right ? what the diference between private and dim?
and it gives error like you can see with the printscreen, what should I do?
http://swf.co.il/filestore/61/HgEH0TfU8r.1.jpg._
thanks,
Hi,
you need to declare them in the form, or you will lose the values when you exit the subroutines!
Where did you get the Picturebox2 = True and False from - certainly not the code I posted.
I posted bDragging = true and bDragging = false to signify the 'mouse' is down, so you drag on a mouse move
hi Petevick,
sory for bothring you.
I have entered your code exactly as is , but as you can see the private doesn't work. so I had to declare every variable few time with the events you have entered.
and change somethings,
here is the exact code you've entered but with dim ,because it gives a lot of errors,as you can see with the example:
http://swf.co.il/filestore/2a/Jxl_eU...14-44-04.jpg._
and this is the form with picture on it ,and its propertise:
http://www.dix.co.il/uploads/image/107/40.jpg
I have try to put the declaration with form load , and the upper part of the code before the sub begins , the declaration part , but also it doesn't work.
the PRIVATE declaration should be in a modul ,class, and so, but it doesn't work with the form , which event should it be in ?
thx.
HI,
the code hasn't made it - but you HAVE TO declare the variables as private to the form or the routines simply won't work.
Private at form level means the whole form can use the variables, and they retain their value. If you just declare them in the sub, then as soon as you leave the sub, the value is lost.
You must be doing something wrong, or trying to declare them in the wrong place.
They should go like:-
Public Class frmMain
Private pubDate As Date
Private title As String
Private description As String
Private hDescription As String
Hi,
Now it looks like this:
http://www.dix.co.il/uploads/image/107/48.jpg
did I was wrong with the location of the declaration?
as you can see I got a lot of errors ,what to do?
do you have an example of a code that you can give me that I'll look how it is with a comlete source code.
looking forward to your answer.
Why is this code in a class called help, and not in the form class????
That is probably why you are getting errors as picturebox2 is presumably part of frmMain and not the help class
In your form, click on picturebox, and then click on events and generate the mouseup, mousedown and mousemove events
Did you meant something like this?
http://www.dix.co.il/uploads/image/107/72.jpg
It works very well to move a fixed picture, I mean I can move the picture with the stylus but freely ,it is very nice for something else I'm doing.
but what I meant is that I have a picture as you can see with the printscreen
http://www.dix.co.il/uploads/image/107/61.jpg
and it is in a picturebox ,and it is in normal size so I can't see the rest of the picture, and with the stylus I want to move the picture in the picturebox so I can see the rest of the picture, hope I understand myself.
Ah - Drop the picture box into a panel and make the picturebox larger than the panel that should do it.
Similar to the code at http://www.codeproject.com/KB/vb/PanExample.aspx
Very Good ! THANK YOU VERY MUCH! IT IS VERY HELPFULL.
THANK YOU ALSO FOR YOUR PATIENCE.
:thumb::)