Triton Posted July 15, 2004 Posted July 15, 2004 I know this is simple but I can't seem to get the right calculation for it. I want to put my gui window in the lower right corner of the desktop and want it to position itselt according to desktop height and width. I've got the basic calc but it does not seem to hit the right spot on different resolutions. Thanks. Triton
CyberSlug Posted July 15, 2004 Posted July 15, 2004 There are two gotchas: 1) Position of Windows' task bar. 2) The paramteres for GuiCreate are only the client area of the window, so you have to calculate the titlebar and border sizes..... I put code somewhere in AutoBuilder that calculates window titlebar dimensions. I'll post an example if I get time. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
CyberSlug Posted July 15, 2004 Posted July 15, 2004 Disclaimer: tested only on Windows XP; based on this codeIf you do NOT want to take the Windows' taskbar into consideration, then remove _WinLowerRightCorner and uncomment the call to WinMove.expandcollapse popup$title = "Gui Example" $width = 300 $height = 400 GuiCreate($title, $width, $height) ;;;;$size = WinGetPos($title);window size ;;;;;WinMove($title,"", @DesktopWidth - $size[2], @DesktopHeight - $size[3]) _WinLowerRightCorner($title) GuiShow() GuiWaitClose() Func _WinLowerRightCorner($title) $pos = WinGetPos($title) If @error Then Return 1 Local $xAdjust = 0, $yAdjust = 0 $tb = WinGetPos("","Notification Area") ;taskbar x,y,width,height If @error Then Return 0 Select Case ($tb[2] > $tb[3]) And ($tb[1] > 0) ;width>height && y>0 $yAdjust = $tb[3] ;taskbar at bottom Case ($tb[2] > $tb[3]) And ($tb[1] <= 0);width>height && y<=0 $yAdjust = -$tb[3] ;taskbar at top Case ($tb[2] < $tb[3]) And ($tb[0] > 0) ;width<height && x>0 $xAdjust = $tb[2] ;taskbar at right Case Else $xAdjust = -$tb[2] ;taskbar at left EndSelect $newX = (@DesktopWidth - $xAdjust - $pos[2]) $newY = (@DesktopHeight - $yAdjust - $pos[3]) WinMove($title, '', $newX, $newY) EndFunc Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Triton Posted July 15, 2004 Author Posted July 15, 2004 Thanks CyberSlug I was real close with my current code. Triton
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