How can I insert a file icon in a menu item?
The file icon probably needs to be converted to BMP. How does it work?
The file icon probably needs to be converted to BMP. How does it work?
Code:
#COMPILE EXE #DIM ALL %UNICODE = 1 #INCLUDE "Win32api.inc" GLOBAL hDlg, hMenu, hMenuFile AS DWORD FUNCTION PBMAIN() DIALOG NEW PIXELS, 0, "Icon in Menu",300,300,250,150, %WS_OVERLAPPEDWINDOW TO hDlg AddMenu("C:\Windows\Explorer.exe") 'AddMenu(exe.path$ + "test.docx") DIALOG SHOW MODAL hDlg END FUNCTION SUB AddMenu((pFile AS WSTRINGZ) LOCAL hh AS DWORD LOCAL fi AS SHFILEINFO IF ISFILE(pFile) THEN MENU NEW BAR TO hMenu MENU NEW POPUP TO hMenuFile MENU ADD POPUP, hMenu, "&File", hMenuFile, %MF_ENABLED MENU ADD STRING, hMenuFile, pFile, 100, %MF_ENABLED MENU ATTACH hMenu, hDlg hh = SHGetFileInfo (pFile, 0, fi, LEN(fi), %SHGFI_SMALLICON) [B][COLOR=#FF0000] SetMenuItemBitmaps hMenuFile, 0, %MF_ByPosition, fi.hIcon, fi.hIcon[/COLOR][/B] END IF END SUB
Comment