02-03-2008, 03:01 PM
Well, I am adding a custom top bar to my game (the bar at the top of everything with a minimize, maximize, and exit button). I am coding it myself and made this code to drag it. It occurs when you click on the label that is over the dragable part of the bar.
x2 and y2 are integers to store the original location of the cursor (when the user clicks on the bar).
Is there any way to optimize this?
x2 and y2 are integers to store the original location of the cursor (when the user clicks on the bar).
Code:
Private Sub lblDragBar_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
x2 = X
y2 = Y
End Sub
Private Sub lblDragBar_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case Button
Case 1
If x2 > X Then frmMirage.Left = frmMirage.Left + (X - x2)
If x2 < X Then frmMirage.Left = frmMirage.Left - (x2 - X)
If y2 > Y Then frmMirage.top = frmMirage.top + (Y - y2)
If y2 < Y Then frmMirage.top = frmMirage.top - (y2 - Y)
End Select
End Sub
Is there any way to optimize this?