Deprecated: Array and string offset access syntax with curly braces is deprecated in /homepages/21/d38531796/htdocs/jose/smfforum/Sources/Subs.php on line 3825
ListView2 with icons

Author Topic: ListView2 with icons  (Read 646 times)

0 Members and 1 Guest are viewing this topic.

Offline Zlatko Vid

  • Full Member
  • ***
  • Posts: 159
  • User-Rate: +0/-0
ListView2 with icons
« on: May 23, 2021, 10:36:40 PM »
Hello
here is Listview control example with icons in front of item text .
I con by itself can be any size ,,i have used small 16x16

Offline Zlatko Vid

  • Full Member
  • ***
  • Posts: 159
  • User-Rate: +0/-0
Re: ListView2 with icons
« Reply #1 on: May 24, 2021, 01:58:05 PM »
Here is code of example :
Code: [Select]
$ Filename "ListView2.exe" ' o2
include "RTL32.inc"
include "awinh037.inc"
#lookahead
% LVSIL_SMALL = 1
% LVM_SETIMAGELIST = 4099
INT win,wx=200,wy=200,ww=640,wh=420,wstyle = WS_MINMAXSIZE
INT button0,b0ID=100,listv,lvID=1000,static1,st1ID=200, col1,col2,col3
INT static0,stid0 = 199,stIMG
win=SetWindow("GUI:ListView",wx,wy,ww,wh,0,wstyle)
'create static control
stImg = LoadImage(0,"adBook.bmp",0,252,30,16)
If stImg = 0 ' create static with text
static1 = SetStatic(win,10,10,254,32," Adress Book by Aurel",0,0x200,st1ID)
ControlFont (static1, 24, 11, 600, "Courier New")
Else
static0 = SetStatic(win,10,10,254,32,"",0x5000030E,0x200,stid0)
SendMessage static0 ,370, 0, stImg

End if
'crete button-----------------------------------------------------------------------
button0 = SetButton(win,370,10,80,32,"Close (X)",0x50001000,0x200,b0ID)

'create ListView --------------------------------------------------------------------
listv = SetListView (win, 10, 60, 600 , 300 ,"Name", 100, 0, 0x200, lvID)
'SendMessage listv, 4150 ,0 , 32  ' extended style - full row select
'ControlFont (listv, 14, 8, 200, "Consolas")

'create image list for listView
INT imgList
imgList = LVimageList( listv, 16, 16, 254)
'load icon
INT hIcon1,hIcon2,hicon3,hicon4
INT icon1,icon2,icon3,icon4
INT hIcon1 = LoadImage(0,"fn16.ico",1, 16, 16, &H10) ' set flag 1 for icon/ 0 for bitmap
icon1 = AddImageToList(imgList, hIcon1)

INT hIcon2 = LoadImage(0,"wm16.ico",1, 16, 16, &H10)
icon2 = AddImageToList(imgList, hIcon2)

INT hIcon3 = LoadImage(0,"wL16.ico",1, 16, 16, &H10)
icon3 = AddImageToList(imgList, hIcon3)
'
'print str lvImg
'add listview item {AddLVI hwnd, pos, text, icon}
AddListViewItem (listv, 0, " FUNC", icon1)
AddListViewItem (listv, 1, " WMSG", icon2)
AddListViewItem (listv, 2, " WHILE",icon3)
AddListViewItem (listv, 3, " CODE", -1)
AddListViewItem (listv, 4, " MODE", -1)
'------------------------------------------------------------------------------------
Wait()  'message loop
'------------------------------------------------------------------------------------
'func main
Function WndProc (sys hwnd,wmsg,wparam,lparam) as sys callback
SELECT hwnd
CASE win
Select wmsg
CASE WM_CLOSE
CloseWindow(win)
EndProgram
End Select
END SELECT
RETURN Default
END FUNCTION

'------------------------------------------------------------------------------------------------------
Sub LVimageList(byval _lvhandle as int, byval _lvcx as int, byval _lvcy as int , byval _lvstyle as int) as INT
  int _lviml
 'hImageList = ImageList_Create(24, 24, ILC_MASK OR ILC_COLOR8, 1, 0)
  _lviml = ImageList_Create( _lvcx, _lvcy, _lvstyle, 1, 1)
  SendMessage ( _lvhandle, LVM_SETIMAGELIST, LVSIL_SMALL, _lviml )
  Return _lviml
End Sub

'----------------
sub  AddImageToList(byval _imList as INT,byval _imlimage as INT) as INT
  Return ImageList_AddIcon(_imlist,_imlimage)
end sub


Offline Nicola_Piano

  • Newbie
  • *
  • Posts: 43
  • User-Rate: +0/-0
Re: ListView2 with icons
« Reply #2 on: November 19, 2021, 11:27:18 AM »
Hi, very interesting.
Thanks