This is a migrated thread and some comments may be shown as answers.

Custom shaped Screen Tips

2 Answers 107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 27 Mar 2020, 12:43 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 27 Mar 2020, 01:11 PM

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.
0
Daniel
Top achievements
Rank 1
answered on 27 Mar 2020, 02:48 PM

Worked like a charm. 

Thanks! 

Tags
General Discussions
Asked by
Daniel
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or