Jump to content

Search the Community

Showing results for tags 'tray menu icons'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Here's a code sample showing how I add icon images (in this simple case just colored blocks) to the tray items. It should be noted that I used solid blocks to simplify the example, but anything can be set as the bitmap (and in any size) using the appropriate code to generate a bitmap to feed into the _GUICtrlMenu_SetItemBmp function. #NoTrayIcon #include <TrayConstants.au3> #include <ColorConstants.au3> #include <GuiMenu.au3> #include <WinAPIGdi.au3> Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. Global $idTrayText, $idUDFText Example() Func Example() Local $iBmpSize = 32 TrayCreateItem("About") TrayItemSetOnEvent(-1, "About") _TrayItemSetBmp(-1, $iBmpSize, $COLOR_BLUE) TrayCreateItem("") ; Create a separator line. $idTrayText = TrayCreateItem("Read Text with TrayItemGetText") TrayItemSetOnEvent(-1, "TrayText") _TrayItemSetBmp(-1, $iBmpSize, $COLOR_GREEN) $idUDFText = TrayCreateItem("Read Text with _GUICtrlMenu_GetItemText") TrayItemSetOnEvent(-1, "UDFText") _TrayItemSetBmp(-1, $iBmpSize, $COLOR_ORANGE) TrayCreateItem("") ; Create a separator line. TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "ExitScript") _TrayItemSetBmp(-1, $iBmpSize, $COLOR_RED) TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. While 1 Sleep(100) ; An idle loop. WEnd EndFunc ;==>Example Func About() MsgBox(0, "Tray Menu Item Image Icons", "AutoIt tray menu item image icons example.") EndFunc ;==>About Func TrayText() ConsoleWrite("TrayText: " & TrayItemGetText($idTrayText) & @CRLF) EndFunc ;==>TrayText Func UDFText() Local $hMenu = TrayItemGetHandle(0) ConsoleWrite("UDFText: " & _GUICtrlMenu_GetItemText($hMenu, $idUDFText, False) & @CRLF) EndFunc ;==>UDFText Func ExitScript() Exit EndFunc ;==>ExitScript Func _TrayItemSetBmp($idControl, $iBmpSize, $iColor, $bRGB = 1) ; Adds an image (bitmap) to a tray menu item - solid block of color ; $idControl = the control ID of the menu item (or -1 for last created item) ; $iBmpSize = the size of the Bmp (height & width are the same) ; $iColor = the color of the bitmap, stated in RGB ; $bRGB [optional] = if True converts to COLOREF (0x00bbggrr) Local $hMenu = TrayItemGetHandle(0) ; handle for standard tray menu If $idControl = -1 Then $idControl = _GUICtrlMenu_GetItemID($hMenu, _GUICtrlMenu_GetItemCount($hMenu) - 1, True) ; last item in menu _GUICtrlMenu_SetItemBmp($hMenu, $idControl, _WinAPI_CreateSolidBitmap(WinGetHandle(AutoItWinGetTitle()), $iColor, $iBmpSize, $iBmpSize, $bRGB), False) EndFunc ;==>_TrayItemSetBmp This example also illustrates an odd quirk. Once you add an image to a tray menu item using the _GUICtrlMenu_SetItemBmp function, you can no longer use TrayItemGetText or TrayItemSetText on that item. Sometimes TrayItemGetText returns gibberish (like it's reading the wrong portion of memory) and sometimes it returns nothing. And TrayItemSetText doesn't change the item text. However, the functions _GUICtrlMenu_GetItemText and _GUICtrlMenuSetItemText work just fine as replacements. Any ideas from the developers (or anyone else) as to why adding an image messes up the TrayItemGetText and TrayItemSetText functions? Maybe something for the Bug Tracker?
×
×
  • Create New...