WinForms/Powershell - LinkLabel displays oddly when form appears over mouse

Viewed 22

So this is an odd one. I've been using Winforms to create popups that can have multiple click able links in Powershell. I've noticeed that sometimes the linklabel in these popups display funny.

This is how the popup is supposed to look (Note: This is a test popup with garbage message mostly taken from elsewhere):

Proper Popup

This is how it looks when the weird stuff happens:

Weird Popup

After much testing, I learned the following about the bug:

A) The issue only occurs if the windows system draws the popup while the mouse is over (or maybe moving over) the LinkLabel.

B) The issue doesn't occur when switching from a linklabel to a regular label

C) There is for sure nothing in my code involving event handling for mouse movement

Based on what I've been reading, I suspect that the problem is due to something in the base code for Winforms Linklabel (If you look at this question, one of the people there state that Linklabel has code built in for handling the cursor C# - Fix linklabel hand-cursor).

I came up with a partial work around that involved moving the cursor away from where the form would be drawn on the screen. However there is a problem with this solution. I've designed my popup to allow the user to include a visible timer which counts down.

So here's the problem now. Each second the timer counts down, it appears that the system is redrawing the form. And each time the system redraws the form, there's the risk that the user might be moving the mouse on the LinkLabel. When that happens, then the weird visual bug displays on the popup where it will stay until the next time the system redraws the form.

What I need to figure out is:

A) What in the base code is cause this visual bug to occur?

B) Is there an option that I can toggle off to prevent this visual bug?

C) Is there a way to work around the issue by make it so that the System only redraws the timer's label each second that it counts down?

Thanks in advance for the help!

0 Answers
Related