RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
So I have a bunch of controls on a page - 140 image controls (without the images) whose backcolor changes from vbGreen to vbRed based on some criteria. Code works, things turn different colors, all is great! Only I can see flickering of the controls as the code runs. Actually posting the code is not the important thing (figured it might provide context) - I'm using these image controls just as a rectangular shape.
code portion
The code I'm interested in follows below. Found it on a different site. I was curious as to how it works. Does the entire code base get posted in a class called Freeze? Also the author mentioned you call a class Freeze as follows:
I guess the bottom line is that I'm just not sure how it all works.
Class Code?
code portion
VBA Code:
'Change colors of image controls
For Each Ctrl In Me.Controls
If Left(Ctrl.Name, 3) = "FP4" And Ctrl.Tag = "Plate" Then
'Find the row of the plate position
lRow = WorksheetFunction.Match(Right(Ctrl.Name, 3), rRange, 0)
'Here is the criteria to decide contol backcolor
If wSht.Cells(lRow, rRange.Column + 1) > CLng(Me.FP4_AgeTB.Value) Then
Ctrl.BackColor = vbRed
ElseIf wSht.Cells(lRow, rRange.Column + 1) <= CLng(Me.FP4_AgeTB.Value) Then
Ctrl.BackColor = vbGreen
End If
End If
Next Ctrl
The code I'm interested in follows below. Found it on a different site. I was curious as to how it works. Does the entire code base get posted in a class called Freeze? Also the author mentioned you call a class Freeze as follows:
I guess the bottom line is that I'm just not sure how it all works.
VBA Code:
Dim Freeze as New Freeze
Freeze.Form Me
Class Code?
VBA Code:
'declare function to stop window flickering when loading / updating forms
Private Declare Function LockWindowUpdate Lib _
"USER32" (ByVal hwndLock As Long) As Long
Option Explicit
Public Sub Form(pForm As Form)
LockWindowUpdate pForm.hWnd
End Sub
Private Sub Class_Initialize()
'check who called the class
End Sub
Private Sub Class_Terminate()
LockWindowUpdate False
End Sub