Windowクラス のイベント発生状況を確認したかったため、各イベントが発生する都度、コンソールに結果出力させるサンプル、これを実行してトレース結果の動きを見ているとWindowのイベント発生契機の理解が深まる。
コード例
add_XXXX.Invokeの中で、自作のトレース用のスタティックメソッドを呼び出すようにしている。
結果(起動時)
IsVisibleChanged、SizeChanged、LayoutUpdated、SourceInitialized、Activated あたりが初期化時のイベントのようだ。
しかし、起動時に一番発生しそうな(それっぽい)Inithalizedは呼ばれていなかった。なぜだろう
PS C:\Users\papanda925\Documents\WinPythonDev\dev> . "c:\Users\papanda925\Documents\WinPythonDev\dev\PSEventNotificationChecker.ps1.ps1"
2022/08/29 19:01 MainWindowEvent Trace Start
2022/08/29 19:01 IsVisibleChanged
2022/08/29 19:01 SizeChanged
2022/08/29 19:01 LayoutUpdated
2022/08/29 19:01 LayoutUpdated
2022/08/29 19:01 LayoutUpdated
2022/08/29 19:01 LayoutUpdated
2022/08/29 19:01 LayoutUpdated
2022/08/29 19:01 LayoutUpdated
2022/08/29 19:01 SourceInitialized
2022/08/29 19:01 Activated
2022/08/29 19:01 PreviewGotKeyboardFocus
2022/08/29 19:01 IsKeyboardFocusWithinChanged
2022/08/29 19:01 IsKeyboardFocusedChanged
2022/08/29 19:01 GotKeyboardFocus
2022/08/29 19:01 LayoutUpdated
2022/08/29 19:01 LayoutUpdated
2022/08/29 19:01 LayoutUpdated
2022/08/29 19:01 LayoutUpdated
2022/08/29 19:01 LayoutUpdated
2022/08/29 19:01 LayoutUpdated
2022/08/29 19:01 Unloaded
2022/08/29 19:01 Loaded
2022/08/29 19:01 MouseEnter
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
2022/08/29 19:01 ContentRendered
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
・・・・・・
結果、終了(xボタンクリック時)
Closing と Closed が呼ばれている これがそんなものかなと思える。
・・・・・・
2022/08/29 19:01 MouseMove
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
2022/08/29 19:01 QueryCursor
2022/08/29 19:01 PreviewMouseMove
2022/08/29 19:01 MouseMove
2022/08/29 19:01 MouseLeave
2022/08/29 19:01 Closing
2022/08/29 19:01 IsVisibleChanged
2022/08/29 19:01 Deactivated
2022/08/29 19:01 IsKeyboardFocusWithinChanged
2022/08/29 19:01 IsKeyboardFocusedChanged
2022/08/29 19:01 LostKeyboardFocus
2022/08/29 19:01 Closed
2022/08/29 19:01 Event Trace End
引用
Window クラス (System.Windows) | Microsoft Docs
ライセンス:本記事のテキスト/コードは特記なき限り
CC BY 4.0 です。引用の際は出典URL(本ページ)を明記してください。
利用ポリシー もご参照ください。
コメント