1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-11 11:55:02 -05:00

if the target window doesn't exist, retarget!

This commit is contained in:
Raymond 2010-04-12 00:02:28 +02:00
parent aa57a27f12
commit c7f5ce6b31
2 changed files with 17 additions and 14 deletions

View File

@ -1668,6 +1668,8 @@ procedure TForm1.ChangeMouseStatus(Sender: TObject);
var var
x, y: Integer; x, y: Integer;
begin begin
if Self.Manager.TargetValid = false then
self.Manager.SetDesktop;
Self.Manager.GetMousePos(x, y); Self.Manager.GetMousePos(x, y);
if self.Manager.ReceivedError() then if self.Manager.ReceivedError() then
begin begin

View File

@ -78,7 +78,7 @@ interface
keyinput: TKeyInput; keyinput: TKeyInput;
procedure ValidateBuffer(w,h:integer); procedure ValidateBuffer(w,h:integer);
protected protected
function WindowRect : TRect;virtual; function WindowRect(out Rect : TRect) : Boolean;virtual;
end; end;
{ TDesktopWindow } { TDesktopWindow }
@ -86,7 +86,7 @@ interface
TDesktopWindow = class(TWindow) TDesktopWindow = class(TWindow)
private private
constructor Create(DesktopHandle : HWND); constructor Create(DesktopHandle : HWND);
function WindowRect : TRect;override; function WindowRect(out Rect : TRect) : Boolean;override;
end; end;
TIOManager = class(TIOManager_Abstract) TIOManager = class(TIOManager_Abstract)
public public
@ -224,7 +224,7 @@ implementation
var var
Rect : TRect; Rect : TRect;
begin begin
Rect := WindowRect; WindowRect(rect);
w:= Rect.Right - Rect.Left; w:= Rect.Right - Rect.Left;
h:= Rect.Bottom - Rect.Top; h:= Rect.Bottom - Rect.Top;
end; end;
@ -248,9 +248,9 @@ implementation
end; end;
end; end;
function TWindow.WindowRect: TRect; function TWindow.WindowRect(out Rect : TRect) : boolean;
begin begin
GetWindowRect(self.handle,result); result := GetWindowRect(self.handle,rect) <> 0;
end; end;
function TWindow.ReturnData(xs, ys, width, height: Integer): TRetData; function TWindow.ReturnData(xs, ys, width, height: Integer): TRetData;
@ -274,7 +274,7 @@ implementation
Rect : TRect; Rect : TRect;
begin begin
Windows.GetCursorPos(MousePoint); Windows.GetCursorPos(MousePoint);
Rect := WindowRect; WindowRect(rect);
x := MousePoint.x - Rect.Left; x := MousePoint.x - Rect.Left;
y := MousePoint.y - Rect.Top; y := MousePoint.y - Rect.Top;
end; end;
@ -283,7 +283,7 @@ implementation
rect : TRect; rect : TRect;
w,h: integer; w,h: integer;
begin begin
Rect := WindowRect; WindowRect(rect);
x := x + rect.left; x := x + rect.left;
y := y + rect.top; y := y + rect.top;
Windows.SetCursorPos(x, y); Windows.SetCursorPos(x, y);
@ -293,7 +293,7 @@ implementation
Input : TInput; Input : TInput;
Rect : TRect; Rect : TRect;
begin begin
Rect := WindowRect; WindowRect(rect);
Input.Itype:= INPUT_MOUSE; Input.Itype:= INPUT_MOUSE;
FillChar(Input,Sizeof(Input),0); FillChar(Input,Sizeof(Input),0);
Input.mi.dx:= x + Rect.left; Input.mi.dx:= x + Rect.left;
@ -310,7 +310,7 @@ implementation
Input : TInput; Input : TInput;
Rect : TRect; Rect : TRect;
begin begin
Rect := WindowRect; WindowRect(rect);
Input.Itype:= INPUT_MOUSE; Input.Itype:= INPUT_MOUSE;
FillChar(Input,Sizeof(Input),0); FillChar(Input,Sizeof(Input),0);
Input.mi.dx:= x + Rect.left; Input.mi.dx:= x + Rect.left;
@ -420,12 +420,13 @@ begin
end; end;
function TDesktopWindow.WindowRect: TRect; function TDesktopWindow.WindowRect(out Rect : TRect) : Boolean;
begin begin
result.Left:= GetSystemMetrics(SM_XVIRTUALSCREEN); Rect.Left:= GetSystemMetrics(SM_XVIRTUALSCREEN);
result.Top:= GetSystemMetrics(SM_YVIRTUALSCREEN); Rect.Top:= GetSystemMetrics(SM_YVIRTUALSCREEN);
result.Right := GetSystemMetrics(SM_CXVIRTUALSCREEN); Rect.Right := GetSystemMetrics(SM_CXVIRTUALSCREEN);
result.Bottom:= GetSystemMetrics(SM_CYVIRTUALSCREEN); Rect.Bottom:= GetSystemMetrics(SM_CYVIRTUALSCREEN);
Result := true;
end; end;
end. end.