Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode=1
%IDC_Checks = 500
%IDC_ListView = 502
#Include "win32api.inc"
Global hDlg,hListView As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "ListView Test",300,300,200,180,%WS_OverlappedWindow To hDlg
Control Add CheckBox, hDlg, %IDC_Checks, "Show CheckBoxes", 10,10,150,20
Control Set Check hDlg, %IDC_Checks, %True
Control Add ListView, hDlg, %IDC_ListView, "", 10,40,180,135
Control Handle hDlg, %IDC_ListView To hListView
ListView Set StyleXX hDlg, %IDC_ListView, %LVS_Ex_CheckBoxes
ListView Insert Column hDlg, %IDC_ListView, 1, "Test", 180, 0
ListView Insert Item hDlg, %IDC_ListView, 1, 1, "Line 1"
ListView Insert Item hDlg, %IDC_ListView, 2, 1, "Line 2"
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local Style,iChecked As Long
If Cb.Msg = %WM_Command And Cb.Ctl = %IDC_Checks And Cb.CtlMsg = %BN_Clicked Then
'this works - changing style using macro
If 1 Then
Control Get Check hDlg, %IDC_Checks To iChecked
If iChecked Then
ListView_SetExtendedListViewStyle hListView, %LVS_Ex_CheckBoxes
Else
ListView_SetExtendedListViewStyle hListView, 0
End If
End If
'this works - changing style using macro
If 0 Then
Style = ListView_GetExtendedListViewStyle(hListView)
ListView_SetExtendedListViewStyle hListView, Style Xor %LVS_Ex_CheckBoxes
End If
'this works - changing style using API directly
If 0 Then
Control Get Check hDlg, %IDC_Checks To iChecked
If iChecked Then
SendMessage hListview, %LVM_SetExtendedListViewStyle, %LVS_Ex_CheckBoxes, %LVS_Ex_CheckBoxes
Else
SendMessage hListview, %LVM_SetExtendedListViewStyle, %LVS_Ex_CheckBoxes, 0
End If
End If
'this works - changing to 1x1 imagelist
If 0 Then
Control Get Check hDlg, %IDC_Checks To iChecked
If iChecked Then
ListView Set StyleXX hDlg, %IDC_ListView, %LVS_Ex_CheckBoxes
Else
ListView Set StyleXX hDlg, %IDC_ListView, 0
End If
End If
'this does not work - using SetWindowLong
If 0 Then
Control Get Check hDlg, %IDC_Checks To iChecked
SetWindowLong hListView, %GWL_ExStyle, GetWindowLong(hListView,%GWL_Exstyle) Xor %LVS_Ex_CheckBoxes
SetWindowPos hListView,0,0,0,0,0, %SWP_NoMove Or %SWP_NoSize Or %SWP_DrawFrame
Control ReDraw hDlg, %IDC_ListView
Dialog ReDraw hDlg
End If
End If
End Function
'gbs_01258
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm