dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.37k stars 966 forks source link

designer form doesn't take care about window state Activation #8107

Open memoarfaa opened 1 year ago

memoarfaa commented 1 year ago

Environment

Microsoft Visual Studio Enterprise 2019 Version 16.11.20

.NET version

.NET Core 3.1 and.NET 5

Did this work in a previous version of Visual Studio and/or previous .NET release?

No

Issue description

designer doesn't take care about window state Activation state of form

Steps to reproduce

open new form in design mode click Properties

2022-11-02_23-31-26

.net framwork

2022-11-02_23-34-13

Diagnostics

No response

RussKie commented 1 year ago

@memoarfaa just to confirm I understand the issue correctly - is the issue related to to the fact the form remains in focus? If yes - why is it important, and how is it affecting your developer experience?

memoarfaa commented 1 year ago

is the issue related to to the fact the form remains in focus? yes Save time while designing

https://user-images.githubusercontent.com/12494184/199631863-68c21bdc-80c7-4e04-bb56-c236f8058710.mp4

https://user-images.githubusercontent.com/12494184/199631872-739918bc-f686-4ba3-bc36-a24ac7119f83.mp4

RussKie commented 1 year ago

Looking at your animation, it looks like you're running a custom form with custom properties and behaviours (doing NC-painting?)....

memoarfaa commented 1 year ago

Yes true https://github.com/memoarfaa/SkinFormCore

I just started a new theme library that has been converted from Winforms .Net framework to .net Core but .net Core designer is not responding to any Nc painting until Close and reopen the form every time

memoarfaa commented 1 year ago

I fixed the Nc painting by add SetWindowPos to every property but I still can't get Inactive title bar color because .net Core designer doesn't take care about WM_NCACTIVATE message . any idea.

SetWindowPos(Handle, IntPtr.Zero, 0, 0, 0, 0, (int)(SWPFlags.SWP_NOACTIVATE | SWPFlags.SWP_NOMOVE | SWPFlags.SWP_NOSIZE | SWPFlags.SWP_NOZORDER | SWPFlags.SWP_FRAMECHANGED));

https://user-images.githubusercontent.com/12494184/200195050-21649345-63c2-4afe-9801-c9e8a4c07ff2.mp4

RussKie commented 1 year ago

Yes true memoarfaa/SkinFormCore

This looks pretty cool. What license have you put your code under?

memoarfaa commented 1 year ago

MIT License Any suggestion to make it widely used in .Net Core Winforms is Welcome

RussKie commented 1 year ago

If you're up for a challenge, we have some long-standing issues with MDI child window rendering - https://github.com/dotnet/winforms/issues/3691. The root issue is within the realms of Windows code, but there's no hope it'll ever be fixed. So an alternative would be to come up with a Windows Forms opt-in functionality (e.g., a renderer of some kind) that would allow rendering NC-area of the MDI child windows to look native. 😉

memoarfaa commented 1 year ago

In short answer issues https://github.com/dotnet/winforms/issues/3691. solved in memoarfaa/SkinFormCore 1- download SkinFormCore v1 2- Add refence to SkinFramWorkCore.dll in your project 3- Create new MDI Window 4- Create methods to Show child window new SkinForm() { MdiParent = this }.Show();

Result is

2022-11-08_12-19-27

I'm also attached simple project

WinFormsApp2.zip

I'm waiting the answer about your test result in any operating system 8,8.1,10,11

merriemcgaw commented 1 year ago

@lonitra would be super interested in what you're doing with the skinning, thank you for sharing! This is something we will have to investigate in our out of process designer. It might be that the window needs to be invalidated to force it to repaint.