のメソッドを使用して、Aero ガラスのボーダレスでサイズ変更できないWPF ウィンドウを作成しようとしています。しかし、なぜかこの窓のガラスの色がピントが合っていないように見えます。次の 3 つの画像でわかるように、境界線のある通常のウィンドウ (図 1 と 2 など) は問題なく動作し、期待どおりに反応します (焦点が合っているときは紺色、焦点が合っていないときは白っぽい (= 非アクティブ))。DwmEnableBlurBehindWindow
DmwAPI
サイズ変更が許可されたボーダレス ウィンドウは、同じ動作を示します。
ただし、サイズ変更できないボーダレスウィンドウは、アクティブな場合と非アクティブな場合の両方で、(最後の図 3でわかるように) 常に焦点が合っていないように見えます。それは常に白っぽく見えます:
これは、ガラス スタイルを設定する方法のサンプル コードです。
public MainWindow()
{
InitializeComponent();
WindowStyle = WindowStyle.None;
ResizeMode = ResizeMode.NoResize;
Height = 200;
Background = Brushes.Transparent;
Loaded += MainWindow_Loaded;
}
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
var windowInteropHelper = new WindowInteropHelper(this);
var handle = windowInteropHelper.Handle;
var mainWindowSrc = HwndSource.FromHwnd(handle);
if (mainWindowSrc != null)
if (mainWindowSrc.CompositionTarget != null)
mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);
var glassParams = new DwmApi.DwmBlurbehind
{
dwFlags = DwmApi.DwmBlurbehind.DWM_BB_ENABLE,
fEnable = true,
hRegionBlur = IntPtr.Zero
};
IntPtr dis = new IntPtr(2);
DwmApi.DwmSetWindowAttribute(mainWindowSrc.Handle,
DwmApi.DwmWindowAttribute.DWMWA_LAST,
dis,
sizeof(uint));
DwmApi.DwmEnableBlurBehindWindow(
handle,
glassParams
);
}
ウィンドウにフォーカスを合わせてみましたが、動作に影響はないようです。これを解決する方法についてのアイデアや指針はありますか?