Beranda > Delphi > How to block input to the system until released

How to block input to the system until released

The Windows API BlockInput function prevents all input to the system, making it appear locked up until released. Declare the function as:

function BlockInput(fBlockInput: Boolean): DWORD; stdcall;
  external 'user32.dll';

Usage: Set to True to “lock-up” and False to “unlock” input devices.

The following code locks up input for 2 seconds:

procedure TForm1.Button1Click(Sender: TObject);
begin
  BlockInput(True);
  Label1.Caption := 'Blocked';
  Application.ProcessMessages;
  Sleep(2000);
  BlockInput(False);
  Label1.Caption := 'Unblocked';
end;
Iklan
Kategori:Delphi
  1. Belum ada komentar.
  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: