---- In case your application needs a highly long time for lots of data processing, this period of time lengthy sufficient to ensure that Windows does not detect person actions through the activation of a screen saver, when the screen saver begins , your system is truly slower, and this can significantly affect the typical operation from the system. Is there a approach to make the information processing system for the lengthy time just before creating off the screen safety? The solution is sure. Windows before beginning the screen saver will activate the application to send the present WM_SYSCOMMAND message, which wParam parameter specifies the kind of program instructions to be executed, during this case, the value SC_SCREENSAVE. The problem is easy methods to seize the news program it? In C + + Builder could be utilised Tapplication OnMessage event handler class to handle the news. Any application acquired immediately after the Windows message will set off Tapplication OnMessage class occasions, by defining the occasion handler, you can deliver towards the application captures all Windows messages (needless to say not integrated in the program with all the SendMessage purpose to send the message) .
---- OnMessage occasions are outlined as follows:
typedef void__fastcall (__closure
* TMessageEvent) (tagMSG & Msg, bool & Handled);
__property TMessageEvent OnMessage =
read = FOnMessage, write = FOnMessage;
---- OnMessage which TMessageEvent sort is the type of occasion that defines the strategy of processing a message, Msg parameters are given data 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 received right after the Handled parameter is set to true, then the message will not be further treatment,
Office Enterprise 2007, in this case is to remove the screen saver activated.
---- Start C + + Builder, create a project file, the header files to increase inside the Private section of the member perform CaptureMessage statement:
class TForm1: public Tform
__published:
private:
void __fastcall CaptureMessage (tagMSG & Msg, 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 operate as outlined CaptureMessage OnMessage an event processor, the main form add the following code inside the OnCreate event handler :
void __fastcall TForm1:: FormCreate (Tobject * Sender)
Application-> OnMessage = CaptureMessage;
---- Press F9 to compile and run the system, you may advance the display screen saver wait time set to a value as small as probable to test the operation from the plan. You will find inside the program is running, the display saver will not be activated, close running programs and then wait for any while, the display screen saver would normally appear. The above code in C + + Builder3, win98 environment to run through the