Search results for 'Disable Mouse'. 2 post(s) found.

  1. 2007/09/25 How to restrict mouse movement
  2. 2007/09/19 Disable Mouse and Keyboard from Delphi Code
2007/09/25 14:16

How to restrict mouse movement


Here's how to restrict the mouse movement to a form and release this restriction after a click on a form:

procedure TForm1.FormCreate(Sender: TObject) ;
var r : TRect;
begin
    //it would be good idea to move the
    //mouse inside the form before restriction
   r := BoundsRect;
   ClipCursor(@R) ;
end;

procedure TForm1.FormClick(Sender: TObject) ;
begin
   //always be sure to release the cursor
   ClipCursor(nil) ;
end;
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/28 22:28 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 06:39 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/09/19 08:28

Disable Mouse and Keyboard from Delphi Code


The BlockInput API function blocks keyboard and mouse input events from reaching applications.

Place a Button (name: "Button1") on a form (name: "Form1") and use this code for the button's OnClick event handler. Once you click the button your mouse and keyboard will be blocked for 5 seconds.

Note: BlockInput is available only on Windows 98 and newer, this is why we have a "FuncAvaial" procedure - to test the existance of a function inside a DLL.


procedure TForm1.Button1Click(Sender: TObject) ;

 function FuncAvail(dllName, funcName: string; var p: pointer): boolean;
 var
   lib: THandle;
 begin
   result := false;
   p := nil;
   if LoadLibrary(PChar(dllName)) = 0 then exit;
   lib := GetModuleHandle(PChar(dllName)) ;
   if lib <> 0 then
   begin
    p := GetProcAddress(lib, PChar(funcName)) ;
    if p <> nil then Result := true;
   end;
 end;

 var
   BlockInput : function(Block: BOOL): BOOL; stdcall;

 begin
  if FuncAvail('USER32.DLL', 'BlockInput', @BlockInput) then
  begin
   ShowMessage('Your Mouse and Keyboard will be blocked for 5 seconds!') ;
   BlockInput(true) ;
   Sleep(5000) ;
   BlockInput(false) ;
  end;
 end;

end.
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 02:08 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 10:30 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:40 delete

    moneyideas