On 2/25/06, Vincent Snijders <[EMAIL PROTECTED]> wrote:
> The magnifier uses a borderless form with the size of a the desktop, and
> before showing the form it copies the background from the screen. The
> background is frozen after that.
I only made it the size of the desktop to improve the drawing speed.
On the first versions it wasn't the size of the screen and worked the
same way, but the painting of the border was kind of slow on old
computers. Not a problem for most software.
It should be easy to adapt code from the magnifier to create a
transparent form. You only need to keep a screenshot at a TBitmap and
paint only a portion of it to the Canvas of the form according to the
position of the form on the screen. Then paint the other things on top
of that and with transparency.
The unit glass.pas from Virtual Magnifying Glass contains the code to
take a screenshot on both Windows and Linux, on the GetDisplayBitmap
method. I got the code from it and pasted here with some modifications
to make it more clear:
{*******************************************************************
* TGlass.GetDisplayBitmap ()
*
* DESCRIPTION: Get contents of the display
*
* PARAMETERS:
*
* RETURNS:
*
*******************************************************************}
function TGlass.GetDisplayBitmap: Boolean;
var
c: TCanvas;
srcRect, destRect: TRect;
TempDir, shellStr, Operation: string;
Before: TTimeStamp;
begin
Result := True;
{$IFDEF Win32}
c := TCanvas.Create;
try
try
c.Handle := GetWindowDC(GetDesktopWindow);
srcRect := Classes.Bounds(XScreen, YScreen, CXScreen, CYScreen);
destRect := Classes.Bounds(0, 0, CXScreen, CYScreen);
{*******************************************************************
* Fix for an issue with Windows 98 on StretchBlt
*******************************************************************}
if Versao >= vwWin2000 then
begin
bmpDisplay.Width := CXScreen;
bmpDisplay.Height := CYScreen;
end
else
begin
bmpDisplay.Width := CXScreen * 2;
bmpDisplay.Height := CYScreen * 2;
end;
bmpDisplay.Canvas.CopyRect(destRect, c, srcRect);
finally
ReleaseDC(0, c.Handle);
c.Free;
end;
except
Result := False;
Exit;
end;
{$ENDIF}
{$IFDEF Unix}
Before := DateTimeToTimeStamp(Now);
TempDir := GetTempDir(False);
shellStr := 'import -window root ' + TempDir + 'display.bmp';
WriteLn(shellStr);
shell(shellStr);
Write('Loading');
try
bmpDisplay.LoadFromFile(TempDir + 'display.bmp');
WriteLn(' ... took ' + IntToStr(DateTimeToTimeStamp(Now).Time -
Before.Time) + ' miliseconds');
except
WriteLn('');
WriteLn(ErrorImageMagick);
Result := False;
Exit;
end;
{$ENDIF}
end;
--
Felipe Monteiro de Carvalho
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives