| View previous topic :: View next topic |
| Author |
Message |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Mon Jul 28, 2003 1:45 pm Post subject: Dragging app like a title bar? |
|
|
If I have say an app with a custom made title bar, how can I make it drag able?
I have made it so when you click it attaches to your mouse but you have to click again to release it. How can I make it so it just drags like a windows dialog?
the code i have is;
| Code: |
:Main
DIALOG CREATE,"Test",-1,0,200,100,NOTITLE,CLICK
DIALOG ADD,BUTTON,Exit,2,179,20,20,"X"
DIALOG SHOW
:EVLOOP
WAIT EVENT
goto @event()
:CLICK
REPEAT
%x = @mousepos(X)
%y = @mousepos(Y)
WINDOW POSITION,"Test",%y,%x
UNTIL @event()
goto EVLOOP
:ExitBUTTON
EXIT
|
|
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1566
|
Posted: Mon Jul 28, 2003 2:12 pm Post subject: |
|
|
| Code: |
:Main
DIALOG CREATE,"Test",-1,0,200,100,NOTITLE,CLICK
DIALOG ADD,BUTTON,Exit,2,179,20,20,"X"
DIALOG SHOW
:EVLOOP
WAIT EVENT
goto @event()
:CLICK
REPEAT
%x = @mousepos(X)
%y = @mousepos(Y)
WINDOW POSITION,"Test",%y,%x
UNTIL @event() @null(@mousedown(L))
goto EVLOOP
:ExitBUTTON
EXIT
|
All I added was the @null(@mousedown(L)) portion. |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Mon Jul 28, 2003 6:14 pm Post subject: |
|
|
I added some code as well, so the mouse stays on the same position relative to the dialog.
| Code: | :Main
DIALOG CREATE,"Test",-1,0,200,100,NOTITLE,CLICK
DIALOG ADD,BUTTON,Exit,2,179,20,20,"X"
DIALOG SHOW
:EVLOOP
WAIT EVENT
goto @event()
:CLICK
%%beginposx = @diff(@mousepos(x),@dlgpos(,L))
%%beginposy = @diff(@mousepos(y),@dlgpos(,T))
REPEAT
%x = @diff(@mousepos(X),%%beginposx)
%y = @diff(@mousepos(Y),%%beginposy)
WINDOW POSITION,"Test",%y,%x
UNTIL @event() @null(@mousedown(L))
goto EVLOOP
:ExitBUTTON
EXIT |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Mon Jul 28, 2003 8:12 pm Post subject: |
|
|
There's also a couple of examples in the source code section of the
main site.
-Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Mon Jul 28, 2003 11:16 pm Post subject: |
|
|
| Thats what I needed thank you. |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Tue Jul 29, 2003 8:34 am Post subject: |
|
|
Here is a slightly different one especially for VDS 4 with SNAP style.
It snaps to the screen edges.
Works with paint style enabled without sticking.
| Code: |
DIALOG CREATE,DRAW EDGE DEMO,-1,0,288,175,CLASS MYWIN,PAINT,NOTITLE,Click,
DIALOG ADD,STYLE,STYLE1,Arial,10,BC,RED,WHITE
DIALOG ADD,TEXT,TEXT1,2,268,17,17,x,,STYLE1,CLICK
DIALOG ADD,TEXT,TEXT2,66,28,,,You can move this window by clicking anywhere
DIALOG ADD,TEXT,TEXT3,84,62,,,It snaps to the edges of your screen
DIALOG ADD,TEXT,TEXT4,102,74,168,14,if you move close to the edges
DIALOG SHOW
:EVLOOP
WAIT EVENT,
GOTO @EVENT()
:PAINT
GOTO EVLOOP
:CLICK
%%startposx = @diff(@mousepos(x),@dlgpos(,L))
%%startposy = @diff(@mousepos(y),@dlgpos(,T))
REPEAT
%x = @diff(@mousepos(X),%%startposx)
%y = @diff(@mousepos(Y),%%startposy)
WINDOW POSITION,#MYWIN,%y,%x
UNTIL @event() @null(@mousedown(L))
REM "If you dont need paint style for your dialog element
REM remove all the lines between REM ########## "
REM ################################################
%%POS = @DIFF(@WINPOS(#Shell_TrayWnd,T),@DLGPOS(,H))
IF @GREATER(@SUM(@WINPOS(#MYWIN,T),@WINPOS(#MYWIN,H),40),@WINPOS(#Shell_TrayWnd,T))
%%POS = @DIFF(@WINPOS(#Shell_TrayWnd,T),@SUM(@WINPOS(#MYWIN,H),3))
WINDOW POSITION,#MYWIN,%%POS
END
%%POS = @DIFF(@SYSINFO(SCREENWIDTH),@DLGPOS(,W))
IF @GREATER(@SUM(@WINPOS(#MYWIN,L),@WINPOS(#MYWIN,W),40),@SYSINFO(SCREENWIDTH))
%%POS = @DIFF(@SYSINFO(SCREENWIDTH),@SUM(@WINPOS(#MYWIN,W),4))
WINDOW POSITION,#MYWIN,,%%POS
END
REM ################################################
REM IF you don't want snap style remove all the lines
REM between REM ********** and replace all 40's above by 0.
REM **********************************************
IF @GREATER(40,@WINPOS(#MYWIN,L))
WINDOW POSITION,#MYWIN,,4
END
IF @GREATER(40,@WINPOS(#MYWIN,T))
WINDOW POSITION,#MYWIN,4
END
REM **********************************************
goto EVLOOP
:TEXT1CLICK
:CLOSE
Exit
|
___________________________________________________________________ _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension
Last edited by CodeScript on Wed Jul 30, 2003 9:21 am; edited 1 time in total |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Jul 29, 2003 12:38 pm Post subject: |
|
|
Nice, but once it snaps to the edge of the screen, it's stuck there. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Jul 29, 2003 12:47 pm Post subject: |
|
|
Nope, gets stuck everywhere.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Tue Jul 29, 2003 5:03 pm Post subject: |
|
|
I think it depends on graphics properties. You can increase the gap between the taskbar and the window in snap style(bottom) adding 1 or 2 and also the screen border and the window in top snap. Like from 2 to 3 or 4.
I will post the modified one.
Edit:
Updated the Script.
Skit and FF
Please let me know if it sticks now. _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
|
|
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 vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|