MaterialSkin icon indicating copy to clipboard operation
MaterialSkin copied to clipboard

Form blocked in minimized state

Open TomsDev67 opened this issue 4 years ago • 9 comments

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.

image image

Running on Win10 64bits

TomsDev67 avatar Mar 25 '20 16:03 TomsDev67

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.

leocb avatar Mar 25 '20 16:03 leocb

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; in Main.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! 😄

leocb avatar Oct 06 '20 15:10 leocb

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.

seikosantana avatar Apr 23 '21 03:04 seikosantana

The solution @TomsDev67 reported:

remove the this.DrawerTabControl = this.materialTabControl; in Main.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?

information-security avatar Jun 24 '21 03:06 information-security

Drawer won't work

leocb avatar Jun 28 '21 04:06 leocb

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

muzsor avatar Jul 30 '21 07:07 muzsor

See #203 for another possible solution

leocb avatar Aug 17 '21 03:08 leocb

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!

RedDot-3ND7355 avatar Dec 05 '21 22:12 RedDot-3ND7355

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(); } }

msaaqibkhan avatar Jan 05 '22 10:01 msaaqibkhan