Jump to content

Settings Dialog


Recommended Posts

I've been trying like crazy to find a way to do a 'Settings' dialog with two (2) panes like a lot of applications have. This is what I want but I am sure that there is a much better way to do it:

post-61648-0-08916300-1299552303_thumb.p

And here's the code that at least shows what I want:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $listview, $hListView, $button, $item1, $item2, $item3, $itemSep, $input1, $msg, $GUI, $Form2, $PasswordEdit, $ButtonCancel, $ButtonOk, $EnterPassLabel, $activelistitem, $Label, $GeneralLabel, $AdvancedLabel, $ActiveView
    $GUI = GUICreate("Settings", 750, 500, -1, -1)
    $listview = GUICtrlCreateListView("                                       ", 10, 10, 148, 450, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_NOCOLUMNHEADER,$LVS_NOSORTHEADER,$LVS_NOSCROLL));,$LVS_SORTDESCENDING)
    $item1 = GUICtrlCreateListViewItem("General", $listview)
    $item2 = GUICtrlCreateListViewItem("Password", $listview)
    $itemSep = GUICtrlCreateListViewItem("———————————", $listview)
    GUICtrlSetColor ( -1, 0xbababa)
    $item3 = GUICtrlCreateListViewItem("Advanced", $listview)
    $GeneralLabel = GUICtrlCreateLabel("General settings would go here.", 180, 12, 200, 17, 0)
    GUISetState()
    Do
        $msg = GUIGetMsg()
        $activelistitem = GUICtrlRead(GUICtrlRead($listview))
        Select
            Case $msg = $item1 or StringInStr ($activelistitem, "General")
                If $ActiveView <> "General" Then
                    GUICtrlDelete ($PasswordEdit)
                    GUICtrlDelete ($ButtonOk)
                    GUICtrlDelete ($ButtonCancel)
                    GUICtrlDelete ($EnterPassLabel)
                    GUICtrlDelete ($AdvancedLabel)
                    $GeneralLabel = GUICtrlCreateLabel("General settings would go here.", 180, 12, 180, 17, 0)
                    $ActiveView = "General"
                EndIf
            Case $msg = $item2 or StringInStr ($activelistitem, "Password")
                If $ActiveView <> "Password" Then
                    GUICtrlDelete ($GeneralLabel)
                    GUICtrlDelete ($AdvancedLabel)
                    $PasswordEdit = GUICtrlCreateInput("password:", 180, 32, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
                    $ButtonOk = GUICtrlCreateButton("&OK", 228, 64, 75, 25, $BS_NOTIFY)
                    $ButtonCancel = GUICtrlCreateButton("&Cancel", 310, 64, 75, 25, $BS_NOTIFY)
                    $EnterPassLabel = GUICtrlCreateLabel("Enter password:", 180, 12, 180, 17, 0)
                    $ActiveView = "Password"
                EndIf
            Case $msg = $item3 or StringInStr ($activelistitem, "Advanced")
                If $ActiveView <> "Advanced" Then
                    GUICtrlDelete ($PasswordEdit)
                    GUICtrlDelete ($ButtonOk)
                    GUICtrlDelete ($ButtonCancel)
                    GUICtrlDelete ($EnterPassLabel)
                    GUICtrlDelete ($GeneralLabel)
                    $AdvancedLabel = GUICtrlCreateLabel("Advanced settings would go here.", 180, 12, 180, 17, 0)
                    $ActiveView = "Advanced"
                EndIf
        EndSelect
        Sleep(10)
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Is there anything out there (a UDF or an AutoIt example) that can do exactly what I have but in a much more efficient way?

I've searched through UDF's, examples and the AutoIt forum in general but came up empty. Maybe layered GUI's would work? I don't know? I tried but wasn't successful...

As usual, any help would be so greatly appreciated and I am sure that a lot of people want exactly what I am trying to achieve,

Thanks,

Ian

Developer and Co-OwnerInTime Applicaitons Inc.

Link to comment
Share on other sites

There is a more elegant way: Create multiple child GUIs and Show/Hide theam according to the selected item in the List.

I created some functions to help with that:

http://autoit.de/index.php?page=Thread&postID=77017#post77017

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Cheers ProgAndy! I would also recommend the Wiki entry about Multiple GUI's too >> http://www.autoitscript.com/wiki/Managing_Multiple_GUIs

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Thanks to both of you for the reply! I knew about child windows but I wasn't quite sure how to do it so that they would follow the main GUI when moving the window. ProgAndy, your example works perfectly and even though some of the top functions where a little be tricky to understand, it is extremely easy to add items making this the perfect base for what I am trying to do.

Thanks so much! I knew that someone would come to save the day! AutoIt is great and so is it's community!

Take care,

Ian

Developer and Co-OwnerInTime Applicaitons Inc.

Link to comment
Share on other sites

Yeah, the function names do not fit and the UDFs are lacking documentation, but I am not in the mood to change it :)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

I would prefer a For loop and GUICtrlSetState() :)

PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.
Link to comment
Share on other sites

Yeah, the function names do not fit and the UDFs are lacking documentation, but I am not in the mood to change it :)

Don't worry about it! All it's lacking is a bunch of green text... I think it's perfect!

Thanks again! You saved me a bunch of time!

Ian

P.S.: I got it working with ListView instead of TreeView like I originally wanted it. Now I have to incorporate all my settings. I have at least 150 different settings so it's quite the task! You UDF is definitely going to help me a great deal! :)

Developer and Co-OwnerInTime Applicaitons Inc.

Link to comment
Share on other sites

Just a quick note. With the extended style set to:

$WS_EX_CONTROLPARENT

... the tab GUI can be moved around. Replacing $WS_EX_CONTROLPARENT with -1 fixes this issue.

But it did scare me for a moment. Glad I got the GUI to not move :)

Ian

Developer and Co-OwnerInTime Applicaitons Inc.

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