name15 Posted January 24, 2010 Share Posted January 24, 2010 how to add ico or image to item in menu Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 25, 2010 Share Posted January 25, 2010 See the help file example under: _GuiCtrlMenu_SetItemBmp() Note the menu is created with the UDF also. You are asking for trouble if you use the native GuiCtrlCreateMenu() and then modify it with the UDF functions. 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 Link to comment Share on other sites More sharing options...
name15 Posted January 26, 2010 Author Share Posted January 26, 2010 that function didn't work Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 that function didn't work I don't think you used it properly then. Please open your help file and turn to _GUICtrlMenu_SetItemBmp. Now boys and girls, would someone like to read the description of this function? Sets the bitmap displayed for the itemGood. Now, what about the parameters? $hMenuHandle of the menu$iItemIdentifier or position of the menu item$hBmpHandle to the item bitmap$fByPos[optional] Menu identifier flag: True - $iItem is a zero based item position False - $iItem is a menu item identifier Right, so... Does that mean we should be using the GUICtrlCreateMenu or the _GUICtrlMenu_CreateMenu function? We should be using the latter! Yes, if we don't, then we'll run into some problems later - it's not owner drawn is it... So.. Did you take a look at the example? NO?? Well, that's not doing research is it. Let's see now: expandcollapse popup#include <GuiMenu.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) Global $iMemo _Main() Func _Main() Local $hGUI, $hFile, $hEdit, $hHelp, $hMain Local Enum $idNew = 1000, $idOpen, $idSave, $idExit, $idCut, $idCopy, $idPaste, $idAbout ; Create GUI $hGUI = GUICreate("Menu", 400, 300) ; Create File menu $hFile = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hFile, 0, "&New", $idNew) _GUICtrlMenu_InsertMenuItem ($hFile, 1, "&Open", $idOpen) _GUICtrlMenu_InsertMenuItem ($hFile, 2, "&Save", $idSave) _GUICtrlMenu_InsertMenuItem ($hFile, 3, "", 0) _GUICtrlMenu_InsertMenuItem ($hFile, 4, "E&xit", $idExit) ; Create Edit menu $hEdit = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hEdit, 0, "&Cut", $idCut) _GUICtrlMenu_InsertMenuItem ($hEdit, 1, "C&opy", $idCopy) _GUICtrlMenu_InsertMenuItem ($hEdit, 2, "&Paste", $idPaste) ; Create Help menu $hHelp = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hHelp, 0, "&About", $idAbout) ; Create Main menu $hMain = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hMain, 0, "&File", 0, $hFile) _GUICtrlMenu_InsertMenuItem ($hMain, 1, "&Edit", 0, $hEdit) _GUICtrlMenu_InsertMenuItem ($hMain, 2, "&Help", 0, $hHelp) ; Set window menu _GUICtrlMenu_SetMenu ($hGUI, $hMain) ; Create memo control $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() ; Set New menu item to have a bitmap _GUICtrlMenu_SetItemBmp ($hFile, 0, _WinAPI_CreateSolidBitmap ($hGUI, 0xFF0000, 11, 11)) MemoWrite("Item bitmap handle: 0x" & Hex(_GUICtrlMenu_GetItemBmp ($hFile, 0))) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main ; Write message to memo Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWriteNow run the example and see what happens. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
name15 Posted January 26, 2010 Author Share Posted January 26, 2010 (edited) you writ but i want add icon to menu not color expandcollapse popup#include <GuiMenu.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) Global $iMemo _Main() Func _Main() Local $hGUI, $hFile, $hEdit, $hHelp, $hMain Local Enum $idNew = 1000, $idOpen, $idSave, $idExit, $idCut, $idCopy, $idPaste, $idAbout ; Create GUI $hGUI = GUICreate("Menu", 400, 300) ; Create File menu $hFile = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hFile, 0, "&New", $idNew) _GUICtrlMenu_InsertMenuItem ($hFile, 1, "&Open", $idOpen) _GUICtrlMenu_InsertMenuItem ($hFile, 2, "&Save", $idSave) _GUICtrlMenu_InsertMenuItem ($hFile, 3, "", 0) _GUICtrlMenu_InsertMenuItem ($hFile, 4, "E&xit", $idExit) ; Create Edit menu $hEdit = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hEdit, 0, "&Cut", $idCut) _GUICtrlMenu_InsertMenuItem ($hEdit, 1, "C&opy", $idCopy) _GUICtrlMenu_InsertMenuItem ($hEdit, 2, "&Paste", $idPaste) ; Create Help menu $hHelp = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hHelp, 0, "&About", $idAbout) ; Create Main menu $hMain = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hMain, 0, "&File", 0, $hFile) _GUICtrlMenu_InsertMenuItem ($hMain, 1, "&Edit", 0, $hEdit) _GUICtrlMenu_InsertMenuItem ($hMain, 2, "&Help", 0, $hHelp) ; Set window menu _GUICtrlMenu_SetMenu ($hGUI, $hMain) ; Create memo control $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() ; Set New menu item to have a bitmap _GUICtrlMenu_SetItemBmp ($hFile, 0, "C:\1.ico") MemoWrite("Item bitmap handle: 0x" & Hex(_GUICtrlMenu_GetItemBmp ($hFile, 0))) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main ; Write message to memo Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrites Edited January 26, 2010 by name15 Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 Try out Holgers ModernMenu.au3 UDF - http://www.autoitscript.com/forum/index.php?showtopic=20967 Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now