Sign in to follow this  
Followers 0
IvanCodin

What does the -1 value represent

5 posts in this topic

I have seen this many times and have not been able to find anything that describes what the minus value does. Here is an example from the Help file that show what I am talking about. What do the -1 values do?

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $widthCell, $msg, $iOldOpt
    
    GUICreate("My GUI")  ; will create a dialog box that when displayed is centered

    GUISetHelp("notepad")  ; will run notepad if F1 is typed
    $iOldOpt = Opt("GUICoordMode", 2)

    $widthCell = 70
    GUICtrlCreateLabel("Line 1 Cell 1", 10, 30, $widthCell) ; first cell 70 width
    GUICtrlCreateLabel("Line 2 Cell 1", -1, 0) ; next line   <=  Here is an example of what I mean
    GUICtrlCreateLabel("Line 3 Cell 2", 0, 0) ; next line and next cell
    GUICtrlCreateLabel("Line 3 Cell 3", 0, -1) ; next cell same line  <= Here is another example
    GUICtrlCreateLabel("Line 4 Cell 1", -3 * $widthCell, 0) ; next line Cell1

    GUISetState()      ; will display an empty dialog box

    ; Run the GUI until the dialog is closed
    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE

    $iOldOpt = Opt("GUICoordMode", $iOldOpt)
EndFunc   ;==>Example

Me

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Ah, I see. The -1 used to be Default in some cases. Since then the Default keyword has come into play. So consider these use of -1 as Default. IMO, -1 should have been replaced by Default long ago in examples.

Edit: Typo fix

Edited by MHz

Share this post


Link to post
Share on other sites

When using the GUI-functions it can have the meaning of "last used control".

In this example -1 is replaced by the ControlID of the Combo.

GUICtrlCreateCombo("", 10, 10)
GUICtrlSetData(-1, "item1|item2|item3", "item3")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks all!! I see I need to change some of my scripts :-)

Me

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