Author: Jonas Bilinkevicius
I would like to have a password for windows I minimize. How can I write an
application that will prevent any minimized window from restoring until a password
is given?
Answer:
interface part:
bPassWordDialog: Boolean;
procedure WMSYSCOMMAND(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
procedure WMActivate(var Msg: TWMActivate); message WM_ACTIVATE;
implementation part:
1 2 procedure TForm1.WMActivate(var Msg: TWMActivate);
3 begin4 if (Msg.Active = WA_Active) and (bPassWordDialog) then5 begin6 bPassWordDialog := False;
7 ShowMessage('Show password dialog here');
8 end;
9 inherited;
10 end;
11 12 procedure TForm1.WMSYSCOMMAND(var Msg: TWMSysCommand);
13 begin14 bPassWordDialog := False;
15 if Msg.CmdType = SC_MINIMIZE then16 bPassWordDialog := True;
17 inherited;
18 end;