The CForm Changer Class

As mentioned previously in this chapter, API calls are much easier to use when they are encapsulated within a class module. The CFormChanger class included in the FormFun.xlsm file at www.wrox.com repeats the previous code snippet for all the windows style bits mentioned in the previous section, presenting them as the following properties of the class:

Modal

Sizeable

ShowCaption

SmallCaption

ShowIcon

IconPath (to show a custom icon)

ShowCloseBtn

ShowMaximizeBtn

ShowMinimizeBtn

ShowSysMenu

ShowTaskBarIcon

To use the class on your own forms, copy the entire class module into your project and call it from your form's Activate event, as in the following example. You can find this example in the ToolbarForm.xlsm workbook at www.wrox.com:

Private Sub UserForm_Activate()

Dim oChanger As CFormChanger

'Create a new instance of the CFormChanger class Set oChanger = New CFormChanger

'Set the form changer's properties oChanger.SmallCaption = True oChanger.Sizeable = True

'Tell the changer which form to apply the style changes to. 'Also acts as the trigger for applying them Set oChanger.Form = Me

End Sub

0 -1

Post a comment