Jump to content

SOLVED----GUI Window Remembers Screen Position


 Share

Go to solution Solved by TheSaint,

Recommended Posts

I have a script that parses our wiki page at work and generates an email.  The email is generated in its own "GUi-Window".  I have 4 monitors on my machine. My script is opening up the newly generated GUI page on another monitor other than the "primary". This is fine for me, but this is going to be deployed to everyone in my department who don't have multiple monitors setup.  I tested on a co-workers machine who only has his laptop, and the first gui opens just fine, but the second gui "email notification" opens "Off Screen".  I had to move it over to the laptop display to be able to see what was there.

Why is it doing this and how can I make it so that the second window always opens up on the same window where the first gui opens?

Code is below, any and all help is greatly appreciated.

 

FIrst Gui Creation

$C4Automation = GUICreate("C4 Automation", 615, 438, 188, 121)
$Label1 = GUICtrlCreateLabel("C4 Automation", 32, 24, 564, 41)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$ProjectSiteCombo = GUICtrlCreateCombo("", 184, 104, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_SORT))
$ProjectTypeCombo = GUICtrlCreateCombo("", 184, 136, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_SORT))
$ProjectNameInputBox = GUICtrlCreateInput("Project Name", 184, 168, 161, 21, $ES_UPPERCASE)
$NumberofProjects = GUICtrlCreateInput("Number of Projects", 184, 200, 161, 21)
$Submit = GUICtrlCreateButton("Submit", 136, 264, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Exit = GUICtrlCreateButton("Exit", 256, 264, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Choose Your Project Type:", 24, 140, 156, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Choose Your Project Site:", 24, 108, 150, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Input Your Project Name:", 24, 172, 147, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("Input Number of Projects", 24, 204, 145, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("Choose Your Project Side", 24, 236, 149, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$ProjectSideCombo = GUICtrlCreateCombo("", 184, 232, 145, 25, BitOR($CBS_DROPDOWN, $CBS_SORT))
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState(@SW_SHOW)

Second GUI Creation

$EmailEdit = GUICtrlCreateEdit("", 32, 72, 761, 401, BitOR($ES_MULTILINE, $WS_VSCROLL))
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetData(-1, "")
$CopyButton = GUICtrlCreateButton("Copy To Clipboard", 680, 480, 99, 25)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState(@SW_HIDE);;;;This hides the first GUI that is created. 
$EmailForm = GUICreate("Maintenance Email Notification", 831, 518, -1435, 222) 
$Label = GUICtrlCreateLabel("Maintenance Email Notification ", 25, 22, 780, 41) 
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") 
$EmailEdit = GUICtrlCreateEdit("", 32, 72, 761, 401, BitOR($ES_MULTILINE, $WS_VSCROLL)) 
GUICtrlSetState(-1, $GUI_HIDE) 
GUICtrlSetData(-1, "") 
$CopyButton = GUICtrlCreateButton("Copy To Clipboard", 680, 480, 99, 25) 
Local $test = FileRead("c4.txt") 
ClipPut($test) FileClose($c4file) 
FileDelete("c4.txt")
GUICtrlSetData($EmailEdit, ClipGet()) 
GUICtrlSetState($EmailEdit, $GUI_SHOW) 
GUISetState(@SW_SHOW);;;This shows the email generated form once all the data is populated in the edit box.
Edited by atnextc
Link to comment
Share on other sites

  • Solution

$EmailForm = GUICreate("Maintenance Email Notification", 831, 518, -1435, 222)

Obviously it is the -1435 that is putting your GUI off-screen to the left.

If you are just gonna deploy to everyone as stand-alone, and don't need to check for multiple displays, then just change that to the required positive number.

If you only want to have a single program for yourself and them, then do a test based on user name, so as to retain the negative number on your machine, but a positive on everyone else's.

So either use @UserName or @ComputerName

Example

If @UserName = "atnextc" Then
    $left = -1435
Else
    $left = 188
EndIf
$EmailForm = GUICreate("Maintenance Email Notification", 831, 518, $left, 222)

Did you create the program code yourself?

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...