Jump to content

Creating options menu - help


vocoder
 Share

Recommended Posts

So I have a created a GUI that has some text on it...and I have created a menu that has menuitems Options and Exit.

I am a bit stumped on how to do this

When a user clicks on option, I want the text in the current screen to be replaced by Options that I read from a text file...the user can change them and then save. when they press save, it would save all the options, then go back to the original gui (which itself also reads from text file, but i need the original text on screen)

does anyone have an example of a basic gui options screen that works like this? I tried looking through the examples, but nothing seems to work like this

thanks

Link to comment
Share on other sites

#Include <Constants.au3>
#Include <_XMLDomWrapper.au3>
#include <Array.au3>
#include <GuiConstants.au3>
#NoTrayIcon
Opt("TrayMenuMode", 1)

Local $sFile = $location
;-- Create GUI and components -


GuiCreate("My Program", 430, 700,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOPMOST)
        If FileExists($sFile) Then
            ;-- Message found, need to delete some GUI elements --
            GUICtrlDelete($sent1)
            GUICtrlDelete($input_logo)
            
            
        Else
            ;-- Create barebones app when there is no message found --
            $filemenu = GUICtrlCreateMenu ("&File")
            $filepref = GUICtrlCreateMenuitem ("Options",$filemenu)
            $fileexit = GUICtrlCreateMenuitem ("Exit",$filemenu)
            
            
            $sent1 =  GUICtrlCreateLabel ($nomessage, 70, 140, 400, 200)
            GUICtrlSetColor(-1,0xff0000)
            GUICtrlSetFont (-1,$nofontsize, 400, 2, $nofont)
            GUICtrlSetColor(-1,$nomsgfontcolor)
            GUISetState (@SW_SHOW)
        EndIf
            
            
        
GUISetState()
;-- Tray Menu Items --

$Show    = TrayCreateItem("Show My Program")
$spacer1 = TrayCreateItem("")
$pref    = TrayCreateItem("Options")
$spacer2 = TrayCreateItem("")
$Hide    = TrayCreateItem("Hide My Program")
$spacer2 = TrayCreateItem("")
$about   = TrayCreateItem("About")
$spacer3 = TrayCreateItem("")
$exit    = TrayCreateItem("Exit")
$spacer4 = TrayCreateItem("")
TraySetState()
;-- While the Program is running, do the following --
$sec = @SEC
While 1
    
    If FileExists($sFile) Then
        Local $sFile = $location
        ;-- Create GUI and components -
        
        $ret = _XMLFileOpen($sFile)
        GUISetState(@SW_SHOW)
        
    

        ;-- do some stuff here (i removed this to trim down the code for the time being)
                ;-- removed reading from files, then displaying text on the GUI

            GUISetState (@SW_SHOW)
        
    
        ;-- after we are done reading the file, need to move it to a logfile
        ;FileDelete($sFile)
        
        
    EndIf
    
    ;-- begin system tray stuff --
    $msg = TrayGetMsg()
    $xmsg = GUIGetMsg()
    If $xmsg = $filepref Then
        GuiDelete("My Program")
        GuiCreate("My Program Options", 430, 700,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOPMOST)
        GUISetState (@SW_SHOW)
        
    EndIf
        
    Select
        Case $xmsg = $sent1
            WinSetState("My Program", "", @SW_SHOW)
        Case $msg = $Show
            WinSetState("My Program", "", @SW_SHOW)
        Case $msg = $Hide
            WinSetState("My Program", "", @SW_HIDE)
        Case $msg = $about
            MsgBox(64, "about:", "My Program")
        Case $msg = $exit Or $xmsg = $fileexit
            Exit
        Case $xmsg = $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE)
        Case $xmsg = $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE)
        Case $msg = $TRAY_EVENT_PRIMARYDOUBLE
            GUISetState(@SW_SHOW)
        
    EndSelect
WEnd
Exit

I removed some of the GUI code as it was very very long and not really necessary...where i put the remove comment, just image lots of GUICreateLabel and GUICreateInputs

Edited by vocoder
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...