09-07-2009, 09:04 PM
Difficulty: 1/5
Sides: Client Only
Tested on: MS4
Works for: MS4
Credits: Me
Tutorial Type: Copy and Paste
Description of Variables (You can copy these comments into your program for other programmers to read):
Put the following in modDatabase under Option Explicit:
Put the following at the very bottom of modDatabase:
Put The Following Code In the Form's Code Editor That you want to be able to move
Sides: Client Only
Tested on: MS4
Works for: MS4
Credits: Me

Tutorial Type: Copy and Paste
Description of Variables (You can copy these comments into your program for other programmers to read):
Code:
' OHOX/OHOY are the variables that define the Picture Hold Offset X/Y
' MouseDown is the boolean that determines whether the Mouse is still pressed or not
' CFrm is the Current Form that the player is viewing
' DX/DY are the variables that define the Destination X/Y
' SPIGSS is the System Paramaters Info Action Variables used to get the Screen Size excluding the taskbar
Put the following in modDatabase under Option Explicit:
Code:
Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
Public Const SPIGSS = 48
Private Type CScreenRec
Top As Long
Left As Long
Right As Long
Bottom As Long
End Type
Public CScreen As CScreenRec
Public DX, DY As Long
Public OHOX, OHOY As Long
Public MouseDown As Boolean
Put the following at the very bottom of modDatabase:
Code:
Public Sub FormMove(CFrm As Form, Button As Integer, Shift As Integer, X As Long, Y As Long)
If Button = 1 And MouseDown = True Then
GetScreenSize
DX = CFrm.Left + X - OHOX
DY = CFrm.Top + Y - OHOY
If DX < CScreen.Left Then DX = CScreen.Left
If DY < CScreen.Top Then DY = CScreen.Top
If DX + CFrm.Width > CScreen.Right Then DX = CScreen.Right - CFrm.Width
If DY + CFrm.Height > CScreen.Bottom Then DY = CScreen.Bottom - CFrm.Height
CFrm.Left = DX
CFrm.Top = DY
End If
End Sub
Public Sub GetScreenSize()
Dim ScreenRect As RECT
SystemParametersInfo SPIGSS, 0, ScreenRect, 0
CScreen.Bottom = 15 * ScreenRect.Bottom
CScreen.Right = 15 * ScreenRect.Right
CScreen.Top = 15 * ScreenRect.Top
CScreen.Left = 15 * ScreenRect.Left
End Sub
Put The Following Code In the Form's Code Editor That you want to be able to move
Code:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
MouseDown = True
OHOX = CLng(X)
OHOY = CLng(Y)
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MouseDown = True Then Call FormMove(Me, Button, Shift, CLng(X), CLng(Y))
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MouseDown = False
End Sub