This is a known problem.
Replace
Return _WinAPI_CallWindowProc($g_LV_OldWndProc, $hWnd, $uMsg, $wParam, $lParam)
with
Return DllCall("user32.dll", "lresult", "CallWindowProc", "ptr", $g_LV_OldWndProc, "hwnd", $hWnd, "uint", $uMsg, "wparam", $wParam, "lparam", $lParam)[0]
You should use
_WinAPI_SetWindowSubclass()
and related functions for subclassing.
here is my script-stuff to create ownerdrawn menuitems with icons and colors.
It uses GUIRegisterMsg() and WM_DRAWITEM / WM_MEASUREITEM - messages proceeding.
Holger
Update 06.05.2008: !!! Warning: Script breaking !!! Please change the following commands to: _TrayCreateItem(Text, ...) _TrayCreateMenu(Text , ...)
- Fixed: some old values (thanks to aGorilla) - Fixed: ..SetText() functions (thanks to MrCreatoR) - Added the following commands: _SetMenuIconBkGrdColor(Color) ; set icon background gradient color _SetTrayIconBkGrdColor(Color) ; set icon background gradient color
New sidebar menu commands: _CreateSideMenu(MenuID) ; returns a SideMenuID/index _DeleteSideMenu(SideMenuID) ; delete a menu sidebar _SetSideMenuText(SideMenuID, Text) ; set a text for the sidebar _SetSideMenuColor(SideMenuID, Color) ; set text color _SetSideMenuBkColor(SideMenuID, Color) ; set text background color _SetSideMenuBkGradColor(SideMenuID, Color) ; set text background gradient color _SetSideMenuImage(SideMenuID, Bitmapfile [, Resourcename/number [, Expand/Compress Bitmap]])
Just take a look into the samples how to use them!
At the moment there are some known issues: - missing 64bit compatibility (already in progress, to fully work with "AutoIt3_x64.exe") - moving the mouse cursor on the sidebar menu image/text also changes the current menu item selection - for sidebar menu image only bitmaps are supported at the moment (min.8bpp)
Update 23.03.2008: !!! Warning: Please update all your scripts and add after _TrayIconCreate() the command _TrayIconSetState() - otherwise you will not see any tray icons!!! Also update your icon numbers like for GUI icons - Fixed: some things (thanks to nickston) - Changed: _TrayIconCreate() do not show automatically the icon - Changed: icon behaviour now more similar to GUI icons (I hope) - Added: command.txt - Removed: unicode macro
History:
CODEUpdate 21.03.2008: - Changed: dynamic array sizing of the saved menu items - Added: _TrayDeleteItem(menuID), _GUICtrlODMenuItemDelete($nID) - please delete menu (items) with these commands - Added: _TrayIconSetState() modes 4 and 8 for flashing and flashstopping of tray icons - Added: _SetFlashTimeOut([timeOut]) to set the flash timeout - Added: OnEvent sample
Update 23.02.2008: - Fixed: GDI object overload while using bold font
Update 22.02.2008: - Added: _TrayItemSetSelIcon(ItemID, IconFile, IconID) - set the icon if the item is selected - Added: _GUICtrlODMenuItemSetIcon(ItemID, IconFile, IconID) - set the icon of the item - Added: _GUICtrlODMenuItemSetSelIcon(ItemID, IconFile, IconID) - set the icon if the item is selected - Added: "ModernMenuRaw.au3" which only includes the unknown constants, should better work with 'Au3Check' now
Update 12.01.2008-2: - Fixed: Missing underscore in "CreateMenuFontByName"-function (Font fallback function) (thanks to MsCreatoR and GEOSoft). - Changed: If a menuitem is disabled then the rect only is showing around the item - Added: Underscore in menutext only showing when pressing "Alt"-key
Update 12.01.2008: - Changed: 'local' Dll calls to global DllOpen to speedup (some virusscanners sometimes slowdown the process cause of opening these Dll's again and again) - Added: Using of @Tab for accelerator showing/drawing
Update 07.12.2007: - Changed: all stuff in only 1 ZIP file - Fixed: now works with 3.2.10.0 and 3.2.8.1
Update 03.08.2007 - Fixed: error in _TrayIconDelete() and new creation - Added: additional parameter to _TrayIconCreate(ToolTip, IconFile, IconID, Callback, Msg, hIcon) to use existing icon handles - Added: sample_Win2Tray: 'moves' all minimized windows to the tray
Update 28.07.2007 - Fixed: wrong call of function CreateFont() - Thanks to SleepyExtreme for info - Changed: included samples to demonstrate using of icon clicks
Update 21.07.2007 - added bold item support - limited to menuitems only, menus are not supported
Update 17.07.2007: - now you can also menu icons for the tray - added commands for Tray: _TrayIconCreate() _TrayCreateMenu() _TrayCreateItem() _TrayItemSetIcon() _TrayIconSetState() _TrayTip()
So you can have more than 1 tray icon for 1 Autoit3-script.
Update 01.07.2007: - now works with unicode (3.2.4.9) - new command: _GUICtrlODMenuItemSetText(ControlID, NewText)
Update 21.08.2006: - delete 1 line in libs to work with current release 3.2.0.X (error: cannot redeclare constant...) - Thanks to Javascript_Freek for info
Update 02.02.2006: - added Checked-state for normal menu items and radio menu items - added a like ModernMenuLib-script for easier create/use these menustuff (see sample in the ModernMenuLib-folder)