Jump to content

Menu problem.


Potarski
 Share

Recommended Posts

I made a manu in my gui but i have small question, how to make if i click on settings(GUICtrlCreateMenuItem) then it show me a lot of my inputs and buttons, and if i click for settings2(GUICtrlCreateMenuItem) them show me other settings. I tested GuiCtrlDelete but not working good...

$hMAIN_WINDOW = GUICreate ("Test",363, 156, 800 / 2, 800 / 2)
$aMENUID[0] = GUICtrlCreateMenu ('Menu')
$aMENUID[1] = GUICtrlCreateMenuItem ('delete input' & @TAB & @TAB & '[F5]',$aMENUID[0])
$aMENUID[2] = GUICtrlCreateMenuItem ('show input' & @TAB & @TAB & '(requires restart)',$aMENUID[0])
$aMENUID[3] = GUICtrlCreateMenuItem ('read Input' & @TAB & @TAB & '(requires restart)',$aMENUID[0])
$aMENUID[9] = GUICtrlCreateMenuItem ('EXIT' & @TAB & @TAB & '[ESC]',$aMENUID[0])
GUISetState (@SW_SHOW,$hMAIN_WINDOW)


While 1
    $hMAIN_WINDOW = GUIGetMsg()
    Switch $hMAIN_WINDOW
        Case $GUI_EVENT_CLOSE
            Exit
        Case $aMENUID[2]
            $TEST = GUICtrlCreateButton("xxx", 0, 0, 29, 25, $WS_GROUP)
        Case $aMENUID[1]
            GUICtrlDelete($TEST)
        Case $aMENUID[3]
MsgBox(64,"Reading...",GUICtrlRead($TEST))
EndSwitch
WEnd

I need example: I click Test then show me some option boxes etc if i click Test2 then show me others settings etc. If i buse GuiDelete then GUICtrlRead($TEST) doesn't working show "0" before delete show good "xxx".

Edited by Potarski
Link to comment
Share on other sites

If I understood your question correctly you are trying to achieve something like this?

#include <GUIConstantsEx.au3>

Global $hMAIN_WINDOW, $hMAIN_MSG, $aMENUID[6], $TEST

$hMAIN_WINDOW = GUICreate ("Test",363, 156, 800 / 2, 800 / 2)
$aMENUID[0] = GUICtrlCreateMenu ('Menu')
$aMENUID[1] = GUICtrlCreateMenuItem ('delete input' & @TAB & @TAB & '[F5]',$aMENUID[0])
$aMENUID[2] = GUICtrlCreateMenuItem ('show input' & @TAB & @TAB & '(requires restart)',$aMENUID[0])
$aMENUID[3] = GUICtrlCreateMenuItem ('read Input' & @TAB & @TAB & '(requires restart)',$aMENUID[0])
$aMENUID[4] = GUICtrlCreateMenuItem ('EXIT' & @TAB & @TAB & '[ESC]',$aMENUID[0])
GUISetState()

While 1
    $hMAIN_MSG = GUIGetMsg()
    Switch $hMAIN_MSG
        Case $GUI_EVENT_CLOSE
            _aMENUID4()
        Case $aMENUID[2]
            _aMENUID2()
        Case $aMENUID[1]
            _aMENUID1()
        Case $aMENUID[3]
            _aMENUID3()
        Case $aMENUID[4]
            _aMENUID4()
    EndSwitch
WEnd

Func _aMENUID2()
    MsgBox(0, "", "Button: aMENUID[2] - show input")
EndFunc ;==> MenuID 2

Func _aMENUID1()
    MsgBox(0, "", "Button: aMENUID[1] - delete input")
EndFunc ;==> MenuID 1

Func _aMENUID3()
    MsgBox(0, "", "Button: aMENUID[3] - read input")
EndFunc ;==> MenuID 2

Func _aMENUID4()
    Exit
EndFunc ;==> MenuID 4
Link to comment
Share on other sites

  • Moderators

Potarski,

A hint towards a rather more elegant solution - create all the controls just once and then Hide/Show them as required: :idiot:

#include <GUIConstantsEx.au3>

Global $aMENUID[10]

$hMAIN_WINDOW = GUICreate("Test", 363, 156, 800 / 2, 800 / 2)

$aMENUID[0] = GUICtrlCreateMenu('Menu')
$aMENUID[1] = GUICtrlCreateMenuItem('delete input' & @TAB & @TAB & '[F5]', $aMENUID[0])
$aMENUID[2] = GUICtrlCreateMenuItem('show input' & @TAB & @TAB & '(requires restart)', $aMENUID[0])
$aMENUID[3] = GUICtrlCreateMenuItem('read Input' & @TAB & @TAB & '(requires restart)', $aMENUID[0])
$aMENUID[9] = GUICtrlCreateMenuItem('EXIT' & @TAB & @TAB & '[ESC]', $aMENUID[0])

$TEST = GUICtrlCreateInput("xxx", 10, 10, 45, 25) ; create input just once
GUICtrlSetState($TEST, $GUI_HIDE) ; and hide it

GUISetState(@SW_SHOW, $hMAIN_WINDOW)

While 1

    Switch GUIGetMsg() ; Use the result directly - certainly do NOT overwrite the GUI handle variable
        Case $GUI_EVENT_CLOSE, $aMENUID[9] ; Add menu exit item here
            Exit
        Case $aMENUID[2]
            GUICtrlSetState($TEST, $GUI_SHOW) ; Show input
        Case $aMENUID[1]
            GUICtrlSetState($TEST, $GUI_HIDE) ; Hide input
        Case $aMENUID[3]
            MsgBox(64, "Reading...", GUICtrlRead($TEST))
    EndSwitch
WEnd

A couple of other points:

- 1. You were overwriting the GUI handle when you tested for messages with GUIGetMsg - not a good idea! ;)

- 2. You can have a number of Case options in a single case - note how I added the Exit menu item to the Exit Case. :idiot:

- 3. You certainly do not require a restart to Hide/Show controls! :D

All clear? Please ask again if not. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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