Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[WN/EO] Making Pictures Dragable/Moveable [Updated]


Guest
 Share

Recommended Posts

Just a simple tutorial on making things moveable, in this example I'll be making the shop window moveable but you can make anything you want moveable, lets begin:

~All client side ~

First of all going into the FrmMain(Game) code and search for:

```
Option Explicit
```
Now look for:

```
Private PresentY As Long
```
And add:

```
Dim XM3 As Integer
```
And under that:

```
Dim YM3 As Integer
```
You will need to add a new XM As Integer and YM As Integer for each picture you wish to make moveable.

Now we need a Sub for the MouseDown and a Sub for the Mousemove so before 'Private Sub picShopItems_DblClick()' Add these two Subs:

```
Private Sub picShop_mousedown(Button As Integer, Shift As Integer, x3 As Single, y3 As Single)
        XM3 = x3
        YM3 = y3
End Sub

Private Sub picShop_Mousemove(Button As Integer, Shift As Integer, x3 As Single, y3 As Single)
    If Button = 1 Then
        picShop.left = picShop.left + x3 - XM3
        picShop.top = picShop.top + y3 - YM3
    End If
End Sub
```
You need to add those sort of subs each time you want to make something new moveable. If you weren't using the shop window just change PicShop to whatever you want. Thats pretty much it. Thanks to Aramyth for showing me the basics of this.
Link to comment
Share on other sites

  • 1 month later...
@leopoldobb:

> Doesn't work on EO1.3.0.1, edit plis.

It's an example of how to make something, i.e. a picture moveable, copying the code word for word is idiotic. It works for all versions unless someone has remade VB6.
Link to comment
Share on other sites

Doesn't work with inv box O.O, it moves, then spazzes out and isn't visible, do you know why? If so, I'd really like to know :D

Thanks,
Païn

P.S: To prove to you I'm not a moron:

```
Private MoveForm As Boolean
Private MouseX As Long
Private MouseY As Long
Private PresentX As Long
Private PresentY As Long
Dim XM3 As Integer
Dim YM3 As Integer
```
```
Private Sub Label1*(The thing to move with)*_mousedown(Button As Integer, Shift As Integer, x3 As Single, y3 As Single)
        XM3 = x3
        YM3 = y3
End Sub

Private Sub Label1_Mousemove(Button As Integer, Shift As Integer, x3 As Single, y3 As Single)
    If Button = 1 Then
        picInventory.left = picInventory.left + x3 - XM3
        picInventory.top = picInventory.top + y3 - YM3
    End If
End Sub
```
*= not in actual code
Link to comment
Share on other sites

Ill try it out in the morning, it's probably because of the fact that theres items that it mouseovers and they're dragable, etc, but yeah Ill look into it in the morning. Oh, if you want, try it with the picSpells window, see if it does the same thing.
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
@Captain:

> Why not just do this?
> ```
>     If Button = 1 Then
>         ReleaseCapture
>         SendMessage Command1.hwnd, &HA1, 2, 0&
>     End If
>
> ```

I saw this code on a vb6 forum but if i use it, it gives the error that release capture sub not defined. Any hints ?

```
Private Sub picFoo_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ReleaseCapture
  SendMessage lHwnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&
End Sub
```
Link to comment
Share on other sites

@Soul:

> You have to declare that you are using the ReleaseCapture API. At the top of a module:
> ```
> Declare Function ReleaseCapture Lib "user32" Alias "ReleaseCapture" ( _
> _
> ) As Long
>
> ```

Yah figured that out and now i know why others people can't use this code on an picture box.
If the picture box its not moveable after adding this code simple set her scale mode to pixel, option 3 and it will work perfectly.
Link to comment
Share on other sites

  • 3 months later...
  • 5 months later...
I think I might be a jerk for posting on this thread. I just cant figure out this script. I got it to work perfectly with the shop, but that's because there's a walk through right in front of me. I guess I don't know what this means "_You will need to add a new XM As Integer and YM As Integer for each picture you wish to make moveable_." Do you mean I'm supposed to do..```
Private MoveForm As Boolean
Private MouseX As Long
Private MouseY As Long
Private PresentX As Long
Private PresentY As Long
Dim XM3 As Integer
Dim YM3 As Integer
Dim XM3 As Integer
Dim YM3 As Integer
```With two or how ever many each? Or do I name them something different or put them somewhere else or…? And the ReleaseCapture thing, man, I don't know what's going on with that. Dude I suck :/
Link to comment
Share on other sites

Here is what I did with my gui windows to make them moveable and closeable
picInventory- MouseDown

>! ```
Private Sub picInventory_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
    Dim InvNum As Long
    Const WM_NCLBUTTONDOWN = &HA1
    Const HTCAPTION = 2

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler
>!     InvNum = IsInvItem(x, Y)
>!     If Button = 1 Then
        If InvNum <> 0 Then
            If InTrade > 0 Then Exit Sub
            If InBank Or InShop Then Exit Sub
            DragInvSlotNum = InvNum
        End If
    If Not InvNum <> 0 And Button = 1 Then
            ReleaseCapture
        SendMessage picInventory.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
        End If

    ElseIf Button = 2 Then
        If Not InBank And Not InShop And Not InTrade > 0 Then
            If InvNum <> 0 Then
                If Item(GetPlayerInvItemNum(MyIndex, InvNum)).Type = ITEM_TYPE_CURRENCY Then
                    If GetPlayerInvItemValue(MyIndex, InvNum) > 0 Then
                        CurrencyMenu = 1 ' drop
                        lblCurrency.Caption = "How many do you want to drop?"
                        tmpCurrencyItem = InvNum
                        txtCurrency.text = vbNullString
                        picCurrency.visible = True
                        txtCurrency.SetFocus
                    End If
                Else
                    Call SendDropItem(InvNum, 0)
                End If
            End If
        End If
    End If
>!     SetFocusOnChat
    If x > picInventory.width - 10 Then
        If Y < -picInventory.height + 281 Then
        picInventory.visible = False
        End If
    End If
    ' Error handler
    Exit Sub
errorhandler:
    HandleError "picInventory_MouseDown", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```

picSpells - MouseDown

>! ```
Private Sub picSpells_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
Dim spellnum As Long
Const WM_NCLBUTTONDOWN = &HA1
    Const HTCAPTION = 2

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler
>!     spellnum = IsPlayerSpell(SpellX, SpellY)
    If Button = 1 Then ' left click
        If spellnum <> 0 Then
            DragSpell = spellnum
            Exit Sub
        End If
        If Not spellnum <> 0 And Button = 1 Then
        ReleaseCapture
        SendMessage picSpells.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
        End If
    ElseIf Button = 2 Then ' right click
        If spellnum <> 0 Then
            Dialogue "Forget Spell", "Are you sure you want to forget how to cast " & Trim$(Spell(PlayerSpells(spellnum)).Name) & "?", DIALOGUE_TYPE_FORGET, True, spellnum
            Exit Sub
        End If
    End If
    If x > picSpells.width - 10 Then
        If Y < -picSpells.height + 281 Then
        picSpells.visible = False
        End If
    End If
    ' Error handler
    Exit Sub
errorhandler:
    HandleError "picSpells_MouseDown", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```

picParty - MouseDown

>! ```
Private Sub picParty_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
Const WM_NCLBUTTONDOWN = &HA1
    Const HTCAPTION = 2
    If Button = 1 Then
        ReleaseCapture
        SendMessage picParty.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    End If
    If x > picParty.width - 10 Then
        If Y < -picParty.height + 281 Then
        picParty.visible = False
        End If
    End If
End Sub
```

picOptions - MouseDown

>! ```
Private Sub picOptions_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
Const WM_NCLBUTTONDOWN = &HA1
    Const HTCAPTION = 2
    If Button = 1 Then
        ReleaseCapture
        SendMessage picOptions.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    End If
  If x > picOptions.width - 10 Then
        If Y < -picOptions.height + 281 Then
        picOptions.visible = False
        End If
    End If
End Sub
```

picCharacter - MouseDown

>! ```
Private Sub picCharacter_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
Const WM_NCLBUTTONDOWN = &HA1
    Const HTCAPTION = 2
    If Button = 1 Then
        ReleaseCapture
        SendMessage picCharacter.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    End If
>!     If x > picCharacter.width - 10 Then
        If Y < -picCharacter.height + 281 Then
        picCharacter.visible = False
        End If
    End If
End Sub
```

Add this to the top of frmMain:
```
Private MoveForm As Boolean
Private MouseX As Long
Private MouseY As Long
Private PresentX As Long
Private PresentY As Long

Private Declare Function ReleaseCapture Lib "user32" () As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
```
Just remove this bit of code from them if you don't want to be able to 'x' them out:
```
If x > picCharacter.width - 10 Then
        If Y < -picCharacter.height + 281 Then
        picCharacter.visible = False
        End If
    End If
```or just add an x to the pic like this:

>! ![](http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=72398.0;attach=18426;image)
Hope this might help you out
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...