MaterialSkin
MaterialSkin copied to clipboard
Form blocked in minimized state
Hello,
Back to share a new strange and very annoying bug.
How to reproduce :
- Just compile MaterialSkinExample project
- Go in bin folder and run as administrator MaterialSkinExample.exe
- Application is displaying
- Click in taskbar on the app to minimize it
- Click in task on the app to show it again
And here is the issue, the window will never come back to normal state It is only happening when you launch your app in admin, it is very important to reproduce the case.
For now all verification, checks, and investigation gave me nothing. A colleague had also a look on it without more result.
The only thing that I know is that's probably an issue with the TabControl component.
I'm not able to reproduce it on MaterialSkinExample project but on the project on which I'm working when I've removed the line this.DrawerTabControl = this.materialTabControl;
in Main.Designer.cs
it was making minimize/normal state change working again.
Running on Win10 64bits
Hi, thanks for reporting, you keep surprising me with these bug reports hahah
Probably not a problem with the tabControl, but with how I handle the Drawer (hamburguer menu) with 2 extras forms. I've never seen administrator rights causing weird behavior in the interface messages.
I did some tests, and this issue is indeed caused by the 2 extra forms I use for the drawer, for some reason, when running as an admin, the first window it tries to restore is the drawer (or the overlay), but since it's hidden, the user cannot see it or restore the main app window. When running at normal "user mode" the first window to be restored is the main one.
The solution @TomsDev67 reported:
remove the
this.DrawerTabControl = this.materialTabControl;
inMain.Designer.cs
Works because the main form will not create the drawer/overlay forms if they are not needed.
I tried to hack some behavior on the window state change, but since this lib uses a borderless window, that's difficult to capture and mess around without also breaking the maximize window function. if anyone else want to tackle this, please go ahead. One ideia that popped in my mind is to close/destroy the drawer and overlay forms when minimizing and restoring them back when needed.
Good luck! 😄
I tried to hack some behavior on the window state change, but since this lib uses a borderless window, that's difficult to capture and mess around without also breaking the maximize window function.
This might be out of topic but I wonder how electron renderer window does its -webkit-app-region: drag
.
While being borderless, it is able to perform aero snap, sizable, as it is a sizeable form.
The solution @TomsDev67 reported:
remove the
this.DrawerTabControl = this.materialTabControl;
inMain.Designer.cs
Works because the main form will not create the drawer/overlay forms if they are not needed.
@leocb Could you please mention what shall be the consequences/side-effects of applying the above solution?
Drawer won't work
Here is a piece of code that worked for me, I think this is not a great solution.
// Form.cs
private const int WM_ACTIVATEAPP = 0x001C;
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (WindowState == FormWindowState.Minimized && m.Msg == WM_ACTIVATEAPP && m.WParam == IntPtr.Zero)
{
BringToFront();
}
}
Running on .Net Framework 4.7.2 Win10 1903
See #203 for another possible solution
Solution doesn't work :/ (both) Is there an alternative solution that works on latest build? (nvm, fixed!) But a proper fix would be really appreciated!
Thanks Muzsor Your solution saved my time: // Form.cs private const int WM_ACTIVATEAPP = 0x001C;
protected override void WndProc(ref Message m) { base.WndProc(ref m); if (WindowState == FormWindowState.Minimized && m.Msg == WM_ACTIVATEAPP && m.WParam == IntPtr.Zero) { BringToFront(); } }