Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-18-2005, 09:05 PM
Junior Member
 
Join Date: Jan 2005
Posts: 15
Default snap to edges

??? How could I make my application snap to screen edges (like winamp)?
Reply With Quote
  #2 (permalink)  
Old 01-19-2005, 04:27 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:snap to edges

Code:
/* snap to the border if within the distance */
var distance = 50;
var snapInterval, direct;
/* if the app is snaping to the screen border*/
var moving = false;

/* move the window to the screen border */
function snapTo(direct)
{
var wnd = getMainWnd();
var reach = false;/* reach the border of the screen? */

switch (direct)
{
case 0: /* left */
if (wnd.left > 0) 
wnd.move(wnd.left - 1, wnd.top, wnd.left + wnd.width - 1,
 wnd.top + wnd.height);
if (wnd.left == 0) reach = true;
break;

case 1:/* top */
if (wnd.top > 0) 
wnd.move(wnd.left, wnd.top - 1, wnd.left + wnd.width,
 wnd.top + wnd.height - 1);
if (wnd.top == 0) reach = true;
break;

case 2: /* right */
if (wnd.left + wnd.width < SysInfo.workareaRight) 
wnd.move(wnd.left + 1, wnd.top, wnd.left + wnd.width + 1,
 wnd.top + wnd.height);
if (wnd.left + wnd.width == SysInfo.workareaRight) reach = true;
break;

case 3: /* bottom */
if (wnd.top + wnd.height < SysInfo.workareaBottom) 
wnd.move(wnd.left, wnd.top + 1, wnd.left + wnd.width,
 wnd.top + wnd.height + 1);
if (wnd.top + wnd.height == SysInfo.workareaBottom) reach = true;
break;
}

if (reach)
{
/* reach the border, stop moving */
Application.clearInterval(snapInterval);
moving = false;
}
}

/* 
handle the WM_ONEXITSIZEMOVE to see if 
we need to snap the app to the screen border  
*/
getMainWnd().onExitSizeMove = function ()
{
/* Is the app snaping to screen border? */
if (moving) return;

direct = -1;

// left
if (this.left > 0 && this.left <= distance) direct = 0;
// top
else if (this.top > 0 && this.top <= distance) direct = 1;
//right
else if (this.left < SysInfo.workareaRight - this.width && 
this.left >= SysInfo.workareaRight - this.width - distance)
direct = 2;
//bottom
else if (this.top < SysInfo.workareaBottom - this.height &&
this.top >= SysInfo.workareaBottom - this.height - distance)
direct = 3;

if (direct >= 0)
{
// Move the window
snapInterval = Application.setInterval(snapTo, 10, direct);
moving = true;
}
}
Reply With Quote
  #3 (permalink)  
Old 01-19-2005, 02:04 PM
Junior Member
 
Join Date: Jan 2005
Posts: 15
Default Re:snap to edges

Hey, thank you sooooooo much for the code!!!

Is this suppose to be inserted into the "initialize" script?? if not where and how is this script activated?

thanks for you help.
Reply With Quote
  #4 (permalink)  
Old 01-19-2005, 02:30 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:snap to edges

Yes, insert it into the "initialize" script.
Reply With Quote
  #5 (permalink)  
Old 01-19-2005, 02:58 PM
Junior Member
 
Join Date: Jan 2005
Posts: 15
Default Re:snap to edges

i did that and it doesnt work. By the way, I'm using transparent swf with custom shape (its rectangle, nothing overly complex) with no application borders.
Reply With Quote
  #6 (permalink)  
Old 01-20-2005, 11:37 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:snap to edges

A sample and the exe file.

The sample requires swfkit or swfkit pro.
Reply With Quote
  #7 (permalink)  
Old 01-20-2005, 12:04 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:snap to edges

Sorry, it doesn't support a window moved by dragging the client area of the window([Operation Panel]->[Application definition]->[Interaction]->[Left mouse button click]). The mechanism of the "Drag window" feature of the left mouse click in swfkit is different from that of moving window by dragging the title bar of the window. It doesn't send the wm_exitsizemove event at all.

We will send the WM_EXITSIZEMOVE message in the next version.
Reply With Quote
  #8 (permalink)  
Old 01-20-2005, 02:33 PM
Junior Member
 
Join Date: Jan 2005
Posts: 15
Default Re:snap to edges

Ok. no problem. Thanks for all your help. I was hoping to have that feature as a convenience, but i can do without it.

Thanks
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:37 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.