Jump to content

AddImageToMenu


Scopinho
 Share

Recommended Posts

Another DLLCALL.... ENJOY!

#include <GUIConstants.au3>

Global Const $MF_BYCOMMAND = 0x00000000
Global Const $MF_BYPOSITION = 0x00000400
Global Const $IMAGE_BITMAP = 0
Global Const $LR_LOADMAP3DCOLORS = 0x00001000
Global Const $LR_LOADFROMFILE = 0x0010

GUICreate("AddImageToMenu",100,100,-1,-1,$WS_OVERLAPPEDWINDOW)

$trackmenu = GuiCtrlCreateContextMenu()

GuiCtrlCreateMenuItem("Item 1",$trackmenu)
GuiCtrlCreateMenuItem("Item 2",$trackmenu)
GuiCtrlCreateMenuItem("Item 3",$trackmenu)

AddImageToMenu($trackmenu, $MF_BYPOSITION, 1, ".\AddImageToMenu.bmp")

GUISetState()

While GUIGetMsg() <> -3
WEnd

Func AddImageToMenu($ParentMenu, $IndexType, $MenuIndex, $BitmapMenu)
    $hBmpMenu = DllCall("user32.dll", "hwnd", "LoadImage", "hwnd", 0, _
                                                           "str", $BitmapMenu, _
                                                           "int", $IMAGE_BITMAP, _
                                                           "int", 0, _
                                                           "int", 0, _
                                                           "int", BitOR($LR_LOADFROMFILE, $LR_LOADMAP3DCOLORS))
    $hBmpMenu = $hBmpMenu[0]
    DllCall("user32.dll", "int", "SetMenuItemBitmaps", "hwnd", GUICtrlGetHandle($ParentMenu), _
                                                       "int",  $MenuIndex, _
                                                       "int",  $IndexType, _
                                                       "hwnd", $hBmpMenu, _
                                                       "hwnd", $hBmpMenu)
EndFunc

AddImageToMenu.au3

AddImageToMenu.bmp

Link to comment
Share on other sites

  • Moderators

Nice one Scopinho... tested in a regular Menu and 'Context' :lmao: ... Good work!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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