Jump to content
Sign in to follow this  
MrCreatoR

Create menu item as button - not working with 3.2.12.0

Recommended Posts

MrCreatoR

Hi,

The example bellow supose to display a GUI with one menu item (as menu button), when you press that item, event is fired:

GUICreate("Test", 200, 100)

$MenuItem = GUICtrlCreateMenuItem("Menu Button", -1)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $MenuItem
            MsgBox(0, "", "Menu Button Pressed")
            If $MenuItem = 0 Then Exit
    EndSwitch
WEndoÝ÷ Ø2¢çÇëw[h±ëbµé²g§¹»­¶È­æ¥'hmz0ø­Á«nè(}¼×ýö×M(®+b±¦î)÷Û]´nëh}µÛH­p¢¹"§Êj+y8^צÉèµÊÞj×Ó~z{µé«zÛ«Í(y«!£hv­=/Û"Ü(®K"­æ­z+Z±«rÝéîjëh×6GUICtrlCreateMenu("Menu")
$MenuItem = GUICtrlCreateMenuItem("Menu Button", -1)

But i need it for the first one...


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
MrCreatoR

Just for your information: On my 3.2.10 it works fine.

GUICreate("Test", 200, 100)
$MenuItem = GUICtrlCreateMenuItem("Menu Button", -1)
GUISetState()

...
That's what i say...

I really don't know if it was a bug on 3.2.8.1/3.2.10.0, or it is a bug in 3.2.12.0, but on 3.2.12.0 it not working anymore

I am looking for a way to do the same on 3.2.12.0 (the last released version).

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
ResNullius

Hi,

The example bellow supose to display a GUI with one menu item (as menu button), when you press that item, event is fired:

GUICreate("Test", 200, 100)

$MenuItem = GUICtrlCreateMenuItem("Menu Button", -1)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $MenuItem
            MsgBox(0, "", "Menu Button Pressed")
            If $MenuItem = 0 Then Exit
    EndSwitch
WEndoÝ÷ Ø­wv+_¢»ayø«²Ú'{ú®¢×¯+aÆ®¶­sduT7&VFRgV÷CµFW7BgV÷C²Â# ¢b33c´ÖVçTFVÒÒuT7G&Ä7&VFTÖVçTFVÒgV÷C´ÖVçR'WGFöâgV÷C²ÂÓ¢b33c´ÖVçTFVÓ"ÒuT7G&Ä7&VFTÖVçTFVÒgV÷C´ÖVçR'WGFöã"gV÷C²ÂÓ¤6öç6öÆUw&FRgV÷C²b33c´ÖVçTFVÓ¢gV÷C²fײb33c´ÖVçTFVÒfײ5$ÄbfײgV÷C²b33c´ÖVçTFVÓ#¢gV÷C²fײb33c´ÖVçTFVÓ"fײ5$Äb ¤uT6WE7FFR ¥vÆR¢7vF6uTvWD×6r¢66RÓ0¢W@¢66Rb33c´ÖVçTFVТ×6t&÷ÂgV÷C²gV÷C²ÂgV÷C´ÖVçR'WGFöâ&W76VBgV÷C²¢bb33c´ÖVçTFVÒÒFVâW@¢VæE7vF6¥tVæ@

The consoleWrite shows "0" for both menu IDs

When you stick another menu in there, then they get proper IDs

Share this post


Link to post
Share on other sites
MrCreatoR

When you stick another menu in there, then they get proper IDs

I am sorry, i am not understand, can you show me please a working example?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
MrCreatoR

Ok, here is the only solution that i can see right now:

GUICreate("Test", 200, 100)

$MenuItem = _GUICtrlCreateMenuItemEx("Menu Button", -1)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $MenuItem
            MsgBox(0, "", "Menu Button Pressed")
    EndSwitch
WEnd

Func _GUICtrlCreateMenuItemEx($sText, $iMenuID, $iMenuEntry=-1, $iMenuRadioItem=0)
    Local $nDummyMenu = GUICtrlCreateMenu("")
    Local $nDummyMenuItem = GUICtrlCreateMenuItem("", $nDummyMenu)
    
    Local $nMenuItem = GUICtrlCreateMenuItem($sText, $iMenuID, $iMenuEntry, $iMenuRadioItem)
    
    GUICtrlDelete($nDummyMenu)
    GUICtrlDelete($nDummyMenuItem)
    
    Return $nMenuItem
EndFunc

I don't know what was changed about this issue (the History does not mention it as far as i can see), but the problem is one of two: Or it is a bug in earlier to 3.2.12.0 versions, or it is a bug in this new version. I think the first one is true, but i hope that the second one and it will be fixed :)

Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
ResNullius

I am sorry, i am not understand, can you show me please a working example?

I was only trying to help pinpoint the bug, not imply a solution.

Using your example above:

GUICreate("Test", 200, 100)
GUICtrlCreateMenu("Menu")
$MenuItem = GUICtrlCreateMenuItem("Menu Button", -1)
$MenuItem2 = GUICtrlCreateMenuItem("Menu Button2", -1)
ConsoleWrite("$MenuItem: " & $MenuItem & @CRLF & "$MenuItem2: " & $MenuItem2 & @CRLF)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $MenuItem
            MsgBox(0, "", "Menu Button Pressed")
            If $MenuItem = 0 Then Exit
    EndSwitch
WEnd

By creating a menu first, then the ConsoleWrite()s show Gui Control lIDs for $menuitem1 & $menuitem2 as "4" and "5" respectively.

In the first (non-working example) both controls are ID "0" which is the standard return of GuiGetMsg() in the loop when nothing is happening; so the

Case $MenuItem

always returns true and fires the event.

GuiCtrlCreation probably should never create an ID of 0, so I'm inclined to think it's a new bug.

Share this post


Link to post
Share on other sites
kmeleon

GUICreate("Test", 200, 100)


$filemenu = GUICtrlCreateMenu("&File")
$MenuItem = GUICtrlCreateMenuItem("Open", $filemenu)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $MenuItem
            MsgBox(0, "", "Menu Button Pressed")
            If $MenuItem = 0 Then Exit
    EndSwitch
WEnd


Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.

Share this post


Link to post
Share on other sites
ResNullius

GUICreate("Test", 200, 100)


$filemenu = GUICtrlCreateMenu("&File")
$MenuItem = GUICtrlCreateMenuItem("Open", $filemenu)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $MenuItem
            MsgBox(0, "", "Menu Button Pressed")
            If $MenuItem = 0 Then Exit
    EndSwitch
WEnd
We know that works!

What we're talking about is creating a menuitem at the top level that acts just like a button.

You don't have to navigate down through the menu to access it.

Share this post


Link to post
Share on other sites
TalivanIBM

if you put only this

GUICreate("Test", 200, 100)

$MenuItem = _GUICtrlCreateMenuItemEx("Menu Button", -1)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $MenuItem
            MsgBox(0, "", "Menu Button Pressed")
    EndSwitch
WEnd

Func _GUICtrlCreateMenuItemEx($sText, $iMenuID, $iMenuEntry=-1, $iMenuRadioItem=0)
    Local $nDummyMenu = GUICtrlCreateMenu("") ;  <==============
   
    Local $nMenuItem = GUICtrlCreateMenuItem($sText, $iMenuID, $iMenuEntry, $iMenuRadioItem)
   
    GUICtrlDelete($nDummyMenu)                    ;   <===============
   
    Return $nMenuItem
EndFunc

i have version 3.2.12.1 in some of my scripts i had this problem.

Share this post


Link to post
Share on other sites
PsaltyDS

if you put only this

GUICreate("Test", 200, 100)

$MenuItem = _GUICtrlCreateMenuItemEx("Menu Button", -1)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $MenuItem
            MsgBox(0, "", "Menu Button Pressed")
    EndSwitch
WEnd

Func _GUICtrlCreateMenuItemEx($sText, $iMenuID, $iMenuEntry=-1, $iMenuRadioItem=0)
    Local $nDummyMenu = GUICtrlCreateMenu("");  <==============
   
    Local $nMenuItem = GUICtrlCreateMenuItem($sText, $iMenuID, $iMenuEntry, $iMenuRadioItem)
   
    GUICtrlDelete($nDummyMenu)                   ;   <===============
   
    Return $nMenuItem
EndFunc

i have version 3.2.12.1 in some of my scripts i had this problem.

I don't get it. Why not just this?
GUICreate("Test", 400, 200)

$Menu = GUICtrlCreateMenu("")
$MenuItem = GUICtrlCreateMenuItem("Menu Button", -1)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $MenuItem
            MsgBox(0, "", "Menu Button Pressed")
    EndSwitch
WEnd

What did you revive this old topic for? What did you want it to do?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
TalivanIBM

I don't get it. Why not just this?

GUICreate("Test", 400, 200)
 
 $Menu = GUICtrlCreateMenu("")
 $MenuItem = GUICtrlCreateMenuItem("Menu Button", -1)
 
 GUISetState()
 
 While 1
     Switch GUIGetMsg()
         Case -3
             Exit
         Case $MenuItem
             MsgBox(0, "", "Menu Button Pressed")
     EndSwitch
 WEnd

What did you revive this old topic for? What did you want it to do?

:)

In the title don't put solved and seems to me there is no final reply, excuse me.

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  

×