---- In case your application requires a incredibly lengthy time for a whole lot of information processing, this time period lengthy sufficient so that Windows does not detect consumer actions through the activation of a display saver, once the display screen saver starts , your system is in fact slower, and this will greatly impact the typical operation with the system. Is there a strategy to make the information processing plan for a long time just before generating off the screen protection? The answer is sure. Windows prior to starting the display saver will activate the application to send the existing WM_SYSCOMMAND message, which wParam parameter specifies the kind of program commands to be executed, during this case, the worth SC_SCREENSAVE. The difficulty is tips on how to seize the news program it? In C + + Builder can be utilised Tapplication OnMessage event handler class to handle the news. Any application received soon after the Windows message will trigger Tapplication OnMessage class occasions, by defining the event handler, you can actually send to the software captures all Windows messages (needless to say not included within the plan with all the SendMessage perform to deliver the message) .
---- OnMessage events are outlined as follows:
typedef void__fastcall (__closure
* TMessageEvent) (tagMSG & Msg, bool & Handled);
__property TMessageEvent OnMessage =
read = FOnMessage, write = FOnMessage;
---- OnMessage which TMessageEvent type is the sort of occasion that defines the technique of processing a message, Msg parameters are given info about Windows messages Its structure is as follows:
typedef struct tagMSG
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt ;
---- Handled parameter determines how the concept for further processing, if a concept is acquired soon after the Handled parameter is set to true, then the concept will not be further treatment, with this situation is to remove the screen saver activated.
---- Start C + + Builder, create a project file, the header files to increase within the Private section from the member operate CaptureMessage statement:
class TForm1: public Tform
__published:
private:
void __fastcall CaptureMessage (tagMSG & Msg,
Office Professional Plus 2010, bool & Handled);
public:
__fastcall TForm1 (Tcomponent * Owner);
;
---- in. cpp file to add CaptureMessage definition:
void __fastcall TForm1:: CaptureMessage (tagMSG & Msg, bool & Handled)
if (Msg.message = = WM_SYSCOMMAND & & Msg.wParam = = SC_SCREENSAVE)
Handled = true; / / stop the screen saver starts
else
Handled = false; / / to the message The default processing
---- then perform as outlined CaptureMessage OnMessage an occasion processor, the main form add the following code in the OnCreate occasion handler :
void __fastcall TForm1:: FormCreate (Tobject * Sender)
Application-> OnMessage = CaptureMessage;
---- Press F9 to compile and run the plan, you could advance the display saver wait time set to a value as small as possible to test the operation from the program. You will find inside the system is running, the display screen saver will not be activated, close running programs and then wait to get a while, the display saver would normally appear. The above code in C + + Builder3, win98 environment to run through the