Guest Posted December 26, 2010 Share Posted December 26, 2010 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 = y3End SubPrivate 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 IfEnd 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 More sharing options...
Robin Posted December 26, 2010 Share Posted December 26, 2010 XM and YM are never anything other than 0\. >_> Link to comment Share on other sites More sharing options...
Guest Posted December 26, 2010 Share Posted December 26, 2010 Oh yeah.. Ill edit the tutorial, forgot about that. Link to comment Share on other sites More sharing options...
Guest Posted December 26, 2010 Share Posted December 26, 2010 There we go, updated. Should work now. Link to comment Share on other sites More sharing options...
leopoldobb Posted February 1, 2011 Share Posted February 1, 2011 Doesn't work on EO1.3.0.1, edit plis. Link to comment Share on other sites More sharing options...
Guest Posted February 1, 2011 Share Posted February 1, 2011 @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 More sharing options...
shado360 Posted February 5, 2011 Share Posted February 5, 2011 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 :DThanks,PaïnP.S: To prove to you I'm not a moron:```Private MoveForm As BooleanPrivate MouseX As LongPrivate MouseY As LongPrivate PresentX As LongPrivate PresentY As LongDim XM3 As IntegerDim 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 = y3End SubPrivate 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 IfEnd Sub```*= not in actual code Link to comment Share on other sites More sharing options...
Guest Posted February 5, 2011 Share Posted February 5, 2011 And by invbox you mean picInv? Link to comment Share on other sites More sharing options...
shado360 Posted February 5, 2011 Share Posted February 5, 2011 Yep :P Link to comment Share on other sites More sharing options...
Guest Posted February 5, 2011 Share Posted February 5, 2011 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 More sharing options...
shado360 Posted February 5, 2011 Share Posted February 5, 2011 Kk… I'll try now. Link to comment Share on other sites More sharing options...
shado360 Posted February 5, 2011 Share Posted February 5, 2011 Nope, same thing happened D: Link to comment Share on other sites More sharing options...
shado360 Posted February 5, 2011 Share Posted February 5, 2011 Also tried with the party window 2. Link to comment Share on other sites More sharing options...
Guest Posted February 13, 2011 Share Posted February 13, 2011 Ugh, I cant see whats wrong with it, Im guessing because theres already a proceduer for it and that it'd get in the way of moving spells, etc. Link to comment Share on other sites More sharing options...
evilbunnie Posted February 20, 2011 Share Posted February 20, 2011 Why not just do this?``` If Button = 1 Then ReleaseCapture SendMessage Command1.hwnd, &HA1, 2, 0& End If``` Link to comment Share on other sites More sharing options...
Guest Posted February 20, 2011 Share Posted February 20, 2011 Because I didn't know that was possible at the time ;D? Link to comment Share on other sites More sharing options...
Jacquelinett Posted April 28, 2011 Share Posted April 28, 2011 so how am i going to do this? Link to comment Share on other sites More sharing options...
BoDu Posted April 29, 2011 Share Posted April 29, 2011 @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 More sharing options...
Ruins of Hell Posted April 30, 2011 Share Posted April 30, 2011 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``` Link to comment Share on other sites More sharing options...
BoDu Posted April 30, 2011 Share Posted April 30, 2011 @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 More sharing options...
Kemerd Posted August 14, 2011 Share Posted August 14, 2011 Nice, very helpful. Sorry for reviving I guess. Link to comment Share on other sites More sharing options...
RyokuHasu Posted August 14, 2011 Share Posted August 14, 2011 its ok, i think. A lot of people have been asking about this, i didnt even know a tut existed for it XD Link to comment Share on other sites More sharing options...
Meisterstuck Posted January 17, 2012 Share Posted January 17, 2012 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 BooleanPrivate MouseX As LongPrivate MouseY As LongPrivate PresentX As LongPrivate PresentY As LongDim XM3 As IntegerDim YM3 As IntegerDim XM3 As IntegerDim 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 More sharing options...
Justn Posted January 17, 2012 Share Posted January 17, 2012 Here is what I did with my gui windows to make them moveable and closeablepicInventory- 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 Suberrorhandler: HandleError "picInventory_MouseDown", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd 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 Suberrorhandler: HandleError "picSpells_MouseDown", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd 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 IfEnd 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 IfEnd 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 IfEnd Sub```Add this to the top of frmMain:```Private MoveForm As BooleanPrivate MouseX As LongPrivate MouseY As LongPrivate PresentX As LongPrivate PresentY As LongPrivate Declare Function ReleaseCapture Lib "user32" () As LongPrivate 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 More sharing options...
Meisterstuck Posted January 17, 2012 Share Posted January 17, 2012 Hey thanks a lot man! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now