event ModalPropertyChange (Property as Property, Value as Variant, Cancel as Boolean)

Fired when the properties browser is about to change a property's value using a modal dialog.

 TypeDescription 
   Property as Property A Property object being changed using a modal dialog.  
   Value as Variant A Variant expression that indicates the newly property's value.  
   Cancel as Boolean A boolean expression that indicates whether the control disables or enables the default implementation.  

Use the ModalPropertyChange event to replace the default implementation of modal type editors ( IFontDisp (font) properties, IPictureDisp (picture) properties, object properties pages, EditPage, EditColorPage, EditButton types ). The "Invalid property value" message is displayed if the Property does not accept the Value. To avoid showing error messages set the InvalidValueMessage property to an empty string. 

The following sample replaces the editor for properties of IPictureDisp (picture) type ( the sample uses Type property of the Property to check the property's type. The sample doesn't use the statement typeof Property.Object is IPictureDisp because the Object property might be set to nothing, and so the operator typeof will be unable to determine the type of the object ):

Private Sub PropertiesList1_ModalPropertyChange(ByVal Property As EXPROPERTIESLISTLibCtl.IProperty, Value As Variant, Cancel As Boolean)
    If Property.Type = "Picture*" Then
        MsgBox "Invoke your dialog here, and change the Value parameter, when your dialog is closed."
        Value = StdFunctions.LoadPicture("c:\winnt\system32\setup.bmp")
        Cancel = True
    End If
End Sub

The following sample shows how to change the default font editor:

Private Sub PropertiesList1_ModalPropertyChange(ByVal Property As EXPROPERTIESLISTLibCtl.IProperty, Value As Variant, Cancel As Boolean)
    If (Property.Type = "Font*") Then
        MsgBox "Use your implementation here"
        Set Value = Me.Font
        Cancel = True
    End If
End Sub

Send comments on this topic.
© 1999-2008 Exontrol Inc, Software. All rights reserved.