ツリービューAPIでチェックボックス!!

Ver6.0からは不要ですね。f(^^;;
まぁ、Ver5などではこれしかないので必要であればどうぞ。



サンプルの一部です。

Public Function IsTVItemChecked(hwndTV As Long, hItem As Long) As Boolean
   Dim tvi As TVITEM

   With tvi
      .mask = TVIF_STATE
      .hItem = hItem
      .stateMask = TVIS_STATEIMAGEMASK
   End With
   
   Call TreeView_GetItem(hwndTV, tvi)
   
   IsTVItemChecked = (tvi.state And INDEXTOSTATEIMAGEMASK(IIL_CHECKED))
End Function

Public Function IsTVItemCheckedFromClick(hWnd As Long, x As Long, y As Long) As Boolean
   Dim tvhTI As TVHITTESTINFO
   Dim fChecked As Boolean
    
   tvhTI.pt.x = x
   tvhTI.pt.y = y
  
   If TreeView_HitTest(hWnd, tvhTI) Then
      fChecked = IsTVItemChecked(hWnd, tvhTI.hItem)
      If (tvhTI.flags And TVHT_ONITEMSTATEICON) Then fChecked = Not fChecked
      IsTVItemCheckedFromClick = fChecked
   End If
End Function

Public Function TreeView_HitTest(hWnd As Long, lpHT As TVHITTESTINFO) As Long
   TreeView_HitTest = SendMessageAny(hWnd, TVM_HITTEST, 0&, lpHT)
End Function

    

サンプル TreeViewCheckBoxAPI.LZH