All descendants of TControl, including TForm, contain a WndProc function that serves as the window procedure for the component. This function is virtual, which means that you can override the function to intercept messages. The argument to WndProc is a TMessage structure passed by reference that contains the message command ID and the WPARAM and LPARAM values.
Step 1: Add the WndProc declaration to your form's header.
Step 2: Code the function. The derived WndProc should call the base class TForm::WndProc for all messages that you don't process. This function prevents the windows screensaver from starting.