I've coded myself into a corner, and I don't even know which terms/words to use to search for a solution to solve my problem. My original goal was that I noticed I was using the same kinds of controls and control names for multiple forms: lblTitleBar, lblCmd1, lblCmd2, cmdTmr, etc. I figured that I could consolidate this duplicated code into a class and create an instance on each form. At that point, my basic controls would be setup, formatted, and ready to use for each form. As it stands now, the visible GUI part is working as planned, but I can't figure out how to now capture the events for these objects. Am I not setting them up properly? Is there a way I can pass basic VB events (Click, DblClick, MouseMove, etc) to the class or reference these events on the parent form?
Now, I've seen that I can create the variables on each form and then, they will work as planned, but it would kinda defeat the purpose of trying to centralize the code if I still need to have multiple variable declarations, etc per form, no?
VB Code:
Option Explicit
'clsForm
Public lblTitleBar As Label
Public lblCmd1 As Label
Public lblCmd2 As Label
Private foForm As Form
Private cmdTmr As Timer
Private shpTitleBar As Shape
Private shpForm As Shape
Public Sub NewObject(ByRef roForm As Form)
Dim li As Integer
Set foForm = roForm
Set lblTitleBar = foForm.Controls.Add("VB.Label", "lblTitleBar")
Set lblCmd1 = foForm.Controls.Add("VB.Label", "lblCmd1")
Set lblCmd2 = foForm.Controls.Add("VB.Label", "lblCmd2")
Set cmdTmr = foForm.Controls.Add("VB.Timer", "cmdTmr")
Set shpTitleBar = foForm.Controls.Add("VB.Shape", "shpTitleBar")
Set shpForm = foForm.Controls.Add("VB.Shape", "shpForm")