WPF's message mechanism (III) - five windows within WPF handle activated and closed message windows and system resource notification windows

original
2014/06/11 12:01
Reading number 408

catalog

WPF's Message Mechanism (I) - Let Applications Move

WPF's message mechanism (II) - 5 windows inside WPF

(1) Hide Message Window

(2) Handles active and closed message windows and system resource notification windows

(3) Visible window for user interaction

(4) Visible window for UI window painting

WPF Message Mechanism (III) - WPF Input Event Source

WPF's message mechanism (IV) - UI update in WPF

 

Processing windows for application activation and system shutdown (Window 2# )

Creation time: when calling Application After running, run to Application EnsureHwndSource() method.

Usage: Dispatch the Activated, Deactivated, SessionEnding events of Application.

For security reasons, WPF does not let the UI window handle the messages corresponding to the activation and deactivation of applications and the shutdown of the operating system. Instead, it creates a hidden window internally to receive two Windows messages, WM_ACTIVATEAPP and WM_QUERYENDESSION. After getting these two messages from the thread's message queue, the WPF Application will be triggered Activated, Application.Deactivated, and Application.SessionEnding.

For more details, refer to EnsureHwndSource() and AppFilterMessage() of Application type.

The above process can be described as follows:

 

 Window2

 

 

System resource change notification window (Window 4#)

Creation time: when the ThemeStyle of the Window needs to be confirmed after the Xaml of the MainWindow of the Application is de sequenced into an object.

Purpose: It is used to update the performance of WPF when the Theme of the operating system changes, and when the resources associated with the system, such as SystemColors, SystemFonts, power supplies, displays, and so on, change.

After the initialization of the MainWindow that appears in the WPF application is completed, a hidden window will be created to process messages from the updated system related resources, such as WM_ThemeChanged, WM_SystemColorChanged, WM_DisplayChange, WM_PowerBroadcast, and so on. Similar to the original intention of Window2 #, for security reasons, these messages are not processed through the visible UI window. Instead, the content creates a hidden Window4 # window to process these messages, so as to ensure that the UI window can safely update the performance after changes in the system Theme and related resources.

The above process can be described as follows:

 Window4

 

Maybe you will ask why we first explained Window4 instead of the visible window for user interaction (Window3)? That's because Window3 has a lot of content, while Window2 # and Window4 # are relatively independent. Therefore, it is introduced in this article. The detailed description of Window3 will be introduced in the next article. Please pay attention!

This article is from“ Grapevine Control Blog ”Blog, please keep this source http://powertoolsteam.blog.51cto.com/2369428/477221

Expand to read the full text
Loading
Click to lead the topic 📣 Post and join the discussion 🔥
Reward
zero comment
one Collection
zero fabulous
 Back to top
Top