Jump to content

[SOLVED] How to set icons for ListBox?


MrCreatoR
 Share

Recommended Posts

Hi,

I need to set simple icon (from file) for listbox items (as in ListView items).

There is solution for ComboBox by Holger, but is it possible to do the same for the ListBox control?

P.S

I tried to play with the combo example, but with no success :P.

Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Hi,

I need to set simple icon (from file) for listbox items (as in ListView items).

There is solution for ComboBox by Holger, but is it possible to do the same for the ListBox control?

P.S

I tried to play with the combo example, but with no success :P.

Why don't you want to use a listview?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Why don't you want to use a listview?

Well, i want, but the current code is too big (it's also old :P ), and i will have to change a lot of things to work with ListView, i just thought that it will be easier just to set an icon for listbox items. Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Well, i want, but the current code is too big (it's also old :P ), and i will have to change a lot of things to work with ListView, i just thought that it will be easier just to set an icon for listbox items.

I see.

Well I suppose what you have to do is react to WM_PAINT, get the hdc for the item rect from the struct that must be given in one of the parameters and draw on it. But I don't know how you draw an icon with GDI. Maybe this post by smashly would help, it looks quite clever to me.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I see.

Well I suppose what you have to do is react to WM_PAINT, get the hdc for the item rect from the struct that must be given in one of the parameters and draw on it. But I don't know how you draw an icon with GDI. Maybe this post by smashly would help, it looks quite clever to me.

I haven't studied it carefully, but when you receive the WM_DRAWITEM message and examine the DRAWITEM structure, would the itemdata member tell you which item in the listbox you were dealing with? (I assume the itemdata is the text displayed in the listbox for the item being redrawn.)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I haven't studied it carefully, but when you receive the WM_DRAWITEM message and examine the DRAWITEM structure, would the itemdata member tell you which item in the listbox you were dealing with? (I assume the itemdata is the text displayed in the listbox for the item being redrawn.)

I am not sure, but as far as i checked the WM_DRAWITEM does not called when list items created :P

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

I am not sure, but as far as i checked the WM_DRAWITEM does not called when list items created :P

The list box has to have the correct style.

Owner-drawn List Boxes

An application can create an owner-drawn list box to take responsibility for painting list items. The parent window or dialog box of an owner-drawn list box (its owner) receives WM_DRAWITEM messages when a portion of the list box needs to be painted. An owner-drawn list box can list information other than, or in addition to, text strings.

The owner of an owner-drawn list box must process the WM_DRAWITEM message. This message is sent whenever a portion of the list box must be redrawn. The owner may need to process other messages, depending on the styles specified for the list box.

An application can create an owner-drawn list box by specifying the LBS_OWNERDRAWFIXED or LBS_OWNERDRAWVARIABLE style. If all list items in the list box are the same height, such as strings or icons, an application can use the LBS_OWNERDRAWFIXED style. If list items are of varying height, bitmaps of different size, for example, an application can use the LBS_OWNERDRAWVARIABLE style.

The owner of an owner-drawn list box can process a WM_MEASUREITEM message to specify the dimensions of list items. If the application creates the list box by using the LBS_OWNERDRAWFIXED style, the system sends the WM_MEASUREITEM message only once. The dimensions specified by the owner are used for all list items. If the LBS_OWNERDRAWVARIABLE style is used, the system sends a WM_MEASUREITEM message for each list item added to the list box. The owner can determine or set the height of a list item at any time by using the LB_GETITEMHEIGHT and LB_SETITEMHEIGHT messages, respectively.

If the information displayed in an owner-drawn list box includes text, an application can keep track of the text for each list item by specifying the LBS_HASSTRINGS style. List boxes with the LBS_SORT style are sorted based on this text. If a list box is sorted, but is not of the LBS_HASSTRINGS style, the owner must process the WM_COMPAREITEM message.

In an owner-drawn list box, the owner must keep track of list items containing information other than or in addition to text. One convenient way to do this is to save the handle to the information as item data using the LB_SETITEMDATA message. To free data objects associated with items in a list box, the owner can process the WM_DELETEITEM message.

For an example of an owner-drawn list box, see Creating an Owner-drawn List Box.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

MrCreatoR

Quick and rough example:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>

Global Const $ODT_LISTBOX = 2
Global Const $ODA_DRAWENTIRE = 0x1
Global Const $ODA_SELECT = 0x2
Global Const $ODS_SELECTED = 0x1

$hGUI = GUICreate("Test GUI", 300, 200)

$hListBox = _GUICtrlListBox_Create($hGUI, "", 10, 10, 280, 180, BitOR($LBS_HASSTRINGS, $LBS_OWNERDRAWFIXED))

For $i = 1 To 10
    _GUICtrlListBox_AddString($hListBox, "String " & $i)
Next

_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile("c:\Program Files\AutoIt3\Examples\GUI\Advanced\Images\Blue.bmp")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hListBox)

GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM")

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()

Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam)
    Local $tagDRAWITEMSTRUCT, $cID, $itmID, $itmAction, $itmState, $hItm, $hDC, $iBrushColor, $hBrush, $hBrushOld
    
    $tagDRAWITEMSTRUCT = DllStructCreate("uint cType;uint cID;uint itmID;uint itmAction;uint itmState;" & _
                                         "hwnd hItm;hwnd hDC;int itmRect[4];dword itmData", $lParam)
    If DllStructGetData($tagDRAWITEMSTRUCT, "cType") <> $ODT_LISTBOX Then Return $GUI_RUNDEFMSG
    
    $cID = DllStructGetData($tagDRAWITEMSTRUCT, "cID")
    $itmID = DllStructGetData($tagDRAWITEMSTRUCT, "itmID")
    $itmAction = DllStructGetData($tagDRAWITEMSTRUCT, "itmAction")
    $itmState = DllStructGetData($tagDRAWITEMSTRUCT, "itmState")
    $hItm = DllStructGetData($tagDRAWITEMSTRUCT, "hItm")
    $hDC = DllStructGetData($tagDRAWITEMSTRUCT, "hDC")
    
    Switch $itmAction
        Case $ODA_DRAWENTIRE, $ODA_SELECT
            
            If $itmState = $ODS_SELECTED Then
                $iBrushColor = 0x6495ED
            Else
                $iBrushColor = 0x66CDAA
            EndIf
            
            $hBrush = _WinAPI_CreateSolidBrush($iBrushColor)
            $hBrushOld = _WinAPI_SelectObject($hDC, $hBrush)
            
            DLLCall("user32.dll","int","FillRect", _
                                        "hwnd", $hDC, _
                                        "ptr", DllStructGetPtr($tagDRAWITEMSTRUCT, "itmRect"), _
                                        "hwnd", $hBrush)
            
            _WinAPI_SelectObject($hDC, $hBrushOld)
            _WinAPI_DeleteObject($hBrush)
            
            DLLCall("gdi32.dll","int","SetBkMode", "hwnd", $hDC, "int", 1)
            
            Local $tBuffer = DllStructCreate("char[256]")
            DllCall("user32.dll", "int", "SendMessage", _
                                            "hwnd", $hItm, _
                                            "int", $LB_GETTEXT, _
                                            "int", $itmID, _
                                            "ptr", DllStructGetPtr($tBuffer))
            $itmText = DllStructGetData($tBuffer, 1)
            
            Local $tRECT = DllStructCreate("int Left;int Top;int Right;int Bottom")
            DllStructSetData($tRECT, "Left", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1) + 12)
            DllStructSetData($tRECT, "Top", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 2))
            DllStructSetData($tRECT, "Right", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 3))
            DllStructSetData($tRECT, "Bottom", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 4))
            
            DllCall("user32.dll", "int", "DrawText", "hwnd", $hDC, "str", $itmText, "int", StringLen($itmText), _
                    "ptr", DllStructGetPtr($tRECT), "int", $DT_LEFT)
            
            Local $iX = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1)
            Local $iY = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 2) + 2
            
            _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, $iX, $iY, 10, 10)
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc

:P

Link to comment
Share on other sites

Wow, thank you rasim! It's almost what i needed...

Just one thing: Now how to load an image from icon files? i need to get it from Shell32.dll by index.

P.S

And stop calling yourself a noob, you are a far far away from it (i mean that your are very advanced scripter :P).

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Here's an example for Loadign Icons from Files :P Also, you can specify the icon for each entry ( the images are saved in an imagelist )

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiListBox.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
; example by rasim
; modified by Prog@ndy

Global Const $ODT_LISTBOX = 2
Global Const $ODA_DRAWENTIRE = 0x1
Global Const $ODA_SELECT = 0x2
Global Const $ODS_SELECTED = 0x1

$hGUI = GUICreate("Test GUI", 300, 200)

$hListBoxIMGList = _GUIImageList_Create(16,16,6,1,4,90)
_GUIImageList_SetBkColor($hListBoxIMGList,$CLR_NONE)

GUIRegisterMsg($WM_MEASUREITEM, "WM_MEASUREITEM")
$ListBox = GUICtrlCreateList( "", 10, 10, 280, 180,BitOR($LBS_HASSTRINGS, $LBS_OWNERDRAWFIXED, $WS_VSCROLL))
$hListBox = GUICtrlGetHandle($ListBox)

For $i = 1 To 10
    $IconIDX = _GUIImageList_AddIcon($hListBoxIMGList,@SystemDir & "\shell32.dll",$i,0)
    _GUICtrlListBox_AddString($hListBox, "{" & $IconIDX & "}String " & $i)
    ; the image index is stored in the item String at the beginning between curly brackets: {Index}
Next

;~ _GDIPlus_Startup()
;~ $hImage = _GDIPlus_ImageLoadFromFile("c:\Program Files\AutoIt3\Examples\GUI\Advanced\Images\Blue.bmp")
;~ $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hListBox)


GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM")


GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

;~ _GDIPlus_GraphicsDispose($hGraphic)
;~ _GDIPlus_ImageDispose($hImage)
;~ _GDIPlus_Shutdown()

Func WM_MEASUREITEM($hWnd, $Msg, $wParam, $lParam)
    Local $CtlType, $tagMEASUREITEMSTRUCT = "UINT CtlType;  UINT CtlID;  UINT itemID;  UINT itemWidth;  UINT itemHeight;  ULONG_PTR itemData;"
    Local $MEASUREITEMSTRUCT = DllStructCreate($tagMEASUREITEMSTRUCT,$lParam)
    $CtlType = DllStructGetData($MEASUREITEMSTRUCT, "CtlType")
    If $CtlType <> $ODT_LISTBOX Then Return $GUI_RUNDEFMSG
    DllStructSetData($MEASUREITEMSTRUCT,5,18)
    DllStructSetData($MEASUREITEMSTRUCT,4,DllStructGetData($MEASUREITEMSTRUCT,4)+18)
    Return
EndFunc
Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam)
    Local $tagDRAWITEMSTRUCT, $cID, $itmID, $itmAction, $itmState, $hItm, $hDC, $iBrushColor, $hBrush, $hBrushOld
   
    $tagDRAWITEMSTRUCT = DllStructCreate("uint cType;uint cID;uint itmID;uint itmAction;uint itmState;" & _
                                         "hwnd hItm;hwnd hDC;int itmRect[4];dword itmData", $lParam)
    If DllStructGetData($tagDRAWITEMSTRUCT, "cType") <> $ODT_LISTBOX Then Return $GUI_RUNDEFMSG
   
    $cID = DllStructGetData($tagDRAWITEMSTRUCT, "cID")
    $itmID = DllStructGetData($tagDRAWITEMSTRUCT, "itmID")
    $itmAction = DllStructGetData($tagDRAWITEMSTRUCT, "itmAction")
    $itmState = DllStructGetData($tagDRAWITEMSTRUCT, "itmState")
    $hItm = DllStructGetData($tagDRAWITEMSTRUCT, "hItm")
    $hDC = DllStructGetData($tagDRAWITEMSTRUCT, "hDC")
   
    Switch $itmAction
        Case $ODA_DRAWENTIRE, $ODA_SELECT
           
            If $itmState = $ODS_SELECTED Then
                $iBrushColor = 0x6495ED
            Else
                $iBrushColor = 0x66CDAA
            EndIf
           
            $hBrush = _WinAPI_CreateSolidBrush($iBrushColor)
            $hBrushOld = _WinAPI_SelectObject($hDC, $hBrush)
           
            DLLCall("user32.dll","int","FillRect", _
                                        "hwnd", $hDC, _
                                        "ptr", DllStructGetPtr($tagDRAWITEMSTRUCT, "itmRect"), _
                                        "hwnd", $hBrush)
           
            _WinAPI_SelectObject($hDC, $hBrushOld)
            _WinAPI_DeleteObject($hBrush)
           
            DLLCall("gdi32.dll","int","SetBkMode", "hwnd", $hDC, "int", 1)
           
            Local $tBuffer = DllStructCreate("char[256]")
            DllCall("user32.dll", "int", "SendMessage", _
                                            "hwnd", $hItm, _
                                            "int", $LB_GETTEXT, _
                                            "int", $itmID, _
                                            "ptr", DllStructGetPtr($tBuffer))
            $itmText = DllStructGetData($tBuffer, 1)
            Local $itmTextIMG = StringRegExp($itmText,"\A{\d+}",3)
            If Not @error Then
                $itmTextIMG = $itmTextIMG[0]
                $itmText = StringReplace($itmText,$itmTextIMG,"",1)
                $itmTextIMG = StringMid($itmTextIMG,2,StringLen($itmTextIMG)-2)
            Else
                $itmTextIMG = -1
            EndIf
            
           
            Local $tRECT = DllStructCreate("int Left;int Top;int Right;int Bottom")
            DllStructSetData($tRECT, "Left", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1) + 18)
            DllStructSetData($tRECT, "Top", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 2))
            DllStructSetData($tRECT, "Right", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 3))
            DllStructSetData($tRECT, "Bottom", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 4))
           
            DllCall("user32.dll", "int", "DrawText", "hwnd", $hDC, "str", $itmText, "int", StringLen($itmText), _
                    "ptr", DllStructGetPtr($tRECT), "int", $DT_LEFT)
           
            Local $iX = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1) +1
            Local $iY = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 2) +1
            Local $fIsSelected = ($itmState = $ODS_SELECTED)*2
           
           If $itmTextIMG >= 0 Then _GUIImageList_Draw($hListBoxIMGList,$itmTextIMG,$hDC,$iX,$iY,BitOR(1,$fIsSelected))
    EndSwitch
   
    Return $GUI_RUNDEFMSG
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Perfect! Thank you all, @martin, @rasim and @ProgAndy! Problem solved! :(:P

Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Well, it's not perfect :P

Just now i found out, that there's a Parameter itemData in which you can save the Icon Index with

_GUICtrlListBox_SetItemData

_GUICtrlListBox_GetItemData

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Got it, here is the modified (final?) version:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiListBox.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

; Example by rasim
; modified by Prog@ndy / MsCreatoR (Index storing issue, UDF merge, and tidy source :) )

Global Const $ODT_LISTBOX = 2
Global Const $ODA_DRAWENTIRE = 0x1
Global Const $ODA_SELECT = 0x2
Global Const $ODS_SELECTED = 0x1

$hGUI = GUICreate("ListBox with images - Demo!", 300, 200)

$hListBoxIMGList = _GUIImageList_Create(16, 16, 6, 1, 4, 90)
_GUIImageList_SetBkColor($hListBoxIMGList, $CLR_NONE)

GUIRegisterMsg($WM_MEASUREITEM, "WM_MEASUREITEM")

$ListBox = GUICtrlCreateList("", 10, 10, 280, 180, BitOR($LBS_HASSTRINGS, $LBS_OWNERDRAWFIXED, $WS_VSCROLL))
$hListBox = GUICtrlGetHandle($ListBox)

For $i = 1 To 10
    _GUICtrlListBox_AddStringEx($hListBox, "String " & $i, $hListBoxIMGList, @SystemDir & "\shell32.dll", $i)
Next

GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM")

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _GUICtrlListBox_AddStringEx($hWnd, $sText, $hImageList = 0, $sIconFile = "", $iIndex = 0)
    If $hImageList = 0 Then
        Return _GUICtrlListBox_AddString($hWnd, $sText)
    Else
        Local $iIconIDX = _GUIImageList_AddIcon($hImageList, $sIconFile, $iIndex, 0)
        Local $iStrIndex = _GUICtrlListBox_AddString($hWnd, $sText)
        _GUICtrlListBox_SetItemData($hWnd, $iStrIndex, $iIconIDX)
        
        Return $iStrIndex
    EndIf
EndFunc

Func WM_MEASUREITEM($hWnd, $Msg, $wParam, $lParam)
    Local $CtlType, $tagMEASUREITEMSTRUCT = "UINT CtlType;UINT CtlID;UINT itemID;UINT itemWidth;UINT itemHeight;ULONG_PTR itemData;"
    Local $MEASUREITEMSTRUCT = DllStructCreate($tagMEASUREITEMSTRUCT, $lParam)
    
    $CtlType = DllStructGetData($MEASUREITEMSTRUCT, "CtlType")
    If $CtlType <> $ODT_LISTBOX Then Return $GUI_RUNDEFMSG
    
    DllStructSetData($MEASUREITEMSTRUCT, 5, 18)
    DllStructSetData($MEASUREITEMSTRUCT, 4, DllStructGetData($MEASUREITEMSTRUCT, 4) + 18)
    
    Return
EndFunc

Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam)
    Local $tagDRAWITEMSTRUCT, $cID, $itmID, $itmAction, $itmState, $hItm, $hDC, $iBrushColor, $hBrush, $hBrushOld
    
    $tagDRAWITEMSTRUCT = DllStructCreate("uint cType;uint cID;uint itmID;uint itmAction;uint itmState;" & _
            "hwnd hItm;hwnd hDC;int itmRect[4];dword itmData", $lParam)
    If DllStructGetData($tagDRAWITEMSTRUCT, "cType") <> $ODT_LISTBOX Then Return $GUI_RUNDEFMSG
    
    $cID = DllStructGetData($tagDRAWITEMSTRUCT, "cID")
    $itmID = DllStructGetData($tagDRAWITEMSTRUCT, "itmID")
    $itmAction = DllStructGetData($tagDRAWITEMSTRUCT, "itmAction")
    $itmState = DllStructGetData($tagDRAWITEMSTRUCT, "itmState")
    $hItm = DllStructGetData($tagDRAWITEMSTRUCT, "hItm")
    $hDC = DllStructGetData($tagDRAWITEMSTRUCT, "hDC")
    
    Switch $itmAction
        Case $ODA_DRAWENTIRE, $ODA_SELECT
            If $itmState = $ODS_SELECTED Then
                $iBrushColor = 0x6495ED
            Else
                $iBrushColor = 0x66CDAA
            EndIf
            
            $hBrush = _WinAPI_CreateSolidBrush($iBrushColor)
            $hBrushOld = _WinAPI_SelectObject($hDC, $hBrush)

            DllCall("user32.dll", "int", "FillRect", _
                    "hwnd", $hDC, _
                    "ptr", DllStructGetPtr($tagDRAWITEMSTRUCT, "itmRect"), _
                    "hwnd", $hBrush)
            
            _WinAPI_SelectObject($hDC, $hBrushOld)
            _WinAPI_DeleteObject($hBrush)
            
            DllCall("gdi32.dll", "int", "SetBkMode", "hwnd", $hDC, "int", 1)
            
            Local $tBuffer = DllStructCreate("char[256]")
            DllCall("user32.dll", "int", "SendMessage", _
                    "hwnd", $hItm, _
                    "int", $LB_GETTEXT, _
                    "int", $itmID, _
                    "ptr", DllStructGetPtr($tBuffer))
            
            Local $itmText = DllStructGetData($tBuffer, 1)
            Local $itmTextIMG = _GUICtrlListBox_GetItemData($hListBox, $itmID)
            
            Local $tRECT = DllStructCreate("int Left;int Top;int Right;int Bottom")
            DllStructSetData($tRECT, "Left", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1) + 18)
            DllStructSetData($tRECT, "Top", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 2))
            DllStructSetData($tRECT, "Right", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 3))
            DllStructSetData($tRECT, "Bottom", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 4))
            
            DllCall("user32.dll", "int", "DrawText", "hwnd", $hDC, "str", $itmText, "int", StringLen($itmText), _
                    "ptr", DllStructGetPtr($tRECT), "int", $DT_LEFT)
            
            Local $iX = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1) + 1
            Local $iY = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 2) + 1
            Local $fIsSelected = ($itmState = $ODS_SELECTED) * 2
            
            If $itmTextIMG >= 0 Then _GUIImageList_Draw($hListBoxIMGList, $itmTextIMG, $hDC, $iX, $iY, BitOR(1, $fIsSelected))
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Very nice result rasim, ProgAndy and MrCreatoR. :P

I was only an onlooker but I enjoyed watching it develop.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 4 years later...

Hey all!
 
This is a great solution, and will greatly improve my project.
 
One pitfall I noticed is that the customized List control will only select correctly if it is the only control in the GUI.
 
Here's an example, built off of the post above:
 

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiListBox.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>
 
; Example by rasim
; modified by Prog@ndy / MsCreatoR (Index storing issue, UDF merge, and tidy source :) )
 
Global Const $ODT_LISTBOX = 2
Global Const $ODA_DRAWENTIRE = 0x1
Global Const $ODA_SELECT = 0x2
Global Const $ODS_SELECTED = 0x1
 
$hGUI = GUICreate("ListBox with images - Demo!", 300, 240)
 
$hListBoxIMGList = _GUIImageList_Create(16, 16, 6, 1, 4, 90)
_GUIImageList_SetBkColor($hListBoxIMGList, $CLR_NONE)
 
GUIRegisterMsg($WM_MEASUREITEM, "WM_MEASUREITEM")
 
$ListBox = GUICtrlCreateList("", 10, 10, 280, 180, BitOR($LBS_HASSTRINGS, $LBS_OWNERDRAWFIXED, $WS_VSCROLL))
 
$hListBox = GUICtrlGetHandle($ListBox)
 
For $i = 1 To 10
    _GUICtrlListBox_AddStringEx($hListBox, "String " & $i, $hListBoxIMGList, @SystemDir & "\shell32.dll", $i)
Next
 
$btn = GUICtrlCreateButton("Another Control", 10, 190, 280, 40) ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM")
 
GUISetState()
 
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
 
Func _GUICtrlListBox_AddStringEx($hWnd, $sText, $hImageList = 0, $sIconFile = "", $iIndex = 0)
    If $hImageList = 0 Then
        Return _GUICtrlListBox_AddString($hWnd, $sText)
    Else
        Local $iIconIDX = _GUIImageList_AddIcon($hImageList, $sIconFile, $iIndex, 0)
        Local $iStrIndex = _GUICtrlListBox_AddString($hWnd, $sText)
        _GUICtrlListBox_SetItemData($hWnd, $iStrIndex, $iIconIDX)
        Return $iStrIndex
    EndIf
EndFunc
 
Func WM_MEASUREITEM($hWnd, $Msg, $wParam, $lParam)
    Local $CtlType, $tagMEASUREITEMSTRUCT = "UINT CtlType;UINT CtlID;UINT itemID;UINT itemWidth;UINT itemHeight;ULONG_PTR itemData;"
    Local $MEASUREITEMSTRUCT = DllStructCreate($tagMEASUREITEMSTRUCT, $lParam)
 
    $CtlType = DllStructGetData($MEASUREITEMSTRUCT, "CtlType")
    If $CtlType <> $ODT_LISTBOX Then Return $GUI_RUNDEFMSG
 
    DllStructSetData($MEASUREITEMSTRUCT, 5, 18)
    DllStructSetData($MEASUREITEMSTRUCT, 4, DllStructGetData($MEASUREITEMSTRUCT, 4) + 18)
 
    Return
EndFunc
 
Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam)
    Local $tagDRAWITEMSTRUCT, $cID, $itmID, $itmAction, $itmState, $hItm, $hDC, $iBrushColor, $hBrush, $hBrushOld
 
    $tagDRAWITEMSTRUCT = DllStructCreate("uint cType;uint cID;uint itmID;uint itmAction;uint itmState;" & _
            "hwnd hItm;hwnd hDC;int itmRect[4];dword itmData", $lParam)
    If DllStructGetData($tagDRAWITEMSTRUCT, "cType") <> $ODT_LISTBOX Then Return $GUI_RUNDEFMSG
 
    $cID = DllStructGetData($tagDRAWITEMSTRUCT, "cID")
    $itmID = DllStructGetData($tagDRAWITEMSTRUCT, "itmID")
    $itmAction = DllStructGetData($tagDRAWITEMSTRUCT, "itmAction")
    $itmState = DllStructGetData($tagDRAWITEMSTRUCT, "itmState")
    $hItm = DllStructGetData($tagDRAWITEMSTRUCT, "hItm")
    $hDC = DllStructGetData($tagDRAWITEMSTRUCT, "hDC")
 
    Switch $itmAction
        Case $ODA_DRAWENTIRE, $ODA_SELECT
            If $itmState = $ODS_SELECTED Then
                $iBrushColor = 0x6495ED
            Else
                $iBrushColor = 0x66CDAA
            EndIf
 
            $hBrush = _WinAPI_CreateSolidBrush($iBrushColor)
            $hBrushOld = _WinAPI_SelectObject($hDC, $hBrush)
 
            DllCall("user32.dll", "int", "FillRect", _
                    "hwnd", $hDC, _
                    "ptr", DllStructGetPtr($tagDRAWITEMSTRUCT, "itmRect"), _
                    "hwnd", $hBrush)
 
            _WinAPI_SelectObject($hDC, $hBrushOld)
            _WinAPI_DeleteObject($hBrush)
 
            DllCall("gdi32.dll", "int", "SetBkMode", "hwnd", $hDC, "int", 1)
 
            Local $tBuffer = DllStructCreate("char[256]")
            DllCall("user32.dll", "int", "SendMessage", _
                    "hwnd", $hItm, _
                    "int", $LB_GETTEXT, _
                    "int", $itmID, _
                    "ptr", DllStructGetPtr($tBuffer))
 
            Local $itmText = DllStructGetData($tBuffer, 1)
            Local $itmTextIMG = _GUICtrlListBox_GetItemData($hListBox, $itmID)
 
            Local $tRECT = DllStructCreate("int Left;int Top;int Right;int Bottom")
            DllStructSetData($tRECT, "Left", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1) + 18)
            DllStructSetData($tRECT, "Top", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 2))
            DllStructSetData($tRECT, "Right", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 3))
            DllStructSetData($tRECT, "Bottom", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 4))
 
            DllCall("user32.dll", "int", "DrawText", "hwnd", $hDC, "str", $itmText, "int", StringLen($itmText), _
                    "ptr", DllStructGetPtr($tRECT), "int", $DT_LEFT)
 
            Local $iX = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1) + 1
            Local $iY = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 2) + 1
            Local $fIsSelected = ($itmState = $ODS_SELECTED) * 2
 
            If $itmTextIMG >= 0 Then _GUIImageList_Draw($hListBoxIMGList, $itmTextIMG, $hDC, $iX, $iY, BitOR(1, $fIsSelected))
    EndSwitch
 
    Return $GUI_RUNDEFMSG
EndFunc
 

 

Even stranger, it seems to work fine when it is run for the first time, but subsequent times it seems to break.

I know this is a five-year-old thread, but any ideas of what might be causing this? I'm not good enough with the code to pinpoint the problem.

Regards,

cyberbit

_ArrayConcatenate2D · Aero Flip 3D · EPOCH (destroy timestamps) · File Properties Modifier · _GetFileType · UpdateEngine<new> · In-line Case (_ICase) <new>

[hr]

50% of the time, it works all the time. -PezoFaSho

Link to comment
Share on other sites

@Zedna: Did you run it more than once? It doesn't always appear on the first run. It does it for me on Win7 and XP.

Edited by cyberbit

_ArrayConcatenate2D · Aero Flip 3D · EPOCH (destroy timestamps) · File Properties Modifier · _GetFileType · UpdateEngine<new> · In-line Case (_ICase) <new>

[hr]

50% of the time, it works all the time. -PezoFaSho

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