Jump to content

GuiMsg return values


Jon
 Share

Recommended Posts

  • Administrators

JP has expressed a wish to change the return values of GuiMsg to be less confusing. At the moment in my current unstable it returns positive and negative results both for "good" and "bad" events so you can't just do

While GuiMsg() > 0

as other simple events (like maximizing/minimizing) give negative results.

This doesn't bother me too much as I tend to use a Select statement anyway on the msg received rather than doing something like the above code. But if there is a popular opinion on how the return values could work better then we need to change it now.

Due to the control ref now starting at 3 the values 1 and 2 could be used if required. Or we could have it so that serious events (timeout/closing by system menu) have negative numbers and other events (max/min) have massive numbers (higher than any possible control ref).

Also I don't what the return values of GuiMsg(0) and GuiMsg() to be different (0 is used to indicated closed by button at the moment which conflicts with "no event" in GuiMsg(0) mode). I had changed my unstable so that it returned -3 if the gui was closed (by defined button OR close menu) but this could also cause confusion.

Edited by Jon
Link to comment
Share on other sites

I have no probs with previous (all negative) return values, but if they are must to change, I vote for second case (nagative and/or big positive). Although this is not principle, IMO more logical when control refs start from 1. And I also agree that better if GuiMsg(0) and GuiMsg() will have identical return codes. 0 for no events and -3 for close are good enough.

Edited by Kot
Link to comment
Share on other sites

  • Administrators

Ok, not much feedback so I'll assume that there isn't actually a problem with the current implementation.

Both GuiMsg() and GuiMsg(0) to use the same values (except GuiMsg(0) will return 0 for no event but GuiMsg() will no longer use 0 as a return so the two should be interchangable)

Return values will be:

0 = no event ( GuiMsg(0) only)

-1 = timeout

-2 = unknown - JP/Valik what is this for at the moment - unclear from source

-3 = closed (either by defined button or by system menu)

-4 = minimized

-5 = restored

-6 = maximized

Not at all sure what -2 is used for.

The control refs should be like other handles and be "undefined" - so code like:

While GuiMsg() >0

is a no-no.

I could alter the code so the refs are adjusted to start from 1 but if they are undefined then this is not requried :D

The only oddidty is that you can't tell if the gui was closed by a defined button or by a system menu (both return -3) although if you need to you can use GuiRead() to find the last clicked button if you care. Seems OK to me.

Edited by Jon
Link to comment
Share on other sites

The help file for GuiMsg() says:

Hidden: -2 dialog box is in hidden state due to click on a button defined by GuiSetControlNotify.

I have never used that return for anything, though.

Link to comment
Share on other sites

In the code I first did:

if a GuiHide() was executed, the next GuiMsg(0) was returning -2 indicating that the gui is no more open.

That's has been removed in Jon code.

I am not for sure how the new code has to react to this sequence of gui function. :D

Link to comment
Share on other sites

  • Administrators

In the code I first did:

if a GuiHide() was executed, the next GuiMsg(0) was returning -2 indicating that the gui is no more open.

That's has been removed in Jon code.

I am not for sure how the new code has to react to this sequence of gui function. :huh2:

I can add this now I know what it is. :D

But should GuiMsg return -2 just the once followed by 0s or keep returning -2 as long as it is hidden?

Edited by Jon
Link to comment
Share on other sites

I can add this now I know what it is. :D

But should GuiMsg return -2 just the once followed by 0s or keep returning -2 as long as it is hidden?

it looks like you put the code in GuiMsg perhaps is not working

Sorry for the misinterpretation of the code move from hide to guimsg :huh2:

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...