Jump to content

Switching between Menu Items


Recommended Posts

Hello Guys,

 

I think you all know the Koda Form Designer.

I Created a menubar like this:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\spiele\desktop\layout.kxf
$Form1_1 = GUICreate("Hello", 615, 438, 567, 402)
$MenuItem3 = GUICtrlCreateMenu("&Start")
$Start_page = GUICtrlCreateMenuItem("Start", $MenuItem3)
$Settings_ = GUICtrlCreateMenu("Settings", $MenuItem3)
$Settings_martin = GUICtrlCreateMenuItem("Martingale", $Settings_)
$Settings_green = GUICtrlCreateMenuItem("Green", $Settings_)
$request = GUICtrlCreateMenuItem("Requests", $MenuItem3)
$Exit = GUICtrlCreateMenuItem("Exit", $MenuItem3)
GUICtrlSetResizing(-1, $GUI_DOCKHCENTER+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 64, 72, 49, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

 

But how can i switch between the menuitems without opening a whole GUI, so that the menubar exists further.

 

Thank you!

 

 

 

Link to comment
Share on other sites

  • Moderators

Zeotrope,

I am afraid I have absolutely no idea what you are asking - can you explain in more detail.

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

  • Moderators

Zeotrope,

How does that image relate to the code you posted earlier - the menu bars are entirely different? And what has the button to do with the menu selection?

Please try and explain what you want to do in simple terms because at the moment you are making no sense at all.

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

Ok in steps now, related to the picture:

 

1 - starting program

2 - GUI loads with this Button

3 - Now i want to klick on help - submenu - about

4 - The content of this menu should be shown now instead of this button

 

But with my solutions a new GUI gets created and a new Window opens, without the menubar.

But i want to keep this window with this menubar and just change the content (below the menubar)

 

Hope i explained it good now^^

 

Link to comment
Share on other sites

  • Moderators

Zeotrope,

So you want the content of the GUI to change depending on the menu item you select? That should not prove too difficult - but you will have to wait until tomorrow before I post an example.

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

  • Moderators

Zeotrope,

The easiest way to do this is to use my GUIExtender UDF (the link is in my sig) - that way you can create several sections in your GUI and decide which will appear when the menu is used. Here is a very simple example:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include "GUIExtender.au3"

$hGUI = GUICreate("Test", 500, 900)

$mFileMenu = GUICtrlCreateMenu("File")
$mItem_1 = GUICtrlCreateMenuItem("Item 1", $mFileMenu)
$mItem_2 = GUICtrlCreateMenuItem("Item 2", $mFileMenu)
$mItem_3 = GUICtrlCreateMenuItem("Item 3", $mFileMenu)
GUICtrlCreateMenuItem("", $mFileMenu)
$mExit = GUICtrlCreateMenuItem("Exit", $mFileMenu)

_GUIExtender_Init($hGUI)

$iSection_1 = _GUIExtender_Section_Start($hGUI, 0, 300)
_GUIExtender_Section_Action($hGUI, $iSection_1)

; Create a disabled coloured background - different colour for each selection
GUICtrlCreateLabel("", 0, 0, 500, 300)
GUICtrlSetBkColor(-1, 0xFFCCCC)
GUICtrlSetState(-1, $GUI_DISABLE)

; Add some controls
$cButton_1 = GUICtrlCreateButton("Button 1", 100, 30, 100, 30)

_GUIExtender_Section_End($hGUI)

$iSection_2 = _GUIExtender_Section_Start($hGUI, 300, 300)
_GUIExtender_Section_Action($hGUI, $iSection_2)

GUICtrlCreateLabel("", 0, 300, 500, 300)
GUICtrlSetBkColor(-1, 0xCCFFCC)
GUICtrlSetState(-1, $GUI_DISABLE)

$cButton_2 = GUICtrlCreateButton("Button 2", 200, 430, 100, 30)

_GUIExtender_Section_End($hGUI)

$iSection_3 = _GUIExtender_Section_Start($hGUI, 600, 300)
_GUIExtender_Section_Action($hGUI, $iSection_3)

GUICtrlCreateLabel("", 0, 600, 500, 300)
GUICtrlSetBkColor(-1, 0xCCCCFF)
GUICtrlSetState(-1, $GUI_DISABLE)

$cButton_3 = GUICtrlCreateButton("Button 3", 300, 830, 100, 30)

_GUIExtender_Section_End($hGUI)

; Leave first section open
_GUIExtender_Section_Extend($hGUI, $iSection_2, False)
_GUIExtender_Section_Extend($hGUI, $iSection_3, False)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $mExit
            Exit

        ; Open/close sections depending on menu selection
        Case $mItem_1
            ; Close all sections
            _GUIExtender_Section_Extend($hGUI, 0, False)
            ; Open required section
            _GUIExtender_Section_Extend($hGUI, $iSection_1)
        Case $mItem_2
            _GUIExtender_Section_Extend($hGUI, 0, False)
            _GUIExtender_Section_Extend($hGUI, $iSection_2)
        Case $mItem_3
            _GUIExtender_Section_Extend($hGUI, 0, False)
            _GUIExtender_Section_Extend($hGUI, $iSection_3)

        ; look for the controls being actioned
        Case $cButton_1
            MsgBox($MB_SYSTEMMODAL, "Pressed", "Button 1")
        Case $cButton_2
            MsgBox($MB_SYSTEMMODAL, "Pressed", "Button 2")
        Case $cButton_3
            MsgBox($MB_SYSTEMMODAL, "Pressed", "Button 3")
    EndSwitch

WEnd

The UDF can look quite daunting at first, so please do ask if you have any questions about how to use it.

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