iAmNewbe Posted July 17, 2017 Share Posted July 17, 2017 I have two 27" Monitors in Dual setup. I created the following code in another thread due to not able to get TrayTips to work how I need. It creates a popup window via GUICreate. I have discovered an odd quirk that I am not sure why it is happening. If you do not have these same sized monitors then you will not be able to see the problem if you run the code as is. Using the code below I am moving the created popup window to various areas of my desktop. Trying to get it to hug the left side of the left monitor or specifically the desktop, a certain number "1921" will center the window instead. ----------------------------------------------------------------------------------------------- There is a boundary border around the GUI window. $Left = 1920 <== The left side of the GUI Window and the left side of the desktop there is a one pixel space between them $Left = 1921 <== The left side of the GUI Window and the left side of the monitor are SUPPOSE to Hug, no gaps Instead this centers the window on the left monitor $Left = 1922 <== The left side edge of the gui window is just over the desktop left edge out of sight, can't see the white left border. expandcollapse popup#include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <ColorConstants.au3> $Left = 1920 $Top = 150 Notice("Left Edge","Left Monitor - Left Edge",4,1,$Left,$Top) ; -- BUG -- $Left = 1921 ; <-- 1921 puts gui window center of screen - Left Monitor WHY? $Top = 150 Notice("Funky Position","Moves to center of left monitor",4,2,$Left,$Top) ; -- END BUG -- $Left = 1922 $Top = 150 Notice("Past Left Edge","Moves Left of Left Edge - Left Monitor",4,1,$Left,$Top) Func Notice($message, $description, $timeout = 2, $icon=0,$Left=352,$Top=120) Local $iconArray[4] = ["", "16783", "161", "240" ] Local $popup = GUICreate("",350,60,(@DesktopWidth - $Left),(@DesktopHeight - $Top),$WS_POPUP+$WS_BORDER) ; title, width, height, left, top, style, exStyle, parent GUICtrlSetDefColor(0xFFFFFF) GUISetBkColor(0x1F1F1F) if($icon > 3) Then $icon = 0 if($timeout < 1) Then $timeout = 2 $timeout = $timeout * 1000 if($icon > 0) Then GUICtrlCreateIcon("shell32.dll", $iconArray[$icon], 10, 7,43,43) ; filename, iconName, left, top, width, height, style, exstyle $theMessage = GUICtrlCreateLabel($message,65, 10, 300, 30) ; text, left, top, width, height, style, ex style GUICtrlSetFont(-1, 12, 600, 0, "", 2) ; size, weight, attribute ( 2 = italic, 4 = underline, 8 = strike ), fontname, quality $theDescription = GUICtrlCreateLabel($description, 65, 32, 300, 30) GUICtrlSetFont(-1, 9, 100, 0,"",2) ; GUICtrlSetColor(-1, 0xACAEAC) GUISetState(@SW_SHOW, $popup) Sleep($timeout) GUIDelete($popup) EndFunc Is there something I am doing wrong in my code or is this a bug? Why does the code above when 1921 is entered into the LEFT option for GUICreate position does it dramatically alter the gui window position? Link to comment Share on other sites More sharing options...
iAmNewbe Posted July 17, 2017 Author Share Posted July 17, 2017 (edited) GUICreate("",350,60,(@DesktopWidth - $Left),(@DesktopHeight - $Top),$WS_POPUP+$WS_BORDER) ; title, width, height, left, top, This is the specific line for creating and positioning the Gui Window. $Left = 1921 so (@DesktopWidth - 1921) <== PROBLEM occurs Edited July 17, 2017 by iAmNewbe Link to comment Share on other sites More sharing options...
iAmNewbe Posted July 17, 2017 Author Share Posted July 17, 2017 Further Investigation --------------------------------------------------- Two Monitors, Left Monitor and Right Monitor @DesktopWidth = 1920 GUICreate(TITLE, WIDTH, HEIGHT, LEFT, TOP, STYLE, EXSTYLE, PARENT) LEFT Option of GUICreate contains ----------------------------------------------- (@DesktopWidth - 1920) Result Numerical 0 AND Positions to Left side of Left Monitor (@DesktopWidth - 0) Result Numerical 1920 AND Positions to Left side of Right Monitor (@DesktopWidth - 1921) Result Numerical -1 AND Positions to Center of Left Monitor (@DesktopWidth - -1) Result Numerical 1921 AND Positions to close to Left Edge of Right Monitor (gaps between edges of GUI Window and Right Monitor) 0 <== Left Side of Left Monitor -1 <== Centers on Left Monitor -2 <== Left Edge of GUI is past Left Edge of Desktop out of sight --------------------------------------------- It seems the issue is when -1 is used in the spacing of the Left Option for GUICreate. For me in this situation if I just use 0 without @DesktopWidth calc then it positions how I want on the left edge of the left monitor / desktop. Link to comment Share on other sites More sharing options...
iAmNewbe Posted July 17, 2017 Author Share Posted July 17, 2017 Discrepancy between first post and post #3 In Post 1 (@DesktopWidth - $Left) when $Left is 1920 which after calculation result is ZERO I said position of GUI is one pixel off from Left side of desktop. Then When removal of @DesktopWidth and just place the numeric 0 then the GUI touches the Left side of the desktop. Both are same numerically. When testing again with both of these options I get the equal result of the GUI window left edge touching the left edge of the desktop. I do NOT know why I got a different result the first time around. I am pulling the $Left variable or integer from an ini file setting. For some reason I can not pass @DesktopWidth or other @ constants via ini file it just does not work so I have to hard code these constants / directives into the code and just pass the numeric number through. Which I believe are strings when doing it this way and not integers. I am not sure why -1 does not work but I will just use the 0 for LEFT option for positioning horizontally where I want via subtracting the desktop width by itself to get zero. Link to comment Share on other sites More sharing options...
iAmNewbe Posted July 17, 2017 Author Share Posted July 17, 2017 Long story short -1 centers GUI 0 Paces GUI on left edge of desktop I do not understand -1 result with GUI placement. Link to comment Share on other sites More sharing options...
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