Hi,
I have this code to set all forms and controls in my program to a colour of my choosing.
My question is that if the above is situated in a module how do I tell it to apply the operation to the form without specifying the form name basically generics?
Thanks,
Nightwalker
I have this code to set all forms and controls in my program to a colour of my choosing.
vb Code:
Public Sub colour() Static lngCustom(15) As Long Static lngCurrent As Long Dim lngHandle As Long Dim lngResult As Long Dim uCol As CHOOSECOLOR 'Apply colour to forms uCol.lStructSize = Len(uCol) uCol.hwndOwner = frmMain.hwnd uCol.lpCustColors = VarPtr(lngCustom(0)) uCol.rgbResult = lngCurrent uCol.Flags = CC_FULLOPEN Or CC_RGBINIT lngResult = CHOOSECOLOR(uCol) If uCol.rgbResult = vbBlack Then Exit Sub For Each objForm In Forms If lngResult <> 0 Then 'Customise the colour of the program objForm.BackColor = uCol.rgbResult End If Set objForm = Nothing Next objForm 'Apply color to controls For Each cntrl In frmSetup.Controls If TypeOf cntrl Is Frame Or TypeOf cntrl Is OptionButton Or TypeOf cntrl Is CommandButton Then cntrl.BackColor = uCol.rgbResult End If Set cntrl = Nothing Next cntrl For Each cntrl In frmMain.Controls If TypeOf cntrl Is Frame Or TypeOf cntrl Is OptionButton Or TypeOf cntrl Is CommandButton Or TypeOf cntrl Is Label Then cntrl.BackColor = uCol.rgbResult End If Set cntrl = Nothing Next cntrl End Sub
My question is that if the above is situated in a module how do I tell it to apply the operation to the form without specifying the form name basically generics?
Thanks,
Nightwalker