PDA

View Full Version : سوال: mouse move picturebox



robotic1981
پنج شنبه 05 شهریور 1388, 12:07 عصر
سلام
من میخوام picturebox2 را روی picturebox1 جابجا کنم،من کد زیر را نوشته ام اما این کد picturebox2 را روی کل فرم جابجا میکند،لطفا راهنماییم کنین.

Public Class Form1

Private oControlOffsetPoint As Point
Private Sub PictureBox2_MouseMove_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseMove
Dim sX As Integer = RectangleToClient(New Rectangle(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y, 1, 1)).Left - oControlOffsetPoint.X
Dim sY As Integer = RectangleToClient(New Rectangle(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y, 1, 1)).Top - oControlOffsetPoint.Y
If e.Button = Windows.Forms.MouseButtons.Left Then

sender.Location = New Point(sX, sY)
PictureBox2.Left = sX
PictureBox2.Top = sY
End If

PictureBox2.BringToFront()

End Sub

End Class

Hossis
پنج شنبه 05 شهریور 1388, 14:15 عصر
یک شرط قرار بدید که اگه ماوس از محدوده تصویر 1 خارج شد،‌ این دستور کار نکنه

ACorvinus
پنج شنبه 05 شهریور 1388, 17:13 عصر
سلام
من میخوام picturebox2 را روی picturebox1 جابجا کنم،من کد زیر را نوشته ام اما این کد picturebox2 را روی کل فرم جابجا میکند،لطفا راهنماییم کنین.

Public

Class Form1


Private oControlOffsetPoint As Point
PrivateSub PictureBox2_MouseMove_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseMove
Dim sX AsInteger = RectangleToClient(New Rectangle(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y, 1, 1)).Left - oControlOffsetPoint.X
Dim sY AsInteger = RectangleToClient(New Rectangle(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y, 1, 1)).Top - oControlOffsetPoint.Y
If e.Button = Windows.Forms.MouseButtons.Left Then


sender.Location =

New Point(sX, sY)
PictureBox2.Left = sX
PictureBox2.Top = sY
EndIf


PictureBox2.BringToFront()



EndSub

End

Class




سلام .

خوب با این کد چه مشکلی داری ؟

robotic1981
جمعه 06 شهریور 1388, 00:25 صبح
من مشکلم همین شرطه هست،نمیدونم چه جوری محدوده تصویر1 را مشخص کنم،میشه کد شرطو برام بذارین00
شادو موفق باشین.

Navid Asadi
پنج شنبه 12 شهریور 1388, 11:52 صبح
برنامه زیر اون چیزیه که می خواید