22
33using NeeLaboratory . ComponentModel ;
44using NeeLaboratory . Generators ;
5+ using NeeView . Interop ;
56using NeeView . Native ;
67using NeeView . Setting ;
78using NeeView . Threading ;
1213using System . Linq ;
1314using System . Windows ;
1415using System . Windows . Input ;
16+ using System . Windows . Interop ;
1517using System . Windows . Media ;
1618
1719namespace NeeView
@@ -389,12 +391,24 @@ private void OnRendering(object? sender, EventArgs e)
389391 LayoutFrame ( ) ;
390392 }
391393
392-
393- // ウィンドウソース初期化後イベント
394- private void MainWindow_SourceInitialized ( object sender , EventArgs e )
394+ // ウィンドウソース初期化後
395+ protected override void OnSourceInitialized ( EventArgs e )
395396 {
397+ base . OnSourceInitialized ( e ) ;
398+
396399 Debug . WriteLine ( $ "App.MainWindow.SourceInitialized: { App . Current . Stopwatch . ElapsedMilliseconds } ms") ;
397400
401+ if ( App . Current . Resources [ "Window.Background" ] is SolidColorBrush brush )
402+ {
403+ // Win32 の背景ブラシを設定して起動時のちらつきを軽減するテスト
404+ var hwnd = new WindowInteropHelper ( this ) . Handle ;
405+ int color = brush . Color . B << 16 | brush . Color . G << 8 | brush . Color . R ;
406+ IntPtr blackBrush = NativeMethods . CreateSolidBrush ( color ) ;
407+ const int GCLP_HBRBACKGROUND = - 10 ;
408+ NativeMethods . SetClassLongPtr ( hwnd , GCLP_HBRBACKGROUND , blackBrush ) ;
409+ NativeMethods . InvalidateRect ( hwnd , IntPtr . Zero , true ) ;
410+ }
411+
398412 // Chrome の情報を最新にする
399413 _windowController . Refresh ( ) ;
400414
@@ -405,13 +419,15 @@ private void MainWindow_SourceInitialized(object sender, EventArgs e)
405419 Debug . WriteLine ( $ "App.MainWindow.SourceInitialized.Done: { App . Current . Stopwatch . ElapsedMilliseconds } ms") ;
406420 }
407421
422+ private void MainWindow_SourceInitialized ( object sender , EventArgs e )
423+ {
424+ }
425+
408426 // ウィンドウ表示開始
409427 private void MainWindow_Loaded ( object sender , RoutedEventArgs e )
410428 {
411429 Debug . WriteLine ( $ "App.MainWindow.Loaded: { App . Current . Stopwatch . ElapsedMilliseconds } ms") ;
412430
413- App . Current . CloseSplashScreen ( ) ;
414-
415431 MessageDialog . OwnerWindow = this ;
416432
417433 _dpiProvider . SetDipScale ( VisualTreeHelper . GetDpi ( this ) ) ;
0 commit comments