Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As
Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long,
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const SWP_NOZORDER As Long = &H4
Private Const SWP_SHOWWINDOW As Long = &H40
Private Sub ReportControl1_BeginEdit(ByVal Row As
XtremeReportControl.IReportRow, ByVal Column As
XtremeReportControl.IReportColumn, ByVal Item As
XtremeReportControl.IReportRecordItem)
' Set the edit window position to match the text vertically aligned position
Dim l_Left As Long, l_Top As Long, l_Right As Long, l_Bottom As Long
Dim lo_OldFont As StdFont
Dim l_TextHeight As Long
Dim l_Offset As Long
If Row Is Nothing Then Exit Sub
If Item Is Nothing Then Exit Sub
If Me.ReportControl1.InplaceEditHwnd = 0 Then Exit Sub
' Get the height of the font
Set lo_OldFont = UserControl.Font
Set Me.Font = Me.ReportControl1.PaintManager.TextFont
l_TextHeight =
Me.ScaleY(Me.TextHeight("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()_+-={}\[]|:"";'<>,.?/~`"),
Me.ScaleMode, vbPixels)
Set Me.Font = lo_OldFont
' Get the RECT of the Cell
Row.GetItemRect Item, l_Left, l_Top, l_Right, l_Bottom
' Calculate the offset for the edit window
l_Offset = Int((l_Bottom - l_Top) / 2 + 0.5) - Int((l_TextHeight / 2)
+ 0.5) - IIf((l_Bottom - l_Top) Mod 2 = 0, 1, 2) ' Probably a better
way to do this but it works for now across a range of row heights that I tested
' Add the offset to the TOP position, and subtract it from the HEIGHT of the edit window
SetWindowPos Me.ReportControl1.InplaceEditHwnd, 0, l_Left + 2, l_Top +
l_Offset, l_Right, l_Bottom - l_Offset, SWP_NOZORDER + SWP_SHOWWINDOW
End Sub
|