Aug
|
Spurious/Incorrect .NET Form.Activated() Event
2017
Notice: Using the "fix" below can result in the form's Notice 2: I've added another version below. A couple of new categories for this blog: But, let's continue with the subject of this post: the Quite a few years ago I created my own Metro-style form based on the idea of Microsoft's flat-style interface. Metro was approximately a couple of years away from release and there wasn't really any screenshots of what it would look like. I ploughed on with my version - including a break of a year because it took a long time to get it working correctly as working with forms that have their The biggest issue was getting Windows to treat the borderless form as a true window; it just didn't give a crap about it. A quick way to tell if Windows regards a form as a true window is to minimise it to the taskbar. Does it immediately disappear from view? It's not a true window. Does it animate down into the taskbar? It's a true window. There were two issues remaining (that I remember, anyway): restoring the window from its minimised state causes the window to gain an extra X number of pixels on its height. That's still an issue and seems random as to which form it affects. The fix I put in-place seems to work most of the time, but regardless, the child controls gain extra height with/without the form growing in size. Clearly more work to be done, there. The second issue which I'm going to talk about here is the form's It seems somewhat random when it happens, but here's how it generally goes:
This causes a problem in my particular case because I handle and expose the activation event via a For example, here's a (currently work-in-progress) form that's active: And here's that same form when it has become inactive: As you can see, having the form become active when it actually isn't is confusing to the user. And extremely irritating to me. My first quick go at fixing this seems to work; I'll have to keep testing it over the long term but it seems like it may have solved it. Not a fan that I have to do this in the first place, but what can ya do? Have this at the first line(s) within the
Here's another version (see notice at top of this post):
It appears I'm not sure if it's worth putting a check into the |