|
Post by Brandon Parker on Nov 16, 2023 20:19:29 GMT -5
Here is the example I was talking about. Note that you will need to have two bitmap images in the DefaultDir$ named "rowHeightBitmap" and "rowHeightBitmap1" for the program to run, or you will have to change the names to the bitmaps you want to use. Neat tip...you can use a bitmap that is the same color as the background of the ListView and a single pixel wide to cause the ListView rows to be a specific height or have different rows be different heights.
NoMainWin
'The variables True & False are typically used in 'this fashion in my programming and are thus declared 'as Global variables Global False : False = 0 Global True : True = 1
'This is typically a decent way to store handles to 'API created controls/objects since one can maintain 'like handles in each array listViewHandle(0) = _NULL imageListHandle(0) = _NULL
'Call this function to initialize any/all constants 'that might be required, but are not declared within 'Liberty BASIC itself Call initializeListViewConstants
'This is a very simple window with a few buttons for options 'to execute the ListView row Addition, Editing, Deletion activities WindowWidth = 530 WindowHeight = 335 Button #Example.btnAddItem, "Add Item", AddItem, UL, 5, (WindowHeight - 67) Button #Example.btnEditItem, "Edit Item", EditItem, UL, 202.5, (WindowHeight - 67) Button #Example.btnDeleteItem, "Delete Item", DeleteItem, UL, 402, (WindowHeight - 67) Open "ListView Image List Example" For Window As #Example
'Initialize the Common Controls API; this is required prior to usage 'and calling it multiple times has NO negative effect, so it is a good 'idea to just call the subroutine before creation of any Common Control Call InitCommonControls
'These are the flags that I typically use when creating a ListView, but 'styles may differ for the requirements style = _WS_CHILD Or _WS_VISIBLE Or listViewConstants.LVS.NOSORTHEADER.struct _ Or listViewConstants.LVS.REPORT.struct Or listViewConstants.LVS.SHOWSELALWAYS.struct _ Or listViewConstants.LVS.SINGLESEL.struct styleEx = _WS_EX_CLIENTEDGE Or _WS_EX_DLGMODALFRAME
'Create the ListView by calling the CreateListView() function, and 'assign the returned handle to the variable it is to be retained in listViewHandle(0) = CreateListView(style, styleEx, Hwnd(#Example), GetWindowLong(Hwnd(#Example), _GWL_HINSTANCE), 5, 23, 505, 244) 'Call the setListViewFullRowSelect() function to have the entire row show as selected 'when any subItem is selected by the user result = setListViewFullRowSelect(listViewHandle(0)) 'Call the listViewShowGrid() function to show the grid layout result = listViewShowGrid(listViewHandle(0)) 'Call the createNewListColumn() function three times to create three columns result = createNewListColumn(listViewHandle(0), 0, 165, " Item 1") result = createNewListColumn(listViewHandle(0), 1, 165, " Item 2") result = createNewListColumn(listViewHandle(0), 2, 165, " Item 3")
'Don't forget your ability to trap the window's close event #Example "TrapClose Quit"
'Call the createImageList() function to create the Image List 'where the images will be stored imageListHandle(0) = createImageList(32, 32, _NULL, 2, 0)
'Here we will load two bitmaps and assign them to the Image List we created 'Load a bitmap using Liberty BASIC's built in command LoadBMP "rowHeightBitmap", DefaultDir$ + "\rowHeightAdjust.bmp" 'Add the bitmap to the Image List by calling the addImageToImageList() function result = addImageToImageList(imageListHandle(0), HBMP("rowHeightBitmap"), _NULL)
'Load a bitmap using Liberty BASIC's built in command LoadBMP "rowHeightBitmap1", DefaultDir$ + "\rowHeightAdjust1.bmp" 'Add the bitmap to the Image List by calling the addImageToImageList() function result = addImageToImageList(imageListHandle(0), HBMP("rowHeightBitmap1"), _NULL)
'Call the setListViewImageList() function to assign the Image List to the ListView 'Use the LVSIL_SMALL value to set the Image List type to Small result = setListViewImageList(listViewHandle(0), imageListHandle(0), listViewConstants.LVSIL.SMALL.struct)
'This is the loop that I typically use for windowed programs 'because I normally use the WMLiberty.dll and you cannot "Wait" with it While Hwnd(#Example) Scan result = Sleep(1) Wend
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Sub Quit handle$ result = DestroyWindow(listViewHandle(0)) 'The destroyImageList() function is not required 'if LVS_SHAREIMAGELISTS is not used for any of the 'ListViews in the process 'Print destroyImageList(myImageList)
'Check whether the bitmaps exist prior to destroying them 'This is not required if you "KNOW" they exist If isBitMap("rowHeightBitmap") Then UnloadBMP "rowHeightBitmap" If isBitMap("rowHeightBitmap1") Then UnloadBMP "rowHeightBitmap1" Close #handle$ End End Sub
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Sub AddItem handle$ 'Get the number of items in the ListView numListViewEntries = GetListViewItemCount(listViewHandle(0)) 'Here we are simply alternating the image to be used when the istView row is added If Not(numListViewEntries Mod 2) Then iImage = 0 Else iImage = 1 'Add the ListView row result = AddListViewData(listViewHandle(0), numListViewEntries, 0, "Data1", iImage) 'Add each additional subItem result = EditListViewData(listViewHandle(0), numListViewEntries, 1, "Data2") result = EditListViewData(listViewHandle(0), numListViewEntries, 2, "Data3") 'Select the newly added ListView row result = SelectListViewRow(listViewHandle(0), numListViewEntries, True) End Sub
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Sub EditItem handle$ 'Get the number of items in the ListView and Exit the Sub if there are no items numListViewEntries = GetListViewItemCount(listViewHandle(0)) If Not(numListViewEntries) Then Exit Sub 'Get the selected row of the ListView row = GetSelectedListViewRow(listViewHandle(0)) 'Here we just get the text for each subItem, add " Edited" to that text, and then 'send it back to each subItem result = EditListViewData(listViewHandle(0), row, 0, GetListViewText$(listViewHandle(0), row, 0) + " Edited") result = EditListViewData(listViewHandle(0), row, 1, GetListViewText$(listViewHandle(0), row, 1) + " Edited") result = EditListViewData(listViewHandle(0), row, 2, GetListViewText$(listViewHandle(0), row, 2) + " Edited")
'Reselect the ListView row that was selected initially result = SelectListViewRow(listViewHandle(0), row, True) End Sub
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Sub DeleteItem handle$ 'Get the number of items in the ListView and Exit the Sub if there are no items numListViewEntries = GetListViewItemCount(listViewHandle(0)) If Not(numListViewEntries) Then Exit Sub 'Get the selected row of the ListView and then delete the item by sending the 'LVM_DELETEITEM message to the ListView row = GetSelectedListViewRow(listViewHandle(0)) result = SendMessageLVITEMStruct(listViewHandle(0), listViewConstants.LVM.DELETEITEM.struct, row) End Sub
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Sub InitCommonControls 'This initializes the Common Controls DLL CallDLL #comctl32, "InitCommonControls", ret As void End Sub
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Sub initializeListViewConstants 'Create the structures for ListViews 'This struct has been superceded, but it still works Struct LVITEM, mask As ulong, _ iItem As long, _ iSubItem As long, _ state As ulong, _ stateMask As ulong,_ pszText As ptr, _ cchTextMax As long, _ iImage As long, _ lParam As long, _ iIndent As long
Struct LVCOLUMN, mask As ulong, _ fmt As long, _ cx As long, _ pszText As ptr, _ cchTextMax As long, _ iSubItem As long, _ iImage As long, _ iOrder As long
Struct LVFINDINFO, flags As ulong, _ psz As ptr, _ lParam As ulong, _ pt As ulong, _ 'point structure vkDirection As ulong
Struct listViewConstants, LVP.DBLCLK As long, _ LVS.REPORT As long, _ LVS.SINGLESEL As long, _ LVS.SHOWSELALWAYS As long, _ LVS.NOSORTHEADER As long, _ LVS.EXDOUBLEBUFFER As long, _ LVS.EX.FULLROWSELECT As long, _ LVS.EX.CHECKBOXES As long, _ LVSIL.NORMAL As long, _ LVSIL.SMALL As long, _ LVSIL.STATE As long, _ LVSIL.GROUPHEADER As long, _ LVIS.FOCUSED As long, _ LVIS.UNSELECTED As long, _ LVIS.SELECTED As long, _ LVIS.CHECKED As long, _ LVIS.UNCHECKED As long, _ LVIS.STATEIMAGEMASK As long, _ LVIF.TEXT As long, _ LVIF.STATE As long, _ LVIF.IMAGE As long, _ LVIR.BOUNDS As long, _ LVFI.STRING As long, _ LVFI.PARTIAL As long, _ LVN.ITEMCHANGED As long, _ LVM.ENSUREVISIBLE As long, _ LVM.SETITEMSTATE As long, _ LVM.GETITEMSTATE As long, _ LVM.GETITEMTEXT As long, _ LVM.FINDITEMA As long, _ LVM.SETITEM As long, _ LVM.GETITEMCOUNT As long, _ LVM.GETITEMA As long, _ LVM.GETSUBITEMRECT As long, _ LVM.DELETEITEM As long, _ LVM.INSERTITEM As long, _ LVM.INSERTCOLUMN As long, _ LVM.SETEXTENDEDLISTVIEWSTYLE As long, _ LVM.SETIMAGELIST As long
'Set all of the values for the ListView constants 'LVM_FIRST = &H1000 or 4096 listViewConstants.LVP.DBLCLK.struct = False listViewConstants.LVS.REPORT.struct = 1 listViewConstants.LVS.SINGLESEL.struct = 4 listViewConstants.LVS.SHOWSELALWAYS.struct = 8 listViewConstants.LVS.NOSORTHEADER.struct = 32768 listViewConstants.LVS.EXDOUBLEBUFFER.struct = 10000 listViewConstants.LVS.EX.FULLROWSELECT.struct = 32 listViewConstants.LVS.EX.CHECKBOXES.struct = 4 listViewConstants.LVSIL.NORMAL.struct = 0 listViewConstants.LVSIL.SMALL.struct = 1 listViewConstants.LVSIL.STATE.struct = 2 listViewConstants.LVSIL.GROUPHEADER.struct = 3 listViewConstants.LVIS.FOCUSED.struct = 1 listViewConstants.LVIS.UNSELECTED.struct = 0 listViewConstants.LVIS.SELECTED.struct = 2 listViewConstants.LVIS.CHECKED.struct = 8192 listViewConstants.LVIS.UNCHECKED.struct = 4096 listViewConstants.LVIS.STATEIMAGEMASK.struct = 61440 listViewConstants.LVIF.TEXT.struct = 1 listViewConstants.LVIF.STATE.struct = 8 listViewConstants.LVIF.IMAGE.struct = 2 listViewConstants.LVIR.BOUNDS.struct = 0 listViewConstants.LVFI.STRING.struct = 2 listViewConstants.LVFI.PARTIAL.struct = 8 listViewConstants.LVN.ITEMCHANGED.struct = -101 listViewConstants.LVM.ENSUREVISIBLE.struct = 4115 listViewConstants.LVM.SETITEMSTATE.struct = 4139 listViewConstants.LVM.GETITEMSTATE.struct = 4140 listViewConstants.LVM.GETITEMTEXT.struct = 4141 listViewConstants.LVM.FINDITEMA.struct = 4109 listViewConstants.LVM.SETITEM.struct = 4102 listViewConstants.LVM.GETITEMCOUNT.struct = 4100 listViewConstants.LVM.GETITEMA.struct = 4101 listViewConstants.LVM.GETSUBITEMRECT.struct = 4152 listViewConstants.LVM.DELETEITEM.struct = 4104 listViewConstants.LVM.INSERTITEM.struct = 4103 listViewConstants.LVM.INSERTCOLUMN.struct = 4123 listViewConstants.LVM.SETEXTENDEDLISTVIEWSTYLE.struct = 4150 listViewConstants.LVM.SETIMAGELIST.struct = 4099 End Sub
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function CreateListView(ByRef style, ByRef styleEx, ByRef hParent, ByRef hInstance, ByRef xloc, ByRef yloc, ByRef width, ByRef height) 'style - The style attributes for the ListView 'styleEx - The extended style attributes for the ListView 'hParent - The handle to the Parent window 'hInstance - The handle to the instance of the calling process; use the GetWindowLong() 'xloc - The left side x location to place the ListView on the Parent window 'yloc - The top side y location to place the ListView on the Parent window 'width - The width of the ListView 'height - The height of the ListView 'The return value of the function is the following: ' On Success the return value is the handle to the newly created ListView ' If the function fails, the return value is NULL
className$ = "SysListView32" + chr$(0) CallDLL #user32, "CreateWindowExA", styleEx As ulong, _ ' extended style className$ As ptr, _ ' class name "" As ptr, _ style As ulong, _ ' style xloc As long, _ ' left x yloc As long, _ ' top y width As long, _ ' width height As long, _ ' height hParent As ulong, _ ' parent hWnd _NULL As ulong, _ hInstance As ulong, _ ' hInstance _NULL As ulong, _ CreateListView As ulong 'Hwnd to ListView
'LVCF.WIDTH = 2 : LVCF.TEXT = 4 LVCOLUMN.mask.struct = LVCF.WIDTH OR LVCF.TEXT End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function GetWindowLong(hWnd, index) 'hWnd - A handle to the window which is indirectly ' indicates which class the window belongs to 'index - The zero based offset to the value being retrieved 'The return value of the function is the following: ' On Success the return value is the requested value ' If the function fails, the return value is Zero
CallDLL #user32, "GetWindowLongA", hWnd As ulong, _ index As long, _ GetWindowLong As long End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function GetListViewItemCount(hListView) 'hListView - The handle to the ListView to retrieve the item count from 'The return value is the number of items contained within the ListView
GetListViewItemCount = SendMessage(hListView, listViewConstants.LVM.GETITEMCOUNT.struct, 0, 0) End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function createNewListColumn(hListView, columnIndex, columnWidth, headerCaption$) 'hListView - The handle to the ListView to create the new column in 'columnIndex - The column index to be created 'columnWidth - The width of the column to be created 'headerCaption$ - The string representation of the column caption 'The return value of the function is the following: ' Index of Column - Successful ' -1 - Unsuccessful
LVCOLUMN.cx.struct = columnWidth LVCOLUMN.pszText.struct = headerCaption$ + chr$(0) LVCF.WIDTH = 2 : LVCF.TEXT = 4 LVCOLUMN.mask.struct = LVCF.WIDTH OR LVCF.TEXT createNewListColumn = SendMessageLVCOLUMNStruct(hListView, listViewConstants.LVM.INSERTCOLUMN.struct, columnIndex) End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function AddListViewData(hListView, row, column, myData$, iImage) 'hListView - The handle to the ListView where data is to be added 'row - The row at which data is to be added 'column - The column at which data is to be added 'myData$ - The string representation of the data to be added 'hImage - The zero-based index of the image from the Image List to ' add to the row being created 'The return value is Zero when successful
LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct If (iImage > -1) Then LVITEM.mask.struct = LVITEM.mask.struct Or listViewConstants.LVIF.IMAGE.struct LVITEM.iImage.struct = iImage End If LVITEM.iItem.struct = row LVITEM.iSubItem.struct = column LVITEM.pszText.struct = myData$ result = SendMessageLVITEMStruct(hListView, listViewConstants.LVM.INSERTITEM.struct, 0) AddListViewData = SendMessage(hListView, listViewConstants.LVM.GETITEMSTATE.struct, 0, 0) End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function EditListViewData(hListView, row, column, myData$) 'hListView - The handle to the ListView where data is to be edited 'row - The row at which data is to be edited 'column - The column at which data is to be edited 'myData$ - The string representation of the data to be edited 'The return value of the function is the following: ' True - Successful ' False - Unsuccessful LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = column LVITEM.pszText.struct = myData$ EditListViewData = SendMessageLVITEMStruct(hListView, listViewConstants.LVM.SETITEM.struct, 0) End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function SelectListViewRow(hListView, row, setFocus) 'hListView - The handle to the ListView where the row is to be selected 'row - The row which is to be selected 'setFocus - If set to True; LVIS_FOCUSED is added to the LVITEM.state.struct member ' This causes the row to actually receive the focus instead of just being selected 'The return value of the function is the following: ' True - Successful ' False - Unsuccessful
LVITEM.iItem.struct = row LVITEM.iSubItem.struct = 0 LVITEM.mask.struct = listViewConstants.LVIF.STATE.struct LVITEM.state.struct = listViewConstants.LVIS.SELECTED.struct If setFocus = True Then LVITEM.state.struct = (LVITEM.state.struct Or listViewConstants.LVIS.FOCUSED.struct) End If SelectListViewRow = SendMessage(hListView, listViewConstants.LVM.ENSUREVISIBLE.struct, row, False) SelectListViewRow = SendMessageLVITEMStruct(hListView, listViewConstants.LVM.SETITEM.struct, 0) End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function setListViewFullRowSelect(hListView) 'hListView - The handle to the ListView to set Full Row Select 'The return value is Zero when successful
setListViewFullRowSelect = SendMessage(hListView, 4150, 32, 32)'LVS_EX_FULLROWSELECT End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function listViewShowGrid(hListView) 'hListView - The handle to the ListView to show the grid on 'The return value is Zero when successful
listViewShowGrid = SendMessage(hListView, 4150, 1, 1)'LVS_EX_GRIDLINES End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function SendMessage(hWnd, msg, wParam, lParam) 'hWnd - The handle to send the message to 'msg - The value of the message being sent 'wParam - Message specific information 'lParam - Message specific information 'The return values depends on the message being sent
CallDLL #user32, "SendMessageA" , hWnd As ulong, _ msg As long, _ wParam As long, _ lParam As long, _ SendMessage As long End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function SendMessageLVITEMStruct(hWnd, msg, wParam) 'This function is for use only when lParam needs to be 'the LVITEM Structure 'hWnd - The handle to send the message to 'msg - The value of the message being sent 'wParam - Message specific information 'The return values depends on the message being sent
CallDLL #user32, "SendMessageA" , hWnd As ulong, _ msg As long, _ wParam As long, _ LVITEM As struct, _ SendMessageLVITEMStruct As long End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function SendMessageLVCOLUMNStruct(hWnd, msg, wParam) 'This function is for use only when lParam needs to be 'the LVCOLUMN Structure 'hWnd - The handle to send the message to 'msg - The value of the message being sent 'wParam - Message specific information 'The return values depends on the message being sent
CallDLL #user32, "SendMessageA" , hWnd As ulong, _ msg As long, _ wParam As long, _ LVCOLUMN As struct, _ SendMessageLVCOLUMNStruct As long End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function DestroyWindow(hWnd) 'hWnd - The handle to the window to be destroyed 'The return value of the function is the following: ' Non-zero - Successful ' Zero - Unsuccessful CallDLL #user32, "DestroyWindow", hWnd As ulong, _ DestroyWindow As long End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function GetSelectedListViewRow(hWndLV) 'hWndLV - The handle to the list-view control to get information from 'The return value of the function is the following: ' -1 - Indicates that no row is selected ' Otherwise, indicates the Zero-based row number that is selected GetSelectedListViewRow = -1 numListViewEntries = GetListViewItemCount(hWndLV) For row = 0 To (numListViewEntries - 1) LVITEM.mask.struct = listViewConstants.LVIF.STATE.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = 0 'first column LVITEM.stateMask.struct = listViewConstants.LVIS.SELECTED.struct result = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.GETITEMA.struct, 0) If LVITEM.state.struct And listViewConstants.LVIS.SELECTED.struct Then GetSelectedListViewRow = row Exit Function Else If row = (numListViewEntries - 1) Then GetSelectedListViewRow = -1 Exit Function End If End If Next row End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function GetListViewText$(hWndLV, row, column) 'hWndLV - The handle to the list-view control to get information from 'row - The row to retrive the data from 'column - The column to retrieve the data from 'The return value of the function is the text that resides at the column, row location LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iSubItem.struct = column LVITEM.pszText.struct = Space$(_MAX_PATH) + chr$(0) LVITEM.cchTextMax.struct = Len(Winstring(LVITEM.pszText.struct)) EditListViewData = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.GETITEMTEXT.struct, row) GetListViewText$ = Trim$(Winstring(LVITEM.pszText.struct)) End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function Sleep(milliseconds) 'milliseconds - The number of milliseconds to sleep the process for 'This funciton has no return value. CallDLL #kernel32, "Sleep", milliseconds As ulong, _ ret As void End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function shiftLeft(value, bitsToShift) 'value - The value to be shifted to the left 'bitsToShift - The number of bits to shift value by 'The return value of the function is the new value shiftLeft = (value * (2^bitsToShift)) End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function createImageList(sizeX, sizeY, flags, numImages, canGrowBy) 'sizeX - The width, in pixels, of images that will be added 'sizeY - The height, in pixels, of images that will be added 'flags - A set of bit flags that specify the type of image list to create ' This is a combination of the Image List Creation Flags 'numImages - The number of images that the image list initially contains 'canGrowBy - The number of images that can be added to the image list 'The return value of the function is the following: ' The handle to the created image list if successful ' NULL if unsuccessful CallDLL #comctl32, "ImageList_Create", sizeX As long, _ sizeY As long, _ flags As ulong, _ numImages As long, _ canGrowBy As long, _ createImageList As ulong End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function addImageToImageList(hImageList, hBitmap, hBitmapMask) 'hImageList - The handle to the image list to add the image to 'hBitmap - The handle to the bitmap that contains the image/images 'hBitmapMask - The handle to the bitmap that contains the mask; ' This can be NULL if no mask is used 'The return value of the function is the following: ' -1 - Not Successful ' Otherwise returns the index of the first new image CallDLL #comctl32, "ImageList_Add", hImageList As ulong, _ hBitmap As ulong, _ hBitmapMask As ulong, _ addImageToImageList As long End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function destroyImageList(hImageList) 'hImageList - The handle to the image list to destroy 'The return value of the function is the following: ' Zero - Not Successful ' Non-zero - Successful CallDLL #comctl32, "ImageList_Destroy", hImageList As ulong, _ destroyImageList As long End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function setListViewImageList(hWndLV, hImageList, iImageList) 'hWndLV - The handle to the list-view control to add the image list to 'hImageList - The handle to the image list to assign to the list-view 'iImageList - The type of image list being added ' - LVSIL_NORMAL = 0 ' - LVSIL_SMALL = 1 ' - LVSIL_STATE = 2 ' - LVSIL_GROUPHEADER = 3 'The return value of the function is the following: ' Returns the handle of the previously associated image list; NULL otherwise setListViewImageList = SendMessage(hWndLV, listViewConstants.LVM.SETIMAGELIST.struct, iImageList, hImageList) End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function getSystemMetrics(nIndex) 'nIndex - System metric or configuration to be retrieved 'The return value of the function is based on the nIndex value used CallDLL #user32, "GetSystemMetrics", nIndex As long, _ getSystemMetrics As long End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function loadIcon(hInst, file$, sizeX, sizeY, fuLoad) 'hInst - The instance handle to the module; ust GetWindowLong() here 'file$ - The complete filepath to the icon to be loaded ' fuLoad requires _LR_LOADFROMFILE 'sizeX - Width in pixels of the icon ' Use Zero and OR _LR_DEFAULTSIZE to fuLoad, or use _SMCXICON for default icon size ' If parameter is zero and _LR_DEFAULTSIZE is not used actual width is used 'sizeY - Height in pixels of the icon ' Use Zero and OR _LR_DEFAULTSIZE to fuLoad, or use _SMCYICON for default icon size ' If parameter is zero and _LR_DEFAULTSIZE is not used actual height is used 'fuLoad - Flags to tell the function how to behave ' Use (_LR_LOADFROMFILE Or _LR_DEFAULTSIZE) 'The return value of this function is a handle to the icon loaded from the file if successful; 'otherwise, the return value is NULL file$ = file$ + chr$(0) CallDLL #user32, "LoadImageA", hInst As ulong, _ file$ As ptr, _ _IMAGE_ICON As ulong, _ sizeX As long, _ sizeY As long, _ fuLoad As ulong, _ loadIcon As ulong End Function
'_______________________________________________________________________________________________________________________________________ '_______________________________________________________________________________________________________________________________________
Function destroyIcon(hIcon) 'hIcon - The handle to the icon to be destroyed 'The return value of the function is the following: ' Zero - Not Successful ' Non-zero - Successful CallDLL #user32, "DestroyIcon", hIcon As ulong, _ destroyIcon As long End Function
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function isBitMap(BMPName$) 'BMPName$ - The name of the bitmap to check existence 'The return value of the function is the following: ' Zero - The bitmap does not exist ' Non-zero - The bitmap exists, and the return value ' is the handle of the bitmap On Error GoTo [Error] isBitMap = Hbmp(BMPName$) [Error] End Function
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
{:0)
Brandon Parker
|
|