Thanks for replying Stephen.
This is what I have done thus far.
I changed the default in the Class_Initialize in your clsAlternateColor
module to HighlightCurrentRow and changed the last IF statement in your
DrawRect procedure, see below.
I also changed the FrameHighlight default value to 5 and the OptionValue
for
Option34 to 5 in your AlternateColor form. The current row will highlight
as
long as the top row shown in the form is first record. I still have to
review more of your code to determine the 'toprow' and to make it
highlight
the correct row.
Rex
Private Sub Class_Initialize()
' Default border width of frame we draw
' around the control
m_BorderWidth = 6
' Default draw Alternate Rows of Color.
m_HighlightRoworControlOrColumn = HighlightCurrentRow
'HighlightAlternateRows
' Default Alternate Color = RED
m_HighlightColor = vbRed
End Sub
Public Sub DrawRect(row As Long, RowColor As Long)
' Row is a zero based index
' RowColor is desired color
' CriControl is the control we will use if
' we are only shading behind a single control
' or we are shading an entire column.
' Draw rectangle onto our background Bitmap
' REMOVE THIS IN PRODUCTION CODE
' ADD YOUR OWN ERROR HANDLING!
On Error Resume Next
' Temp vars
Dim hNewBrush As Long
Dim rc As RECT
Dim lngLeft As Long, lngWidth As Long
' loop counter
Dim x As Long
' Create a Brush in the desired color
Select Case m_HighlightRoworControlOrColumn
Case HighlightNothing
'Do Nothing!
Exit Sub
Case HighlightColumnControl, HighlightAlternateRows
hNewBrush = apiCreateSolidBrush(m_HighlightColor) 'RGB(255, 0, 0))
'Debug.Print "created brush"
Case Else
hNewBrush = apiCreateSolidBrush(RowColor)
End Select
'Debug.Print "m_Form.Controls(Testcolumn).Left" & m_Form.Controls
("testcolumn").Left
Select Case m_HighlightRoworControlOrColumn
Case HighlightNothing
'Do Nothing!
Case HighlightControl
' Row height is independant of width
rc.Top = m_HeaderHeightPixels
rc.Top = rc.Top + (row * m_DetailRowHeight)
rc.Bottom = rc.Top + m_DetailRowHeight
'lngLeft = TwipsToPixels((m_Form.Controls("testcolumn").Left) - 1,
Horiz)
lngLeft = TwipsToPixels(m_CriteriaControl.Left - 1, Horiz)
'lngLeft = TwipsToPixels(m_CriteriaControl.Left - 1, Horiz)
'Debug.Print "lngLeft:" & lngLeft
'Debug.Print
lngWidth = TwipsToPixels((m_CriteriaControl.width) - 1, Horiz)
'lngWidth = TwipsToPixels((m_CriteriaControl.width) + 1, Horiz)
'Debug.Print "m_Form.Controls(Testcolumn).Width" & m_Form.Controls
("testcolumn").width
'Debug.Print "lngWidth:" & lngWidth
'Debug.Print
rc.Left = (lngLeft - m_BorderWidth) + m_RecordSelectorWidth
rc.Right = rc.Left + lngWidth + (m_BorderWidth * 2)
Case HighlightRow, HighlightAlternateRows, HighlightCurrentRow
' Row height is independant of width
rc.Top = m_HeaderHeightPixels
rc.Top = rc.Top + (row * m_DetailRowHeight)
rc.Bottom = rc.Top + m_DetailRowHeight
' Fill the entire row
rc.Left = 0
rc.Right = m_bmi.bmiHeader.biWidth
Case HighlightColumnControl
rc.Top = m_HeaderHeightPixels
lngWidth = TwipsToPixels((m_HighlightColumn.width) - 1, Horiz)
'lngWidth = TwipsToPixels((m_HighlightColumn.width) + 1, Horiz)
lngLeft = TwipsToPixels(m_HighlightColumn.Left - 1, Horiz)
rc.Left = (lngLeft - m_BorderWidth) + m_RecordSelectorWidth
rc.Right = rc.Left + lngWidth + (m_BorderWidth * 2)
rc.Bottom = rc.Top + ((m_Form.RecordsetClone.RecordCount + 1) -
m_TopRow) * m_DetailRowHeight
Case Else
End Select
If m_HighlightRoworControlOrColumn = HighlightAlternateRows Then
' 'Only print even numbered rows
If (row Mod 2) = 0 Then
' Draw the Rectangle
Call apiFillRect(m_hDC, rc, hNewBrush)
End If
ElseIf m_HighlightRoworControlOrColumn = HighlightCurrentRow Then
'Added this IF statement
If row = m_Form.CurrentRecord - 1 Then
Call apiFillRect(m_hDC, rc, hNewBrush) 'Draw the Rectangle
End If
Else
Call apiFillRect(m_hDC, rc, hNewBrush)
End If
Call DeleteObject(hNewBrush)
End Sub
Stephen said:
Post your code behind the Form you are working with.
I would like to use Stephen Lebans AlternateColorDetailSection class to
highlight the current row in a continuous form. The code seems to
[quoted text clipped - 4 lines]