 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
samhnky
Joined: 29 Sep 2009 Posts: 43
|
Posted: Mon Nov 16, 2009 10:00 pm Post subject: Closing a Sub Gui Thread |
|
|
(Please forgive me if this has been asked before... If it has I apparently do not know how to word the request.)
I'm writing a program for work, and due to the amount of users working in various "departments" I use an INI file to save individual preferences. The problem I'm having is with terminating the sub Gui (Gui 2)
I have a cancel button that calls the following code: | Code: | Gui2Close:
Gui, Destroy
Return |
However the "X" button is not using this GoSub... I think it is actually doing a hide type command, the problem then becomes that if I try to open my settings window again I run into problems where the Sub Gui declares variables it freaks out when the variables are declared... a second time. Using the Cancel button does not create this problem. So I'm trying to figure out how to alter the "X" buttons behavior on a sub Gui, or how to disable the "X" button on the sub gui.
Thank you for your assistance,
Sam |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Nov 16, 2009 10:30 pm Post subject: |
|
|
None of what you described is in the script you posted.
post your entire script so we can see all the things you listed. |
|
| Back to top |
|
 |
samhnky
Joined: 29 Sep 2009 Posts: 43
|
Posted: Mon Nov 16, 2009 10:49 pm Post subject: Please re-read |
|
|
| Anonymous wrote: | None of what you described is in the script you posted.
post your entire script so we can see all the things you listed. |
please re-read my post... My problem is not with my code that I have rather with code that I do not have...
What I need and do not have is one of the two following items
1. Code to intercept the sub Gui "X" buton and re route it to the Gui2Close
2. Disable the "X" button on the sub Gui forcing users to use the Cancle button if the wish to close the sub Gui without saving changes.
If you can help with one or both of the 2 above possible sollutions great, if you are still lost because I'm not providing more code... Then I honestly believe that you are just as lost as me... Sorry to be blunt, not trying to pu anyone down, I know probably 99.9% of you know more about AHK than I do, but I can't stress enough that my problem is not with code I have it is with code I need
Thanks |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 1770 Location: MN, USA
|
|
| Back to top |
|
 |
Guest
|
Posted: Mon Nov 16, 2009 11:15 pm Post subject: |
|
|
| Quote: |
1. Code to intercept the sub Gui "X" buton and re route it to the Gui2Close
|
| Code: |
XButton1::GoSub Gui2Close
|
| Quote: |
2. Disable the "X" button on the sub Gui forcing users to use the Cancle button
if the wish to close the sub Gui without saving changes
|
| Code: |
ifWinExist, <<Title of Gui Window>>
XButton1::Return
Return
|
By the way, if you read your own description you indicate you tried something and it didn't work, implying you tested a script.
if you didn't write anything, then you didn't say that. |
|
| Back to top |
|
 |
samhnky
Joined: 29 Sep 2009 Posts: 43
|
Posted: Mon Nov 16, 2009 11:47 pm Post subject: Awesome, exactly what I needed. |
|
|
| Anonymous wrote: | | Quote: |
1. Code to intercept the sub Gui "X" buton and re route it to the Gui2Close
|
| Code: |
XButton1::GoSub Gui2Close
|
| Quote: |
2. Disable the "X" button on the sub Gui forcing users to use the Cancle button
if the wish to close the sub Gui without saving changes
|
| Code: |
ifWinExist, <<Title of Gui Window>>
XButton1::Return
Return
|
By the way, if you read your own description you indicate you tried something and it didn't work, implying you tested a script.
if you didn't write anything, then you didn't say that. |
After someone pointed out to my I decided to research your suggestion... Xbutton1 is a mouse button, and not the X button in the top right corner...
I did a quick search and found that If I apply the option "SysMenu" to the Gui it will remove the Icon in the top left corner, and the minimize, maximize and close button (x button) in the top right corner... Thank you for the attempt...
Last edited by samhnky on Tue Nov 17, 2009 12:45 am; edited 1 time in total |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Nov 17, 2009 12:38 am Post subject: |
|
|
If you want to control many gui's individually and all at once.
Here is an alternative method to use WinClose.
| Code: |
OnMessage(0x112, "GuiClose") ; 0x112 = WM_SYSCOMMAND
Gui, 1:Show, x10 y10 w300 h150, Gui #1
Gui, 2:Show, x320 y10 w300 h150, Gui #2
Gui, 3:Show, x630 y10 w300 h150, Gui #3
Return
GuiClose(wParam) {
If (wParam = 0xF060) ; 0xF060 = SC_CLOSE
If (A_GUI = 1)Or If (A_GUI = 2) Or If (A_GUI = 3)
{
MsgBox, 0, SC_CLOSE, Close Button was clicked on GUI : #%A_GUI%`nOr Press ESC to Close All
WinClose Gui #%A_Gui%
}
}
ESC::ExitApp
|
|
|
| Back to top |
|
 |
samhnky
Joined: 29 Sep 2009 Posts: 43
|
Posted: Tue Nov 17, 2009 12:48 am Post subject: |
|
|
| Anonymous wrote: |
| Code: |
OnMessage(0x112, "GuiClose") ; 0x112 = WM_SYSCOMMAND
Gui, 1:Show, x10 y10 w300 h150, Gui #1
Gui, 2:Show, x320 y10 w300 h150, Gui #2
Gui, 3:Show, x630 y10 w300 h150, Gui #3
Return
GuiClose(wParam) {
If (wParam = 0xF060) ; 0xF060 = SC_CLOSE
If (A_GUI = 1)Or If (A_GUI = 2) Or If (A_GUI = 3)
{
MsgBox, 0, SC_CLOSE, Close Button was clicked on GUI : #%A_GUI%`nOr Press ESC to Close All
WinClose Gui #%A_Gui%
}
}
ESC::ExitApp
|
|
Interesting... but not sure how to even begin to use it... I'm not a programmer, I think I would be defined as a scriptkiddy... I think the SysMenu as I mentioned in my edited post above will fix my problem... Thanks everyone... |
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Tue Nov 17, 2009 6:14 pm Post subject: |
|
|
xbutton in the upper right hand corner of a window is called a "GuiClose" button.
To disable GuiClose, yoiu use the "GuiClose:" Label or Subroutine followed by a Return.
It can activated typically by a "gLabel" in a Gui Control, "GoSub" or "Hotkey"
Example:
| Code: |
Gui, add, Button, gGuiClose, Close
; Or
GoSub GuiClose
; Or
#c::GuiClose
GuiClose:
Return
|
Therefore the user will have to press your "Cancel" button on the window you described above. _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|