Mirage Engine
Proper Drag-able Boxes - Printable Version

+- Mirage Engine (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: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49)
+---- Thread: Proper Drag-able Boxes (/showthread.php?tid=180)



Proper Drag-able Boxes - Tutorial Bot - 09-07-2006

Author: pingu
Difficulty: 1/5

:: CLIENT SIDE ::
In modDatabase, after "Option Explicit" add:
Code:
Public SOffsetX As Integer
Public SOffsetY As Integer

At the bottom of modDatabase, add:
Code:
Sub MovePicture(PB As PictureBox, Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 1 Then
        PB.Left = PB.Left + x - SOffsetX
        PB.top = PB.top + y - SOffsetY
    End If
End Sub

Okay, thats all for that portion. Now, let's say we want to make the map editor drag-able. First, add a private sub for the mapeditor pic with mousedown and mousemove:
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
You can do the same thing with other things, too. =) Just follow with the above code.