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
225
Cannot replace the whole Ribbon Application Menu button image
posted

Do you know what I did wrong why I can't replace the whole button image (white circle around)? See the attached snapshot. I have tried many different image sizes with same result.

 

  • 40
    Suggested Answer
    posted

    I tried 37x37 and 43x43 images of a circle, but had the same problems as dtjoa.

    I fixed the problem by using a custom draw filter class.  Set the UltratoolbarsManager.Ribbon.DrawFilter to an instance of this AppButtonFilter, and add the desired image for your logo in the Resources (or supply it some other way)

    <code lang="vb.net">

        Public Class AppButtonFilter
            Implements Infragistics.Win.IUIElementDrawFilter

            Public Function GetPhasesToFilter(ByRef drawParams As Infragistics.Win.UIElementDrawParams) _
            As Infragistics.Win.DrawPhase _
                Implements(Infragistics.Win.IUIElementDrawFilter.GetPhasesToFilter)
                If (TypeOf (drawParams.Element) Is ApplicationMenuButtonUIElement) Then
                    Return Infragistics.Win.DrawPhase.BeforeDrawImage
                Else
                    Return Infragistics.Win.DrawPhase.None
                End If
            End Function

            Public Function DrawElement(ByVal drawPhase As Infragistics.Win.DrawPhase, _
                                        ByRef drawParams As Infragistics.Win.UIElementDrawParams) As Boolean _
                                        Implements Infragistics.Win.IUIElementDrawFilter.DrawElement
                Dim elementRect As Rectangle = drawParams.Element.Rect
                elementRect.Inflate(-1, -1)
                drawParams.DrawImage(Resources.RedCircleImage, elementRect, True, Nothing)
            End Function
        End Class

    </code>

     

    Here are the results:

    using ApplicationMenuButtonImage: 

    using the Draw Filter:

  • 44743
    Suggested Answer
    posted

    The images used by the ApplicationMenuButton are 43x43. There are 3 pixels of transparency on all four sides of the circle part of the image. This means the circle actually measures 37x37. If you create a similar image, I believe your image should completely obscure the default image.