From: RexAbandon via AccessMonster.com on
I would like to use Stephen Lebans AlternateColorDetailSection class to
highlight the current row in a continuous form. The code seems to accomodate
this option but I cannot get it to work.

Has anyone tried this?


Rex

--
Message posted via http://www.accessmonster.com

From: Stephen Lebans on
Post your code behind the Form you are working with.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"RexAbandon via AccessMonster.com" <u14151(a)uwe> wrote in message
news:66946b0d4b61c(a)uwe...
>I would like to use Stephen Lebans AlternateColorDetailSection class to
> highlight the current row in a continuous form. The code seems to
> accomodate
> this option but I cannot get it to work.
>
> Has anyone tried this?
>
>
> Rex
>
> --
> Message posted via http://www.accessmonster.com
>


From: RexAbandon via AccessMonster.com on
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 Lebans wrote:
>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]
>>
>> Rex

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200609/1

From: Stephen Lebans on
Hi Rex,
I asked you to post the code behind your form. I just want to ensure you are
setting up the class correctly. Also if you start making changes to my
underlying Class then you are on your own,

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"RexAbandon via AccessMonster.com" <u14151(a)uwe> wrote in message
news:66a188db1e2f9(a)uwe...
> 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 Lebans wrote:
>>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]
>>>
>>> Rex
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200609/1
>


From: RexAbandon via AccessMonster.com on
Hi Stephen,

I basically took the AlternateColor form in your downloaded and added a line
at the end of the form load procedure as follows:
fbc.HighlightRoworControlOrColumn = 5

I also changed the FrameHighlight default value to 5 and the OptionValue for
Option34 to 5 in the same form.

If the underlying class is left as is, all the rows highlight, not the
current row.

The code behind the form is:

Option Compare Database
Option Explicit
' Copyright Lebans Holdings 1999 Ltd.
' Alternate Colors for each row of the Detail Section.


' Var of type our class
Private fbc As clsAlternateColor

' Temp var for the Class
Dim blRet As Boolean


Private Sub Form_Load()
If Me.RecordSelectors = False Then
DoCmd.MoveSize 0, 0, 8200, 5350
Else
DoCmd.MoveSize 0, 0, 8500, 5350
End If

' Create a new instance of our AlternateColor class
Set fbc = New clsAlternateColor

' You MUST set the Form prop
fbc.SetForm Me
fbc.HighlightRoworControlOrColumn = 5 'Added

End Sub

Private Sub Form_Resize()
If Not fbc Is Nothing Then
' We have resized. Create a New Bitmap
' to match our new Detail size.
fbc.Create
fbc.UpdateScreen
End If

End Sub

Private Sub Form_Unload(Cancel As Integer)
' Release our reference to the class
Set fbc = Nothing
End Sub


Private Sub FrameHighlight_AfterUpdate()
' Do we highlight or not?
fbc.HighlightRoworControlOrColumn = FrameHighlight
' Redraw the screen for our new setting to take effect
fbc.UpdateScreen
End Sub



Private Sub cmdColor_Click()
On Error GoTo Err_cmdColor_Click

' Call the API Color Dialog
fbc.HighlightColor = ShowColorDialog(fbc.HighlightColor)
' Update the display
fbc.UpdateScreen


Exit_cmdColor_Click:
Exit Sub

Err_cmdColor_Click:
MsgBox Err.Description
Resume Exit_cmdColor_Click

End Sub