Jump to content

What does the -1 value represent


Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...