Jump to content

Only first level menu items


crzftx
 Share

Recommended Posts

I have a GUI with a menu. Let's pretend it has "Options", "Help", and "Exit" on the menu bar. But I don't want each button to be it's own Menu, but simply a MenuItem. If I don't have any Menus on the bar, the MenuItems don't show up. I put a GUICtrlCreateMenu("") in there, but then there's a blank button. Any ideas?

Link to comment
Share on other sites

I am not exactly sure what you mean but it sounds more like a toolbar than a menu to me, check the example for _GUICtrlToolbar_AddString() in the helpfile

Link to comment
Share on other sites

Couldn't see how that works without accompanying pictures, but maybe missing something.

#include <GuiToolbar.au3>

Opt("GUIOnEventMode",1)

$guiMain = GUICreate("Test GUI",300,300)
GUISetFont(11,500,0,"Verdana")

$toolbar = _GUICtrlToolbar_Create($guiMain)

$menuStatistics = _GUICtrlToolbar_AddString($toolbar,"Statistics")
;$menuStatistics = GUICtrlCreateMenuItem("Statistics",-1)
GUICtrlSetOnEvent(-1,"ShowStatistics")

$menuOptions = _GUICtrlToolbar_AddString($toolbar,"Options")
;$menuOptions = GUICtrlCreateMenuItem("Options",-1)
GUICtrlSetOnEvent(-1,"ShowOptions")

$menuHelp = _GUICtrlToolbar_AddString($toolbar,"Help")
;$menuHelp = GUICtrlCreateMenuItem("Help",-1)
GUICtrlSetOnEvent(-1,"ShowHelp")

GUISetOnEvent(-3,"Quit")

GUISetState()

While 1
    Sleep(25)
WEnd

Func ShowStatistics()
    ConsoleWrite("User pressed Statistics" & @CRLF)
EndFunc

Func ShowOptions()
    ConsoleWrite("User pressed Options" & @CRLF)
EndFunc

Func ShowHelp()
    ConsoleWrite("User pressed Help" & @CRLF)
EndFunc

Func Quit()
    Exit
EndFunc
Link to comment
Share on other sites

I was thinking you could use _GUICtrlToolbar_AddButton() without setting a image by having "-2" as the third parameter, but now when I try it I see that it is really ugly and is perhaps not a good solution... Sry mate.

Just wait and someone (probably rasim or martin :P) will post something better

Edited by AdmiralAlkex
Link to comment
Share on other sites

crzftx

Hmm... very strange. Without a "main" menu menuitems doesn't displayed, i didn't know that. Anyway you can create a menu controls using a _GUICtrlMenu_* functions, see in the help file. :P

#include <GuiToolbar.au3>

Opt("GUIOnEventMode",1)

$guiMain = GUICreate("Test GUI",300,300)
GUISetFont(11,500,0,"Verdana")

$MenuFile = GUICtrlCreateMenu("&File") ;Main menu

$menuStatistics = GUICtrlCreateMenuItem("Statistics", -1)
GUICtrlSetOnEvent(-1, "ShowStatistics")

$menuOptions = GUICtrlCreateMenuItem("Options", -1)
GUICtrlSetOnEvent(-1, "ShowOptions")

$menuHelp = GUICtrlCreateMenuItem("Help", -1)
GUICtrlSetOnEvent(-1, "ShowHelp")

GUISetOnEvent(-3,"Quit")

GUISetState()

While 1
    Sleep(25)
WEnd

Func ShowStatistics()
    ConsoleWrite("User pressed Statistics" & @CRLF)
EndFunc

Func ShowOptions()
    ConsoleWrite("User pressed Options" & @CRLF)
EndFunc

Func ShowHelp()
    ConsoleWrite("User pressed Help" & @CRLF)
EndFunc

Func Quit()
    Exit
EndFunc
Link to comment
Share on other sites

Strange ... but you can delete the Menu after you have created the first item :P

#include <GuiToolbar.au3>

Opt("GUIOnEventMode",1)

$guiMain = GUICreate("Test GUI",300,300)
GUISetFont(11,500,0,"Verdana")

$MenuTemp = GUICtrlCreateMenu("TempItem") ;Main menu

$menuStatistics = GUICtrlCreateMenuItem("Statistics", -1)
GUICtrlSetOnEvent(-1, "ShowStatistics")

; now We have an Item and can delete the TempMenu again :)
GUICtrlDelete($MenuTemp)

$menuOptions = GUICtrlCreateMenuItem("Options", -1)
GUICtrlSetOnEvent(-1, "ShowOptions")

$menuHelp = GUICtrlCreateMenuItem("Help", -1)
GUICtrlSetOnEvent(-1, "ShowHelp")

GUISetOnEvent(-3,"Quit")

GUISetState()

While 1
    Sleep(25)
WEnd

Func ShowStatistics()
    ConsoleWrite("User pressed Statistics" & @CRLF)
EndFunc
Func ShowOptions()
    ConsoleWrite("User pressed Options" & @CRLF)
EndFunc
Func ShowHelp()
    ConsoleWrite("User pressed Help" & @CRLF)
EndFunc
Func Quit()
    Exit
EndFunc

*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

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