AutoHotkey Community

It is currently May 26th, 2012, 11:21 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Closing a Sub Gui Thread
PostPosted: November 16th, 2009, 11:00 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
(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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2009, 11:30 pm 
None of what you described is in the script you posted.

post your entire script so we can see all the things you listed.


Report this post
Top
  
Reply with quote  
 Post subject: Please re-read
PostPosted: November 16th, 2009, 11:49 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2009, 11:57 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
Code:
2GuiClose:
Gui, Destroy
Return

Creating Multiple GUI Windows


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 12:15 am 
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.


Report this post
Top
  
Reply with quote  
PostPosted: November 17th, 2009, 12:47 am 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
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 November 17th, 2009, 1:45 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 1:38 am 
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
 


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 1:48 am 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 7:14 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
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.

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Cerberus, Google [Bot], Google Feedfetcher, Maestr0, rbrtryn, Tipsy3000, XstatyK and 68 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group