Sign in to follow this  
Followers 0
Rad

$GUI_EVENT_CLOSE, which window sent the $msg?

6 posts in this topic

My wc3 tools i've been working on the last four days is nearly complete. After learning that StringSplit() turns x,x,x into var[1],var[2],var[3] rather than [0][1][2]

Now Im having trouble, I was going to give the window the $WS_CHILD or whatever tag, but that removes the close box from the top right. I am litterally OUT OF SPACE in the window and increasing could mess up my chart. Now I decide I want it to be able to shut that window only, that interferes with this though:

Case $msg = $GUI_EVENT_CLOSE
    Exit
EndSelect

Note there is many many more Case's so dont think its just crappy coding. I know how I would check that it wasnt the window firing, Im just not sure what to use to check.

The helpfile once again is making me mad:

Macro Details

@GUI_CTRLID The control ID of the control sending the message OR the system event ID

@GUI_WINHANDLE The handle of the GUI that sent the message

@GUI_CTRLHANDLE The handle of the Control that sent the message (if applicable)

It says those are 'invalid macros' and the examples below it only have it in the comment. I need to know how to use the @GUI_WINHANDLE so I can modify my case to:

Case $msg = $GUI_EVENT_CLOSE
    If @GUI_WINHANDLE = $window Then Exit
EndSelect

Share this post


Link to post
Share on other sites



this could be answered better if we have more contextual info (code).


---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ok then... my script is 862 lines and none of it is very organized as I add a piece here then add something there. Anyways Ill give you whats probrably most important

$window = GUICreate($windowname,256,256)

... (Options and inputs for $window)

$customize=GUICreate("Customize Damage Table", 270, 247, -1, -1)

... (labels and inputs that create a chart for $customize)

While 1

$msg = GuiGetMsg()

Case... (about 20 different cases)

Case $msg = $GUI_EVENT_CLOSE

Exit

EndSelect

WEnd

Func ... (About 12 different functions)

Endfunc

Important stuff is in bold, thats basically all you need related to the windows and if theres some special type of func like GUISetOnEvent (which doesnt work right for me...) you can tell me where to put it

edit~had to use quote tags, code should allow format though ><

Edited by Rad

Share this post


Link to post
Share on other sites

try GuiGetMsg(1)

From help file:

advanced [optional] return extended information in an array.

0 = (default) Returns a single event.

1 = returns an array containing the event and extended information.

---

How am I supposed to use GUIGetMsg(1)? Do I check $msg[1] = $window?

Share this post


Link to post
Share on other sites

I think you may be getting the GUI Event Modes confused.

The macros @GUI_CtrlId, @GUI_CtrlHandle and @GUI_WinHandle and functions GUISetOnEvent and GUICtrlSetOnEvent are only used when the "GUIOnEventMode" option is set to on.

The default mode is MessageLoop mode, in which a main code loop exists that calls GUIGetMsg().

It returns the event/control ID in a string by default, one would reference with $msg.

One can turn on the advanced mode of GUIGetMsg() by calling it with an argument of 1 to get an array of info similar the above macros one would reference by using:

$msg[0] for Event ID or Control ID if Event happened otherwise 0

$msg[1] for The window handle the event is from

$msg[2] for The control handle the event is from (if applicable)

$msg[3] for The current X position of the mouse cursor (relative to the GUI window)

$msg[4] for The current Y position of the mouse cursor (relative to the GUI window)

[Note: above $msg array info almost direct copy from help]

[Note: all of above assumes a the var holding GUIGetMsg val is named $msg]

Justin

Share this post


Link to post
Share on other sites

Oh yea I got this solved like this:

Case $msg = $GUI_EVENT_CLOSE

If WinActive($window) Then Exit

If WinActive($customize) Then GUISetState(@SW_HIDE,$customize)

EndSelect

xD

Share this post


Link to post
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
Sign in to follow this  
Followers 0