I wish to know if possible to create a listview with different quantity of elements in each column.
For example: In the column 1, 5 elements, in the column 2, 13 elements and in the colum 3, 2 elements.
The listview is a listview with icons at each cell.
I already tried several way, like, for example the code that I place now:
Resource File:
save as resource.rc
I have the following problem:
For example if the column 1 has 5 elements, the column 2 have 13, only shows me 5 elements in the column 2.
As you can see with:
Indicate the listview that has 13 elements but however put this his instruction, take the 5 elements from the first column like the max elements of the listview.
Somebody can guide me in this problem or showing up where the error can be?
As always, thanks
For example: In the column 1, 5 elements, in the column 2, 13 elements and in the colum 3, 2 elements.
The listview is a listview with icons at each cell.
I already tried several way, like, for example the code that I place now:
Code:
#COMPILE EXE #DIM ALL '-------------------------------------------------------------------------------- ' ** Includes ** '-------------------------------------------------------------------------------- #INCLUDE "WIN32API.INC" #INCLUDE "COMMCTRL.INC" #INCLUDE "PBForms.INC" #RESOURCE "resource.PBR" '-------------------------------------------------------------------------------- ' ** Constants ** '-------------------------------------------------------------------------------- %VDCH_CXIMAGE = 16 %VDCH_CYIMAGE = 16 %VDCH_LISTVIEW = 1002 %VDCH_CLOSEBTTON = 1004 '-------------------------------------------------------------------------------- ' ** Declarations ** '-------------------------------------------------------------------------------- DECLARE FUNCTION VIEWDIGCHDLG(BYVAL hParent AS DWORD) AS LONG DECLARE CALLBACK FUNCTION VIEWDIGCHDLGProc() DECLARE SUB BuildListviewDCH() GLOBAL VIEWDIGCHhDlg AS DWORD GLOBAL ghInstance AS DWORD GLOBAL oldstateimage AS LONG GLOBAL hListviewCtl AS LONG '-------------------------------------------------------------------------------- FUNCTION PBMAIN() LOCAL ticc AS INIT_COMMON_CONTROLSEX PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR %ICC_INTERNET_CLASSES OR %ICC_LISTVIEW_CLASSES) VIEWDIGCHDLG %HWND_DESKTOP END FUNCTION '-------------------------------------------------------------------------------- ' ** Dialogs ** '-------------------------------------------------------------------------------- FUNCTION VIEWDIGCHDLG(BYVAL hParent AS DWORD) AS LONG LOCAL lRslt AS LONG ghInstance = GetModuleHandle("") ' Get the handle of the application instance DIALOG NEW hParent, "Digital Channels", , , 456, 153, %WS_POPUP OR %WS_BORDER _ OR %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR _ %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _ %DS_SETFONT, %WS_EX_WINDOWEDGE OR %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _ %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO VIEWDIGCHhDlg CONTROL ADD "SysListView32", VIEWDIGCHhDlg, %VDCH_LISTVIEW, "SysListView321", 5, 5, 440, 110, _ %WS_CHILD OR %WS_VISIBLE OR %WS_CLIPCHILDREN OR %WS_TABSTOP OR %LVS_REPORT OR %LVS_SINGLESEL OR _ %LVS_SHOWSELALWAYS OR %LVS_SHAREIMAGELISTS, %WS_EX_CLIENTEDGE CONTROL ADD BUTTON, VIEWDIGCHhDlg, %VDCH_CLOSEBTTON, "&Close", 411, 125, 40, 13, _ %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_PUSHBUTTON, %WS_EX_LEFT OR %WS_EX_LTRREADING CONTROL HANDLE VIEWDIGCHhDlg, %VDCH_LISTVIEW TO hListviewCtl BuildListviewDCH DIALOG SHOW MODAL VIEWDIGCHhDlg, CALL VIEWDIGCHDLGProc TO lRslt FUNCTION = lRslt END FUNCTION '-------------------------------------------------------------------------------- ' ** CallBacks ** '-------------------------------------------------------------------------------- CALLBACK FUNCTION VIEWDIGCHDLGProc() LOCAL szItem AS ASCIIZ * %MAX_PATH LOCAL tlv_col AS LV_COLUMN LOCAL tlv_item AS LV_ITEM SELECT CASE CBMSG CASE %WM_COMMAND SELECT CASE CBCTL CASE %VDCH_CLOSEBTTON DIALOG END CBHNDL END SELECT END SELECT END FUNCTION '-------------------------------------------------------------------------------- ' ** Sample Code ** '-------------------------------------------------------------------------------- SUB BuildListviewDCH() LOCAL hFont AS DWORD ' handle of font used by parent STATIC hImageList1 AS DWORD ' handle of imagelist control LOCAL hImage AS DWORD ' handle of bitmap, icon or cursor LOCAL tlv_item AS LV_ITEM ' listview item information LOCAL tlv_col AS LV_COLUMN ' listview column information LOCAL ptnmhdr AS NMHDR PTR ' information about a notification message LOCAL ptlvcd AS NMLVCUSTOMDRAW PTR ' listview custom draw information LOCAL szItem AS ASCIIZ * %MAX_PATH ' working variable hFont = GetStockObject(%DEFAULT_GUI_FONT) ListView_SetItemCount hListviewCtl, 15 SendMessage hListviewCtl, %LVM_SETEXTENDEDLISTVIEWSTYLE, 0, %LVS_EX_SUBITEMIMAGES OR %LVS_EX_FULLROWSELECT SendMessage hListviewCtl, %WM_SETFONT, hFont, %TRUE ' Create and initialize the ImageList1 image list hImageList1 = ImageList_Create(%VDCH_CXIMAGE, %VDCH_CYIMAGE, %ILC_COLOR24 OR %ILC_MASK, 2, 0) IF ISTRUE hImageList1 THEN ' Set the background color to use for drawing images ImageList_SetBkColor hImageList1, GetSysColor(%COLOR_WINDOW) ' Add the images to the imagelist hImage = LoadImage(ghInstance, "ICON1", %IMAGE_ICON, 16, 16, %LR_DEFAULTCOLOR) ImageList_ReplaceIcon hImageList1, -1, hImage DeleteObject hImage hImage = LoadImage(ghInstance, "ICON2", %IMAGE_ICON, 16, 16, %LR_DEFAULTCOLOR) ImageList_ReplaceIcon hImageList1, -1, hImage DeleteObject hImage ' Associate the imagelist with the listview control SendMessage hListviewCtl, %LVM_SETIMAGELIST, %LVSIL_SMALL, hImageList1 END IF ' Add the columns to the listview control szItem = "Group Nr. 1" 'column 1 tlv_col.mask = %LVCF_FMT OR %LVCF_WIDTH OR %LVCF_TEXT OR %LVCF_SUBITEM tlv_col.fmt = %LVCFMT_LEFT tlv_col.cx = 160 tlv_col.pszText = VARPTR(szItem) tlv_col.iSubItem = 0 SendMessage hListviewCtl, %LVM_INSERTCOLUMN, 0, BYVAL VARPTR(tlv_col) szItem = "Group Nr. 2" 'column 2 tlv_col.mask = %LVCF_FMT OR %LVCF_WIDTH OR %LVCF_TEXT OR %LVCF_SUBITEM tlv_col.fmt = %LVCFMT_LEFT tlv_col.cx = 160 tlv_col.pszText = VARPTR(szItem) tlv_col.iSubItem = 0 SendMessage hListviewCtl, %LVM_INSERTCOLUMN, 1, BYVAL VARPTR(tlv_col) szItem = "Group Nr. 3" 'column 3 tlv_col.mask = %LVCF_FMT OR %LVCF_WIDTH OR %LVCF_TEXT OR %LVCF_SUBITEM tlv_col.fmt = %LVCFMT_LEFT tlv_col.cx = 160 tlv_col.pszText = VARPTR(szItem) tlv_col.iSubItem = 0 SendMessage hListviewCtl, %LVM_INSERTCOLUMN, 3, BYVAL VARPTR(tlv_col) ' Insert row REGISTER indx& FOR indx& = 1 TO 5 'colum 1 szItem = "CH Nro " & STR$(indx&) tlv_item.mask = %LVIF_TEXT OR %LVIF_IMAGE tlv_item.iItem = indx& tlv_item.iSubItem = 0 tlv_item.pszText = VARPTR(szItem) tlv_item.iImage = 0 SendMessage hListviewCtl, %LVM_INSERTITEM, 0, BYVAL VARPTR(tlv_item) NEXT indx& FOR indx& = 1 TO 13 'colum 2 szItem = "CH Nro " & STR$(indx&) tlv_item.mask = %LVIF_TEXT OR %LVIF_IMAGE tlv_item.iItem = indx& - 1 tlv_item.iSubItem = 1 tlv_item.pszText = VARPTR(szItem) tlv_item.iImage = 0 SendMessage hListviewCtl, %LVM_SETITEM, 1, BYVAL VARPTR(tlv_item) NEXT indx& FOR indx& = 1 TO 2 'column 3 szItem = "CH Nro " & STR$(indx&) tlv_item.mask = %LVIF_TEXT OR %LVIF_IMAGE tlv_item.iItem = indx& - 1 tlv_item.iSubItem = 2 tlv_item.pszText = VARPTR(szItem) tlv_item.iImage = 0 SendMessage hListviewCtl, %LVM_SETITEM, 2, BYVAL VARPTR(tlv_item) NEXT indx& END SUB
Resource File:
save as resource.rc
Code:
#include "resource.h" //////////////////////////////////////////////////////////////////////////////// // Icons //////////////////////////////////////////////////////////////////////////////// ICON1 ICON DISCARDABLE "D:\\PBWin80\\Samples\\SDK\\Tray\\Face1.ico" ICON2 ICON DISCARDABLE "D:\\PBWin80\\Samples\\SDK\\Tray\\Face2.ico"
For example if the column 1 has 5 elements, the column 2 have 13, only shows me 5 elements in the column 2.
As you can see with:
Code:
ListView_SetItemCount hCtl, 13
Somebody can guide me in this problem or showing up where the error can be?
As always, thanks
Comment