設定欄數, 不可少於1, 因為Egrid32 不容許刪除第一欄
Sub EG_SetColumnCount( ByVal hWndControl As Dword,NewColumnCount As Long,SizeOfNewColumns As Long)
Local ColumnCount As Long
ColumnCount=SendMessage(hWndControl, %EG_GETMAXCOLUMNS, 0, 0)
If columncount <1 Then
columncount=1
End If
If newcolumncount > columncount Then
SendMessage(hWndControl, %EG_APPENDCOLUMN,newcolumncount-columncount, SizeOfNewColumns&)
ElseIf newcolumncount < columncount Then
SendMessage(hWndControl, %EG_KILLCOLUMN, columncount - newcolumncount, 0)
End If
End Sub
設定列數, 因為Egrid32不容許刪除第一列, 所以設定列數為0時, 自動隱蔵第一列
Sub EG_SetRowCount( ByVal hWndControl As Dword,NewRowCount As Long, SizeOfNewRows As Long)
Local RowCount As Long
RowCount = SendMessage(hWndControl, %EG_GETMAXROWS, 0, 0)
If newrowcount <0 Then
newrowcount=0
End If
If newrowcount >0 Then
SendMessage(hWndControl, %EG_INTERNALSELECTUD, 1, 1)
SendMessage(hWndControl, %EG_HIDEROW, %false, 0)
If newrowcount > rowcount Then
SendMessage(hWndControl, %EG_APPENDROW, newrowcount - rowcount, SizeOfNewRows&)
ElseIf newrowcount < rowcount Then
SendMessage(hWndControl, %EG_KILLROW, rowcount - newrowcount, 0)
End If
Else
SendMessage(hWndControl, %EG_KILLROW, rowcount-1 , 0)
SendMessage(hWndControl, %EG_INTERNALSELECTUD, 1, 1)
SendMessage(hWndControl, %EG_HIDEROW, %TRUE, 0)
End If
SendMessage(hWndControl, %EG_REFRESHALL, 0, 0)
End Sub
移除全部列數, 因為Egrid32不容許刪除第一列, 所以自動隱蔵第一列
Sub EG_RemoveAllRows( ByVal hWndControl As Dword)
Local RowCount As Long
RowCount = SendMessage(hWndControl, %EG_GETMAXROWS, 0, 0)
If rowcount >0 Then
SendMessage(hWndControl, %EG_KILLROW, rowcount-1 , 0)
SendMessage(hWndControl, %EG_INTERNALSELECTUD, 1, 1)
SendMessage(hWndControl, %EG_HIDEROW, %TRUE, 0)
End If
End Sub
Sub EG_SetColumnHeaderCaption( ByVal hWndControl As Dword, ByVal ColumnIndex As Long, ByVal Caption As String)
SendMessage hWndControl, %EG_INTERNALSELECTTL, ColumnIndex, 0
SendMessage hWndControl, %EG_SETCELLTEXT, StrPtr(Caption), Len(Caption)
End Sub
Sub EG_SetColumnVisible(ByVal hWndControl As Dword, ByVal ColumnIndex As Long,ByVal IsVisible As Long)
SendMessage(hWndControl, %EG_INTERNALSELECTLR, columnindex, columnindex)
If Isvisible=%true Then
SendMessage(hWndControl,%EG_HIDECOLUMN, %false, 0)
Else
SendMessage(hWndControl,%EG_HIDECOLUMN, %true, 0)
End If
End Sub
Sub EG_SetColumnHeaderVerticalAlignment(ByVal hWndControl As Dword,ByVal AlignType As Long)
Local ColumnCount As Long
ColumnCount=SendMessage(hWndControl, %EG_GETMAXCOLUMNS, 0, 0)
SendMessage(hWndControl, %EG_INTERNALSELECTTL,0,0 )
SendMessage(hWndControl, %EG_INTERNALSELECTBR, columncount,0)
SendMessage(hWndControl, %EG_SETVERTALIGN, AlignType, 0)
SendMessage(hWndControl, %EG_REFRESHALL, 0, 0)
End Sub
Sub EG_SetColumnHeaderHorizonAlignment(ByVal hWndControl As Dword,ByVal AlignType As Long)
Local ColumnCount As Long
ColumnCount=SendMessage(hWndControl, %EG_GETMAXCOLUMNS, 0, 0)
SendMessage(hWndControl, %EG_INTERNALSELECTTL,0,0 )
SendMessage(hWndControl, %EG_INTERNALSELECTBR, columncount,0)
SendMessage(hWndControl, %EG_SETHORZALIGN, AlignType, 0)
SendMessage(hWndControl, %EG_REFRESHALL, 0, 0)
End Sub
Sub EG_AddRowData (ByVal hWndControl As Dword,ByVal tmpRowData As String)
Local StringT As StringType
Local RowIndex As Long
StringT.Sptr = StrPtr(tmpRowData)
StringT.Length = Len(tmpRowData)
If EG_CheckFirstRow(hWndControl)=%true Then
SendMessage(hWndControl, %EG_INTERNALSELECTUD, 1, 1)
SendMessage(hWndControl, %EG_HIDEROW, %false, 0)
Else
SendMessage(hWndControl, %EG_APPENDROW, 1, %Null)
End If
Rowindex = SendMessage(hWndControl, %EG_GETMAXROWS, 0, 0)
SendMessage( hWndControl, %EG_SETGRIDTEXTLINE, Rowindex, VarPtr(StringT))
End Sub
Function EG_CheckFirstRow( ByVal hWndControl As Dword) As Long
Local tmpResult As Long
Local RowCount As Long
Local IsRowHidden As Long
Rowcount = SendMessage(hWndControl, %EG_GETMAXROWS, 0, 0)
If rowcount =1 Then
isrowhidden= SendMessage(hWndControl, %EG_GETHIDEROW, 1, 0)
If isrowhidden=-1 Then
tmpresult=%true
Else
tmpresult=%false
End If
Else
tmpresult =%false
End If
Function = tmpresult
End Function
Sub EG_DeleteRow( ByVal hWndControl As Dword,ByVal tmpRow As Long)
Local tmpRows As Long
tmpRows = SendMessage(hWndControl, %EG_GETMAXROWS, 0, 0)
If tmprows >1 Then
SendMessage(hWndControl, %EG_DELETEROW, tmprow, %false)
SendMessage(hWndControl, %EG_KILLROW , 1, 0)
Else
SendMessage(hWndControl, %EG_INTERNALSELECTUD, 1, 1)
SendMessage(hWndControl, %EG_HIDEROW, %TRUE, 0)
End If
SendMessage(hWndControl, %EG_REFRESHALL, 0, 0)
End Sub
Function EG_CheckRemainRows ( ByVal hWndControl As Dword) As Long
Local tmpResult As Long
Local IsRowHidden As Long
tmpResult = SendMessage(hWndControl, %EG_GETMAXROWS, 0, 0)
If tmpresult=1 Then
isrowhidden= SendMessage(hWndControl, %EG_GETHIDEROW, 1, 0)
If isrowhidden=-1 Then
tmpresult=0
End If
End If
Function = tmpresult
End Function