Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1110
Changing the image in a messagebox UltraMessageboxManager
posted

I want to change the image (?, !, etc) in a messagebox styled with the ultramessageboxmanager.

I have created a new class that inherits from UltraMessageBoxManager and implemented a DrawFilter but if I set the new image I get an exception. This is the function I use:

    Public Function GetPhasesToFilter(ByRef drawParams As Infragistics.Win.UIElementDrawParams) As Infragistics.Win.DrawPhase Implements IUIElementDrawFilter.GetPhasesToFilter

        If (TypeOf drawParams.Element Is ImageAndTextUIElement.ImageAndTextDependentImageUIElement) Then

            Return DrawPhase.BeforeDrawElement
        Else
            Return DrawPhase.None
        End If

    End Function

Public Function DrawElement(ByVal drawPhase As Infragistics.Win.DrawPhase, ByRef drawParams As Infragistics.Win.UIElementDrawParams) As Boolean Implements IUIElementDrawFilter.DrawElement

 

        ReplaceImage(drawParams.Element, _img)

        ' Return false to allow the phase to continue
        Return False
End Function

 

    Private Sub ReplaceImage(ByRef element As UIElement, img As Image)
        If (TypeOf element Is ImageAndTextUIElement.ImageAndTextDependentImageUIElement) Then
            Dim ui As ImageAndTextUIElement.ImageAndTextDependentImageUIElement = element
            ui.Image = img   'This line causes an exception.
        End If
    End Sub

 

 

Any help is much appreciated!
- Erik