1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-11 11:55:02 -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;
const
SimbaVersion = 560;
SimbaVersion = 561;
type

View File

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