'listview column
'   %LVS_REPORT样式的列表视图中插入一列。
'   hWndControl:    控件的句柄 (例如  HWND_FORM1_LISTVIEW1)   
'   iPosition:      要插入新列，从零开始位置。
'   TheText:        表示要显示的文本的字符串。  
'   nAlignment:     %LVCFMT_CENTER      文本居中
'                   %LVCFMT_LEFT        文本是左对齐
'                   %LVCFMT_RIGHT       文本为右对齐
'   nWidth:         列的宽度，以像素为单位。
'   Returns:        如果成功的话，新列的索引，否则为-1。
Function FF_ListView_InsertColumn(ByVal hWndControl as HWnd, ByVal iPosition as Long, ByRef TheText as CWSTR , ByVal nAlignment as Long = LVCFMT_LEFT, ByVal nWidth as Long = 100) as Integer
   
   Dim tlvc as LV_COLUMNW
   
   '检查窗口句柄是否有效
   If IsWindow(hWndControl) Then
      
      tlvc.mask = LVCF_FMT Or LVCF_WIDTH Or LVCF_TEXT Or LVCF_SUBITEM
      tlvc.fmt = nAlignment
      tlvc.cx = nWidth
      tlvc.pszText =Cast(LPWSTR, TheText.vptr )
      tlvc.iSubItem = 0
      Function = SendMessageW(hWndControl, LVM_INSERTCOLUMNW, iPosition, Cast(LPARAM, VarPtr(tlvc)))
      
   End If
   
End Function

