Jump to content
Sign in to follow this  
IvanCodin

What does the -1 value represent

Recommended Posts

IvanCodin

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
MHz

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
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
IvanCodin

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  

×