禁止用户切换任务
假定我们要设计一个Windows95的口令程序,该程序运行时需要覆盖整个桌面,并且不允许用户用Alt+Esc、Ctrl+Esc等系统组合键来切换到其他程序。为达到此目的,可按以下步骤:
将Form的FormStyle属性设为fsStayOnTop;
将Form的WindowState属性设为wsMaximized;
在Form的OnCreate事件处理过程中为Windows发送一个屏幕保护程序正在运行的消息;
当程序结束时清除屏幕保护程序运行标志。
示例代码:
procedure TForm1.FormCreate(Sender: TObject);
var
temp: Integer;
begin
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @temp, 0);
end;
procedure Form1.OnClose(Sender: TObject;
var Action: TCloseAction);
var
temp: Integer;
begin
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, @temp, 0);
end;
|