Let the app prohibit Windows screen protection

zhaozj2021-02-11  203

Let the app prohibit Windows screen protection

2000-03-21 · Zhou Xindong · Computer World Daily

If you need a long period of time in your program to make a lot of data processing, this time is enough to activate the screen saver because of the user's actions, once the screen saver is launched, your program It's actually slower, which greatly affects the normal operation of the program. Is there a way to turn off the screen protection before the program is processed for a long time? The answer is yes. Windows sends a WM_SYSCOMMAND message to the currently activated application before starting the screen saver, where the WPARAM parameter specifies the upcoming system command type, in this example is SC_Screensave. The problem is how the program captures this message? This message can be processed using the TAPPLICATION class onMessage event handle in C Builder. The application will trigger the onMessage event of the TAPPLICATION class after receiving any Windows messages. By defining the handler of this event, you can capture all Windows messages sent to the application (this is of course not included in the program in the program.) . Defined OnMessage events is as follows: typedef void__fastcall (__ closure * TMessageEvent) (tagMSG & Msg, bool & Handled); __ property TMessageEvent OnMessage = {read = FOnMessage, write = FOnMessage}; wherein TMessageEvent type is the type OnMessage event, which defines a message processing method The MSG parameter gives the information about Windows messages, which are as follows: typedef struct tagmsg {hwnd hwnd; uint message; wparam wparam; lparam lparam; dword time; point pt;} Handled parameter determines how to proceed for the message If the Handled parameter is set to true after receiving a message, the message will not be further processed, in this example, the activation of the screen saver is canceled.

转载请注明原文地址:https://www.9cbs.com/read-4520.html

New Post(0)