chromelyapps / Chromely

Build Cross Platform HTML Desktop Apps on .NET using native GUI, HTML5, JavaScript, CSS, Owin, AspNetCore (MVC, RazorPages, Blazor)
MIT License
2.98k stars 279 forks source link

Semi Transparent Window - Transparency Effect Only For a Single Color (Transparency Key) #314

Closed burgil closed 3 years ago

burgil commented 3 years ago

Trying to make a semi-invisible window as I would do on windows forms applications or on your competitors: https://ourcodeworld.com/articles/read/315/how-to-create-a-transparent-window-with-electron-framework

Can you please refer me to the docs or provide a brief explanation, or somewhere to point me in the right direction?

Thanks in advance!

Update: Transparency Key Is the best suitable example for what I'm trying to do: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form.transparencykey?view=net-5.0 I also attached some pictures to demonstrate it here: https://github.com/chromelyapps/Chromely/issues/235#issuecomment-816306278

mattkol commented 3 years ago

@orrburgel

This may help: https://github.com/chromelyapps/Chromely/issues/235

burgil commented 3 years ago

Hey, Not sure that's what I need, Please see my comment: https://github.com/chromelyapps/Chromely/issues/235#issuecomment-816306278 Thanks in advance

mattkol commented 3 years ago

@orrburgel

What I shared is just a guide on how to do it. I will advice that you start with the baseline of what was shared and make incremental changes.

burgil commented 3 years ago

@mattkol

Is the color key there what I'm looking for maybe? Since it looks like it sets the alpha of the entire application instead of a single color. Not sure thats what I was looking for

Thanks in advance

mattkol commented 3 years ago

@orrburgel

You are looking for some specificity. I am sure it is doable but it is a research you need to make yourself. I am sure there are lot of resources to get it done. So if you start with what is provided as the baseline, I am sure you will get there.

The project does not support such feature, but we help to create guides when we can.

Other developers who have done something similar may help too.

burgil commented 3 years ago

Ok I will leave it open in case someone can help solve the problem, I wasn't able to

mattkol commented 3 years ago

@orrburgel

I will suggest you add more clarity to the update so others can quickly understand. For instance the sample that was shared, are you able to run it and did it work as described, but not exactly what you want?

You also mentioned the Transparency Key, is COLORKEY not same as the Transparency Key? Can you try change this to the color you want. Or you need to set it like this - here

 public class CustomNativeWindow : WinAPIHost
    {
        enum LWA : uint
        {
            COLORKEY = 0x00000001,
            ALPHA = 0x00000002
        }

        [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
        static extern bool SetLayeredWindowAttributes(IntPtr hwnd, int crKey, byte bAlpha, LWA dwFlags);

        public override void CreateWindow(IWindowOptions options, bool debugging)
        {
            ------
        }
    }