Custom shaped Screen Tips

3 posts, 1 answers
  1. Daniel
    Daniel avatar
    5 posts
    Member since:
    Mar 2020

    Posted 27 Mar 2020 Link to this post

    Is it possible to have a custom shaped screen tip? 

    I have created a custom screen tip class, set the Shape property of the element to be a shape and it appears to work visually but it's leaving a grey background in the spots where I want it to be transparent. See attached. 

     

    I have also tried doing the same but with an image, making the background of the image transparent, but the same thing happens. 

     

    Thanks. 

     

     

  2. Answer
    Nadya
    Admin
    Nadya avatar
    459 posts

    Posted 27 Mar 2020 Link to this post

    Hello Daniel,

    Please refer to the following code snippet in order to avoid that gray rectangle behind the custom shape of the screen tip:

     public RadForm1()
            {
                InitializeComponent();
                this.radButton1.ScreenTipNeeded += this.NewRadButton1_ScreenTipNeeded;
            }
            private void NewRadButton1_ScreenTipNeeded(object sender, Telerik.WinControls.ScreenTipNeededEventArgs e)
            {
    
                PropertyInfo barProperty = ((ComponentBehavior)this.radButton1.Behavior).GetType().GetProperty("ScreenPresenter",
                                                                                                          BindingFlags.NonPublic | BindingFlags.Instance);
                Form screenTipForm = barProperty.GetValue(((ComponentBehavior)this.radButton1.Behavior), null) as Form;
    
                screenTipForm.BackColor = this.BackColor;
                screenTipForm.TransparencyKey = this.BackColor;
    
                IntPtr hWnd = screenTipForm.Handle;
                int GCL_STYLE = -26;
                int ClassLong = NativeMethods.GetClassLongPtr(new HandleRef(null, hWnd), GCL_STYLE).ToInt32();
                if ((ClassLong & NativeMethods.CS_DROPSHADOW) != 0)
                {
                    ClassLong ^= NativeMethods.CS_DROPSHADOW;
                    NativeMethods.SetClassLong(new HandleRef(null, hWnd), GCL_STYLE, (IntPtr)ClassLong);
                }
            }

    I hope this helps. Do not hesitate to contact us if you have other questions.

    Regards,
    Nadya
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  3. Daniel
    Daniel avatar
    5 posts
    Member since:
    Mar 2020

    Posted 27 Mar 2020 in reply to Nadya Link to this post

    Worked like a charm. 

    Thanks! 

Back to Top