Mirage Source
[Feature] Moveable PictureBoxes - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51)
+----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44)
+------ Forum: Tutorials (https://mirage-engine.uk/forums/forumdisplay.php?fid=13)
+------ Thread: [Feature] Moveable PictureBoxes (/showthread.php?tid=2153)



[Feature] Moveable PictureBoxes - Mattyw - 20-09-2008

Difficulty: 1/5 - Very easy to add/use.
Functionality: Made for MS4.


My first tutorial, not a bad one at that either, thanks to DFA.

-- CLIENT --

First, open up frmMirage & for the PictureBox you want to be Moveable, edit the following, then add it in:

Code:
Private Sub picMapEditor_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SOffsetX = X
    SOffsetY = Y
End Sub

Private Sub picMapEditor_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MovePicture(frmMirage.picMapEditor, Button, Shift, X, Y)
End Sub

Then move onto modDatabase, & add the following below "Option Explicit":

Code:
Public SOffsetX As Integer
Public SOffsetY As Integer

Sub MovePicture(PB As PictureBox, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim GlobalX As Integer
Dim GlobalY As Integer

GlobalX = PB.Left
GlobalY = PB.Top

If Button = 1 Then
    PB.Left = GlobalX + X - SOffsetX
    PB.Top = GlobalY + Y - SOffsetY
End If
End Sub

Enjoy! Post what'cha think.

P.S. For every Moveable PictureBox you want, you have to copy/paste & edit the frmMirage stuff.


Re: [Feature] Moveable PictureBoxes - Blodyavenger - 22-12-2008

Actualy, that all wasn't enough for me, I had to add:

Code:
Private Sub picMapEditor_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    Call MovePicture(frmMirage.picMapEditor, Button, Shift, x, y)
End Sub

Aye, if I wanted smooth moving (without auto-move cursor to left upper corner of image and changing position of image instantly when click). So, all you have to add is calling "MovePicture" on MouseMove in picture box.