Source language: Translate to:

Window Positioning

NeoBook tips, tricks, code samples and more...

Moderator: Neosoft Support

Window Positioning

Postby Jim Brammer » Thu Feb 07, 2002 3:45 pm

Any ideas on how one can force a pub to move to specific coordinates on the screen instead of the center?  


Fortunately, NeoBook 4 has [WindowLeft] and [WindowTop] Global Variables. You can use these combined with the [ScreenWidth & Height] and [WindowWidth & Height] variables along with some simple Math to place your program window anywhere you need to.

For example, if you make a System Tray program that, when clicked, makes the program window appear at the bottom-right corner of the screen you might use a routine like the one below...

<font size=-2>
Code Sample  
Math "[ScreenWidth]-[WindowWidth]" "" "[WinX]"
Math "[ScreenHeight]-[WindowHeight]-28" "" "[WinY]"
SetVar "[WindowLeft]" "[WinX]"
SetVar "[WindowTop]" "[WinY]"

Likewise, if you need to re-center a window you could use another combination of those variables and Math like this...

<font size=-2>
Code Sample  
Math "[ScreenWidth]/2" "" "[ScrnW_Half]"
Math "[ScreenHeight]/2" "" "[ScrnH_Half]"
Math "[WindowWidth]/2" "" "[WinW_Half]"
Math "[WindowHeight]/2" "" "[WinH_Half]"
Math "[ScrnW_Half]-[WinW_Half]" "" "[NewWin_X]"
Math "[ScrnH_Half]-[WinH_Half]" "" "[NewWin_Y]"
SetVar "[WindowLeft]" "[NewWin_X]"
SetVar "[WindowTop]" "[NewWin_Y]"

(Edited by Jim Brammer at 5:46 pm on Feb. 7, 2002)
Jim Brammer

Return to NeoBook Knowledgebase

Who is online

Users browsing this forum: No registered users and 1 guest