Here's a quick implementation I've knocked up that should work with the new MaxGUI.Win32MaxGUIEx module only...
SuperStrict
Import MaxGUI.Win32MaxGUIEx
AppTitle = "ListBox Icon View Example"
Global wndMain:TGadget = CreateWindow( AppTitle, 100, 100, 400, 300, Null, WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS|WINDOW_RESIZABLE )
Global lstItems:TGadget = CreateListBox( 0, 0, ClientWidth(wndMain), ClientHeight(wndMain), wndMain )
SetGadgetLayout lstItems, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED
Global icnToolbar:TIconStrip = LoadIconStrip( "../src/maxide/icons.PNG" ) 'Let's try and steal some icons from the MaxIDE toolbar.
If Not icnToolbar Then icnToolbar = LoadIconStrip( RequestFile( "Select An Icon-Strip...", "png,bmp,jpg" ) )
If Not icnToolbar Then RuntimeError "Cannot load icon-strip!"
ShowIconView( lstItems, icnToolbar )
For Local i% = 0 Until icnToolbar.count
AddGadgetItem lstItems, "Icon " + i, 0, i, "Tooltip " + i
Next
Repeat
Select WaitEvent()
Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
End
Case EVENT_GADGETSELECT
Print "Listbox Item Selected: " + EventData()
Case EVENT_GADGETACTION
Print "Listbox Item Double-Clicked: " + EventData()
EndSelect
Forever
Function ShowIconView( pListbox:TGadget, pIconStrip:TIconStrip )
?Win32
Local tmpHwnd% = QueryGadget( pListbox, QUERY_HWND )
If tmpHwnd Then
Local tmpFlags% = GetWindowLongW( tmpHwnd, GWL_STYLE )
tmpFlags:&~(LVS_REPORT|LVS_NOCOLUMNHEADER);tmpFlags:|LVS_ICON
SetWindowLongW( tmpHwnd, GWL_STYLE, tmpFlags )
If TWindowsIconStrip(pIconStrip) Then
SendMessageW( tmpHwnd,LVM_SETIMAGELIST,LVSIL_NORMAL,TWindowsIconStrip(pIconStrip)._imagelist )
EndIf
EndIf
?
EndFunction If you replace LVS_ICON with LVS_SMALLICON in the ShowIconView() function, then you can still use SetGadgetIconStrip() to set the icon strip of the listbox.
|