DX Tutorial #5: Slip Sliding Away
RomanDA's DX Tutorial Series
Sunday, August 13, 2006 by RomanDA | Discussion: DesktopX Tutorials
My goal is to make a set of tutorials for DesktopX. If you have ideas on what you would like to see, please email me at DXTutorials@RomanDA.org
Slip Sliding Away | |
After working on the GalCivII Widget Bar [ LINK ], I was using a lot of code that kept the "sliders" locked to the left side of the screen.
I was challenged to make it so they could "slide" to the top or bottom, or even to the other side of the screen. The actual code was not really that bad, but it was a little convoluted. | |
STEP 1: Setup DRAG | |
First lets setup the sub "ON_DRAG" so that we can pull the x/y & cursor positions. |
'--- Function to handle the DRAG
Sub Object_OnDrag(x, y, newX, newY) '--- Store the Currrent X/Y location of the object BEFORE its moved (or NOT MOVED!) '--- Set this to False so that it will move the item's x/y by default '--- Set the text in the interior object (its only so we can see what is going on, |
STEP 2: Determine the Edges of the Screen | |
It took me a long time to work out the following SIMPLE code. |
If this is your normal screen in my case ill use 1600x1200 just to have something to use for reference. | ||
In this case I'm using the width of the Widget and height of the Widget for this "border".
oTop is the Height of the object
| ||
STEP 3: Setting the Screen Position | ||
Now that we have the height/width areas designated, we need to setup a "test" to see where the cursor is.
In this case I used TOP/BOT/LEFT/RIGHT, you could re-arrange these to change what supersedes things.
|
STEP 4: Dragging things around | ||
We now have our 4 screen "areas"; TOP/LEFT/BOT/RIGHT We can now use a SELECT CASE in order to handle the 4 states and an "ELSE". In order to keep the "LOOK" of this widget, we will ROTATE the object to keep the "rail" aimed at the edge of the screen.
| ||
STEP 5/6/7: Things keep dragging on and on. | ||
We now have our 4 screen "areas"; TOP/LEFT/BOT/RIGHT We can now use a SELECT CASE in order to handle the 4 states and an "ELSE". In order to keep the "LOOK" of this widget, we will ROTATE the object to keep the "rail" aimed at the edge of the screen.
|
This is just PART of what would be needed to be able to move an entire widget around the screen.
You would also want to setup some sort of code to save the position, also you would want to setup something to store the default top/left/right/bot position.
Also, if you have items inside the widget (IE A CLOCK or a CALENDAR or a WEATHER OBJECT) you would have to have code for every object in there to move it around.
Good Luck, and happy DXing,
Enjoy, RomanDA AKA: David A. Roman http://romanda.wincustomize.com http://www.romanda.org DXTutorials@RomanDA.org |
Reply #2 Sunday, August 13, 2006 11:22 PM
Reply #4 Tuesday, August 15, 2006 10:19 AM
Reply #5 Tuesday, August 15, 2006 10:22 AM
Great Work man also check out this article blog |
What was i looking for?
and Thanks!
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!
Reply #1 Sunday, August 13, 2006 8:40 PM
Thanks for sharing all of your hard work RomanDA.
Things like this make this community what it is. You and your widgets are an asset.