Jump to content
Sign in to follow this  
crzftx

Only first level menu items

Recommended Posts

crzftx

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?

Share this post


Link to post
Share on other sites
AdmiralAlkex

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

Share this post


Link to post
Share on other sites
crzftx

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

Share this post


Link to post
Share on other sites
AdmiralAlkex

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

Share this post


Link to post
Share on other sites
rasim

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

Share this post


Link to post
Share on other sites
ProgAndy

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.