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

Tried to fix it, but I failed (@ multiple monitor support).

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@561 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Raymond 2010-02-27 13:10:08 +00:00
parent 84f0424e46
commit ae7fee7ed3
2 changed files with 54 additions and 13 deletions

View File

@ -44,7 +44,7 @@ uses
ColorBox , about, framefunctionlist, ocr, updateform, simbasettings; ColorBox , about, framefunctionlist, ocr, updateform, simbasettings;
const const
SimbaVersion = 560; SimbaVersion = 561;
type type

View File

@ -43,6 +43,7 @@ interface
TWindow = class(TWindow_Abstract) TWindow = class(TWindow_Abstract)
public public
constructor Create;
constructor Create(target: Hwnd); constructor Create(target: Hwnd);
destructor Destroy; override; destructor Destroy; override;
procedure GetTargetDimensions(var w, h: integer); override; procedure GetTargetDimensions(var w, h: integer); override;
@ -76,8 +77,17 @@ interface
width,height: integer; width,height: integer;
keyinput: TKeyInput; keyinput: TKeyInput;
procedure ValidateBuffer(w,h:integer); procedure ValidateBuffer(w,h:integer);
protected
function WindowRect : TRect;virtual;
end; end;
{ TDesktopWindow }
TDesktopWindow = class(TWindow)
private
constructor Create(DesktopHandle : HWND);
function WindowRect : TRect;override;
end;
TIOManager = class(TIOManager_Abstract) TIOManager = class(TIOManager_Abstract)
public public
constructor Create; constructor Create;
@ -154,16 +164,23 @@ implementation
//***implementation*** TWindow //***implementation*** TWindow
constructor TWindow.Create(target: Hwnd); begin constructor TWindow.Create;
begin
inherited Create; inherited Create;
self.handle:= target;
self.dc:= GetWindowDC(target);
self.buffer:= TBitmap.Create; self.buffer:= TBitmap.Create;
self.buffer.PixelFormat:= pf32bit; self.buffer.PixelFormat:= pf32bit;
keyinput:= TKeyInput.Create; keyinput:= TKeyInput.Create;
end; end;
destructor TWindow.Destroy; begin constructor TWindow.Create(target: Hwnd);
begin
self.create; //Call the other create
self.handle:= target;
self.dc:= GetWindowDC(target);
end;
destructor TWindow.Destroy;
begin
ReleaseDC(handle,dc); ReleaseDC(handle,dc);
buffer.Free; buffer.Free;
keyinput.Free; keyinput.Free;
@ -204,7 +221,7 @@ implementation
var var
Rect : TRect; Rect : TRect;
begin begin
GetWindowRect(handle, Rect); Rect := WindowRect;
w:= Rect.Right - Rect.Left; w:= Rect.Right - Rect.Left;
h:= Rect.Bottom - Rect.Top; h:= Rect.Bottom - Rect.Top;
end; end;
@ -228,6 +245,11 @@ implementation
end; end;
end; end;
function TWindow.WindowRect: TRect;
begin
GetWindowRect(self.handle,result);
end;
function TWindow.ReturnData(xs, ys, width, height: Integer): TRetData; function TWindow.ReturnData(xs, ys, width, height: Integer): TRetData;
var var
temp: PRGB32; temp: PRGB32;
@ -249,7 +271,7 @@ implementation
Rect : TRect; Rect : TRect;
begin begin
Windows.GetCursorPos(MousePoint); Windows.GetCursorPos(MousePoint);
GetWindowRect(handle,Rect); Rect := WindowRect;
x := MousePoint.x - Rect.Left; x := MousePoint.x - Rect.Left;
y := MousePoint.y - Rect.Top; y := MousePoint.y - Rect.Top;
end; end;
@ -258,7 +280,7 @@ implementation
rect : TRect; rect : TRect;
w,h: integer; w,h: integer;
begin begin
GetWindowRect(handle, Rect); Rect := WindowRect;
x := x + rect.left; x := x + rect.left;
y := y + rect.top; y := y + rect.top;
if (x<0) or (y<0) then if (x<0) or (y<0) then
@ -270,7 +292,7 @@ implementation
Input : TInput; Input : TInput;
Rect : TRect; Rect : TRect;
begin begin
GetWindowRect(handle, Rect); Rect := WindowRect;
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;
@ -287,7 +309,7 @@ implementation
Input : TInput; Input : TInput;
Rect : TRect; Rect : TRect;
begin begin
GetWindowRect(handle, Rect); Rect := WindowRect;
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;
@ -379,7 +401,7 @@ end;
procedure TIOManager.SetDesktop; procedure TIOManager.SetDesktop;
begin begin
SetBothTargets(TWindow.Create(DesktopHWND)); SetBothTargets(TDesktopWindow.Create(DesktopHWND));
end; end;
function TIOManager.SetTarget(target: TNativeWindow): integer; function TIOManager.SetTarget(target: TNativeWindow): integer;
@ -387,4 +409,23 @@ end;
SetBothTargets(TWindow.Create(target)); SetBothTargets(TWindow.Create(target));
end; end;
{ TDesktopWindow }
constructor TDesktopWindow.Create(DesktopHandle: HWND);
begin
inherited Create;
self.dc := GetDC(DesktopHandle);
self.handle:= DesktopHandle;
Writeln('Created a desktop window');
end;
function TDesktopWindow.WindowRect: TRect;
begin
result.Left:= GetSystemMetrics(SM_XVIRTUALSCREEN);
result.Top:= GetSystemMetrics(SM_YVIRTUALSCREEN);
result.Right := GetSystemMetrics(SM_CXVIRTUALSCREEN);
result.Bottom:= GetSystemMetrics(SM_CYVIRTUALSCREEN);
end;
end. end.