Jump to content

Creating a menu based on data from INI


Yashied
 Share

Recommended Posts

Note that icons will only work in Windows Vista and later. Also need a >WinAPIEx UDF library.

 

post_img_071.png

Menu.ini

[Menu]
Open=File>Open
Save=File>Save
SaveAs=File>Save As...
Copy=Edit>Copy
Paste=Edit>Paste
Separator=*
Skin=Preferences>Interface>Skin
Size=Preferences>Interface>Size
Color=Preferences>Interface>Color
Separator=Preferences>Interface>*
Expert=Preferences>Interface>Advanced...
Miscellaneous=Preferences>Miscellaneous...
Separator=*
Exit=Exit

[Icon]
Open=shell32.dll,45
Save=shell32.dll,258
SaveAs=shell32.dll,68
Copy=shell32.dll,134
Paste=shell32.dll,260
Skin=shell32.dll,303
Size=shell32.dll,240
Color=mspaint.exe,0
Expert=shell32.dll,300
Miscellaneous=shell32.dll,21
Exit=shell32.dll,131

Menu.7z

Previous downloads: 617

Menu.7z

Edited by Yashied
Link to comment
Share on other sites

Wow! You never cease to amaze me. This is going in the Function Folder.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • 3 weeks later...

So I was quite inspired by your TrayMenu with Icons from ico/exe files that I decided to have a go at creating a Function that could convert an Image File and then display in the TrayMenu. This is how I came about creating _GUICtrlMenu_SetItemImage() using the Forum as a basis to learn. :)

Note: I used this post >> from UEZ as a basis for creating the Function!

Of course I know it can be improved, especially tidying up the resources, but for now it works!

#include <GDIPlus.au3>
#include <GUIMenu.au3>

Opt('TrayMenuMode', 3)

_GDIPlus_Startup()

Example()

Func Example()
    Local $hGUI = GUICreate('')

    Local $iSettingsItem = TrayCreateMenu('Settings')
    _GUICtrlMenu_SetItemBmp(TrayItemGetHandle(0), 0, _WinAPI_CreateSolidBitmap($hGUI, 0xFF00FF, 15, 15)) ; Set Image to Settings.

    Local $iDisplayItem = TrayCreateItem('Display', $iSettingsItem)
    Local $hImage_1 = _GUICtrlMenu_SetItemImage(@ScriptDir & 'Example.png', 0, $iSettingsItem) ; Set Image to Sub-Menu in Settings under Display.

    TrayCreateItem('Printer', $iSettingsItem)
    Local $hImage_2 = _GUICtrlMenu_SetItemImage(@ScriptDir & 'Example.png', 1, $iSettingsItem) ; Set Image to Sub-Menu in Settings under Printer.

    TrayCreateItem('Delete')
    Local $hImage_3 = _GUICtrlMenu_SetItemImage(@ScriptDir & 'Example.png', 1) ; Set Image to Delete.

    TrayCreateItem('')
    TrayCreateItem('About')
    TrayCreateItem('')
    Local $iExitItem = TrayCreateItem('Exit')

    TraySetState()

    While 1
        Switch TrayGetMsg()
            Case $iExitItem
                ExitLoop

            Case $iDisplayItem
                MsgBox(0, 'Display/About', 'Display Or About Was Clicked!')

        EndSwitch
        Sleep(10)
    WEnd
    _WinAPI_DeleteObject($hImage_1) ; <<<< Delete Icon Image.
    _WinAPI_DeleteObject($hImage_2) ; <<<< Delete Icon Image.
    _WinAPI_DeleteObject($hImage_3) ; <<<< Delete Icon Image.

    GUIDelete($hGUI)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Func _GUICtrlMenu_SetItemImage($hImageFile, $iIndex, $hWnd = 0, $iWidth = 35, $iHeight = 35) ; Set Image to Tray/GUI Menu.
    $hWnd = TrayItemGetHandle($hWnd)
    Local $hImage = _GDIPlus_BitmapCreateFromFile($hImageFile)
    Local $iImageWidth = _GDIPlus_ImageGetWidth($hImage)
    Local $iImageHeight = _GDIPlus_ImageGetHeight($hImage)
    If ($iImageWidth < 0) Or ($iImageHeight < 0) Then
        Return SetError(1, 0, 0)
    EndIf
    If $iImageWidth < $iImageHeight Then
        $iImageWidth = $iWidth * $iImageWidth / $iImageHeight
        $iImageHeight = $iHeight
    Else
        $iImageHeight = $iHeight * $iImageHeight / $iImageWidth
        $iImageWidth = $iWidth
    EndIf
    Local $aResult = DllCall($ghGDIPDll, 'uint', 'GdipCreateBitmapFromScan0', 'int', $iWidth, 'int', $iHeight, 'int', 0, 'int', 0x0026200A, 'ptr', 0, 'int*', 0)
    Local $hBitmap = $aResult[6]
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iWidth, $iHeight)
    Local $hIcon = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GUICtrlMenu_SetItemBmp($hWnd, $iIndex, $hIcon)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    Return SetError(0, 0, $hIcon)
EndFunc   ;==>_GUICtrlMenu_SetItemImage
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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