Jump to content

About menu item


Recommended Posts

Hi I've been using autoit for 3 weeks and tried to avoid asking in the forum since lot of my question has been answered using search :) but lately I'm having a problem with my program so here it is.

I am having a problem making a recent file menu my question is

Is it possible to change or set the text of GUICtrlCreateMenuitem?

thanks in advance.

Link to comment
Share on other sites

Hi I've been using autoit for 3 weeks and tried to avoid asking in the forum since lot of my question has been answered using search :) but lately I'm having a problem with my program so here it is.

I am having a problem making a recent file menu my question is

Is it possible to change or set the text of GUICtrlCreateMenuitem?

thanks in advance.

$filemenu = GUICtrlCreateMenu ("Menu Name Here")

[font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
Link to comment
Share on other sites

Hi I've been using autoit for 3 weeks and tried to avoid asking in the forum since lot of my question has been answered using search :) but lately I'm having a problem with my program so here it is.

I am having a problem making a recent file menu my question is

Is it possible to change or set the text of GUICtrlCreateMenuitem?

thanks in advance.

Hi there

Maybe if you use GUICtrlSetData to change the title

Cheers

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Link to comment
Share on other sites

Thanks for your fast reply

@ Zedna - I think guictrlsetdata doesn't work for guictrlmenuitem but the guictrldelete does but my other problem is when I e replace the item the new menu item doesn't work.

Thanks anyway have to search some example again

Link to comment
Share on other sites

Hi I've been using autoit for 3 weeks and tried to avoid asking in the forum since lot of my question has been answered using search :) but lately I'm having a problem with my program so here it is.

I am having a problem making a recent file menu my question is

Is it possible to change or set the text of GUICtrlCreateMenuitem?

thanks in advance.

Welcome to the forum. Here is an example of how to change the text of a menu item using Auto3Lib:

#include <A3LMenu.au3>

Global $hGUI, $hFile, $hHelp
Global Enum $idNew=1000, $idOpen , $idSave, $idRecent, $idExit, $idAbout

$hGUI = GUICreate("Menu Test", 400, 300)

; Create File menu
$hFile = _Menu_CreateMenu()
_Menu_AddMenuItem($hFile, "&New"    , $idNew   )
_Menu_AddMenuItem($hFile, "&Open"   , $idOpen  )
_Menu_AddMenuItem($hFile, "&Save"   , $idSave  )
_Menu_AddMenuItem($hFile, ""        , 0        )
_Menu_AddMenuItem($hFile, "(Recent)", $idRecent)
_Menu_AddMenuItem($hFile, ""        , 0        )
_Menu_AddMenuItem($hFile, "E&xit"   , $idExit  )

; Create Help menu
$hHelp = _Menu_CreateMenu()
_Menu_AddMenuItem($hHelp, "&About", $idAbout)

; Create Main menu
$hMain = _Menu_CreateMenu()
_Menu_AddMenuItem($hMain, "&File", 0, $hFile)
_Menu_AddMenuItem($hMain, "&Help", 0, $hHelp)

; Set the window menu
_Menu_SetMenu($hGUI, $hMain)

GUISetState()

; Register command handler and wait for exit
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
do
until GUIGetMsg() = $GUI_EVENT_CLOSE

; Handle menu commands
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
  Switch _Lib_LoWord($iwParam)
    case $idNew
      _Lib_ShowMsg("New"  )
      _Menu_SetItemText($hFile, 4, "File 123")
    case $idOpen
      _Lib_ShowMsg("Open" )
      _Menu_SetItemText($hFile, 4, "File 456")
    case $idSave
      _Lib_ShowMsg("Save" )
    case $idRecent
      _Lib_ShowMsg(_Menu_GetItemText($hFile, 4))
    case $idExit
      Exit
    case $idAbout
      _Lib_ShowMsg("About")
  EndSwitch
  Return $GUI_RUNDEFMSG
EndFunc
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Thanks for your fast reply

@ Zedna - I think guictrlsetdata doesn't work for guictrlmenuitem but the guictrldelete does but my other problem is when I e replace the item the new menu item doesn't work.

Thanks anyway have to search some example again

you might have to create a Case again, if you want you can show us some example of your script , in order to help you

Tried to avoid asking in the forum

:)
Link to comment
Share on other sites

Welcome to the forum. Here is an example of how to change the text of a menu item using Auto3Lib:

#include <A3LMenu.au3>

Global $hGUI, $hFile, $hHelp
Global Enum $idNew=1000, $idOpen , $idSave, $idRecent, $idExit, $idAbout

$hGUI = GUICreate("Menu Test", 400, 300)

; Create File menu
$hFile = _Menu_CreateMenu()
_Menu_AddMenuItem($hFile, "&New"    , $idNew   )
_Menu_AddMenuItem($hFile, "&Open"   , $idOpen  )
_Menu_AddMenuItem($hFile, "&Save"   , $idSave  )
_Menu_AddMenuItem($hFile, ""        , 0        )
_Menu_AddMenuItem($hFile, "(Recent)", $idRecent)
_Menu_AddMenuItem($hFile, ""        , 0        )
_Menu_AddMenuItem($hFile, "E&xit"   , $idExit  )

; Create Help menu
$hHelp = _Menu_CreateMenu()
_Menu_AddMenuItem($hHelp, "&About", $idAbout)

; Create Main menu
$hMain = _Menu_CreateMenu()
_Menu_AddMenuItem($hMain, "&File", 0, $hFile)
_Menu_AddMenuItem($hMain, "&Help", 0, $hHelp)

; Set the window menu
_Menu_SetMenu($hGUI, $hMain)

GUISetState()

; Register command handler and wait for exit
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
do
until GUIGetMsg() = $GUI_EVENT_CLOSE

; Handle menu commands
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
  Switch _Lib_LoWord($iwParam)
    case $idNew
      _Lib_ShowMsg("New"  )
      _Menu_SetItemText($hFile, 4, "File 123")
    case $idOpen
      _Lib_ShowMsg("Open" )
      _Menu_SetItemText($hFile, 4, "File 456")
    case $idSave
      _Lib_ShowMsg("Save" )
    case $idRecent
      _Lib_ShowMsg(_Menu_GetItemText($hFile, 4))
    case $idExit
      Exit
    case $idAbout
      _Lib_ShowMsg("About")
  EndSwitch
  Return $GUI_RUNDEFMSG
EndFunc

well Au3Lib seems to be the best solution, thanks for Au3Lib it helps a lot!!

Edited by c4nm7
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...