voidZiAD / WinBlur

WinBlur is a C#, VB .NET Library that allows developers to use modern blur types on their forms.
MIT License
36 stars 2 forks source link

No Blur #9

Closed xVotexX closed 4 months ago

xVotexX commented 4 months ago

Hi,

i'm not sure if I am missing something, but my form is only transparent. There is no blur at all.

My FormBorderStyle is set to None This is the code I tested with:

using System;
using System.Drawing;
using System.Windows.Forms;
using WinBlur;
using static WinBlur.UI;

namespace WindowsFormsApp2
{
    public partial class Popup : Form
    {

        public Popup()
        {
            InitializeComponent();
            this.BackColor = Color.Black;
            SetBlurStyle(cntrl: this, blurType: BlurType.Acrylic, designMode: Mode.DarkMode);
        }

        private void Popup_Load(object sender, EventArgs e)
        {

        }
    }
}

The X in the middle is from the popup form, which should be transparent and blurred. image

voidZiAD commented 4 months ago

Unfortunately, the blur effect works ONLY on WindowTypes other than "None". There could be a fix, I am currently seeing what I can improve in this project or fix. But, it's likely that this is something that cannot be fixed and it's a feature by Windows, where only default WindowType/Style is going to be blurred.

voidZiAD commented 4 months ago

Btw, by WindowTypes/Style I meant FormBorderStyle. My bad.

voidZiAD commented 4 months ago

Here's a temporary fix!

(This should be in your form btw)

protected override CreateParams CreateParams
{
    get
    {
        int WS_DLGFRAME = 0x400000;
        CreateParams result = base.CreateParams;
        result.Style &= ~WS_DLGFRAME;
        return result;
    }
}

This should allow you to use the Effect while not seeing the default border/title and implementing your own border and top bar. Btw, the FormBorderStyle should not be None, so technically this isn't a fix, but it works. I will still be looking into a way to fix this.

xVotexX commented 4 months ago

Thanks for your reply! I have now set my FormBorderStyle to Sizeable but I don't quite understand where exactly I should put your fix. Can you please give me a full code example as in my original message?

voidZiAD commented 4 months ago

Here's a code example:

using System;
using System.Windows.Forms;
using WinBlur;

namespace WinBlurTest
{
    public partial class Form1 : Form
    {

        protected override CreateParams CreateParams
        {
            get
            {
                int WS_DLGFRAME = 0x400000;
                CreateParams result = base.CreateParams;
                result.Style &= ~WS_DLGFRAME;
                return result;
            }
        }

        public Form1()
        {
            InitializeComponent();
            UI.SetBlurStyle(cntrl: this, blurType: UI.BlurType.Acrylic, designMode: UI.Mode.DarkMode);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}

It should be at the top of the class

voidZiAD commented 4 months ago

Let me know if it works. I noticed that it doesn't ALWAYS work, but let me know. it should look like this: Screenshot (1)

xVotexX commented 4 months ago

In my case, the form is just black. In the Designer i set the BackColor to Standart Control

using System;
using System.Drawing;
using System.Windows.Forms;
using WinBlur;
using static WinBlur.UI;

namespace WindowsFormsApp2
{
    public partial class Popup : Form
    {

        protected override CreateParams CreateParams
        {
            get
            {
                int WS_DLGFRAME = 0x400000;
                CreateParams result = base.CreateParams;
                result.Style &= ~WS_DLGFRAME;
                return result;
            }
        }

        public Popup()
        {
            InitializeComponent();
            UI.SetBlurStyle(cntrl: this, blurType: UI.BlurType.Acrylic, designMode: UI.Mode.DarkMode);
        }

        private void Popup_Load(object sender, EventArgs e)
        {

        }
    }
}

image

xVotexX commented 4 months ago

I've just noticed that when the Form is focused, everything is black, but when I click anywhere else, it changes its BackColor.

focusgif

voidZiAD commented 4 months ago

Thing is, I noticed you have to minimize and reopen the form for it to work. Also, perhaps there's a backcolor that's tampering with the color. You might've set the backcolor of a Panel for example as Black. Anyways, if it still doesn't work, then like I said this is a temporary solution. I will be working on a better solution and I'll update the package once I have done it.

xVotexX commented 4 months ago

The problem now is that even if I remove your fix, the background is still not what it should be. Now it's not even just transparent. Minimising and reopening does not help.

using System;
using System.Drawing;
using System.Windows.Forms;
using WinBlur;
using static WinBlur.UI;

namespace WindowsFormsApp2
{
    public partial class Popup : Form
    {

        public Popup()
        {
            InitializeComponent();
            SetBlurStyle(cntrl: this, blurType: BlurType.Acrylic, designMode: Mode.DarkMode);
        }

        private void Popup_Load(object sender, EventArgs e)
        {

        }
    }
}

image

voidZiAD commented 4 months ago

I just realized... Are you on Windows 10? Dude 😭 This doesn't work on Windows 10. The Blur effects have been introduced in Windows 11 and only a very very few versions of Windows 10. Perhaps the final versions, and even then, you'd have to do some work to enable the Effects. I'm sorry, but it's your OS, not the package.

Your original issue is still valid though, and I am still gonna work on fixing it.

xVotexX commented 4 months ago

Damn. Thats sad. You should remove the "Windows 10" in your Readme then i guess. Do you know anything similar that works on Win10?

voidZiAD commented 4 months ago

Well. It does work on Win10, so It's not incorrect. It's just that, it doesn't work on all versions, and you have to enable it most of the time.

And unfortunately there are no blur effects supported on Versions below 10-11, unless you create it yourself via the Form using user controls and code.

xVotexX commented 4 months ago

Too bad. Good luck then