Author Topic: EGrid Pro 相關的程序函數庫  (Read 3789 times)

admin

  • Administrator
  • *****
  • Posts: 0
    • View Profile
EGrid Pro 相關的程序函數庫
« on: November 11, 2011, 01:06:54 PM »
 設定欄數, 不可少於1, 因為Egrid32 不容許刪除第一欄
Code: [Select]
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時, 自動隱蔵第一列
Code: [Select]
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不容許刪除第一列, 所以自動隱蔵第一列
Code: [Select]
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


Code: [Select]
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


Code: [Select]
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
 


Code: [Select]
 
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

Code: [Select]
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

Code: [Select]

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

Code: [Select]
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

Code: [Select]
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

Code: [Select]
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
« Last Edit: December 04, 2011, 04:24:36 PM by Roy Chan »