Mirage Source

Free ORPG making software.
It is currently Thu Mar 28, 2024 2:05 pm

All times are UTC


Forum rules


Make sure your tutorials are kept up to date with the latest MS4 releases.



Post new topic Reply to topic  [ 1668 posts ]  Go to page 1, 2, 3, 4, 5 ... 67  Next
Author Message
 Post subject: [Feature] Moveable Forms
PostPosted: Thu Jul 09, 2009 9:04 pm 
Offline
Knowledgeable
User avatar

Joined: Sun Dec 14, 2008 4:28 am
Posts: 106
Location: Roanoke, VA, US
Difficulty: 1/5
Sides: Client Only
Tested on: MS4
Works for: MS4
Credits: Me :D
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

_________________
:d


Top
 Profile  
 
PostPosted: Sat Sep 05, 2009 5:48 pm 
Offline
Knowledgeable
User avatar

Joined: Sun Dec 14, 2008 4:28 am
Posts: 106
Location: Roanoke, VA, US
Just wondering, but why on my Transparent and Moveable Forms, and on my Moveable Image/Pic Boxes, do I have a very poor rating. I made these copy and paste, only because I don't think many people understand all the code, and I have everything explicitly stated, and I see no fault with the tutorial. So, if you are reading this, and you gave one of them a poor rating, could you please give me insight on why you did that please, so I can improve the tutorial if it needs it?

_________________
:d


Top
 Profile  
 
PostPosted: Wed Dec 01, 2021 9:12 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоsemiasphalticflux.ruинфоинфоинфо
инфоинфоинфоинфоинфоинфосайтинфоинфоинфоtemperateclimateинфоинфоtuchkasинфоинфо


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:24 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Econ


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:25 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
109.2


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:27 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Bett


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:28 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Bett


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:29 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
musi


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:30 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Sama


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:31 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Nora


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:32 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Ross


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:33 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Gabr


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:34 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Fran


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:35 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Marv


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:37 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Fisk


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:38 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Snoo


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:39 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Rond


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:40 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
hann


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:41 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Spee


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:42 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Chem


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:43 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Gran


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:44 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Plus


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:46 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Danz


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:47 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
XVII


Top
 Profile  
 
PostPosted: Thu Jan 06, 2022 1:48 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
MySQ


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1668 posts ]  Go to page 1, 2, 3, 4, 5 ... 67  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group