tagchen,
ich habe festgestellt, daß die timerkomponente, wenn viel quellcode drin
steht, ziemlich resourcen frißt. jetzt wollte ich den timer durch einen
thread ersetzen. hier mein versuch:
type
TLupenThread = class(TThread)
protected
procedure Execute; override;
public
constructor create;
end;
constructor tlupenthread.create;
begin
FreeOnTerminate := True;
inherited Create(False);
end;
procedure tlupenthread.execute;
var r,Rt: TRect;
Pt, OldPt: tPoint;
DC: HDC;
x,y:integer;
handle:hwnd;
tick,punkt,akt:integer;
begin
while not terminated do
begin
{ermitteln des Desktophandles}
DC:=GetDC(GetDesktopWindow);
{*****************VERGRÖSSERUNGSBEREICH*********** ***********}
if vergroeserungsbereich = 'Maus' then
{Bereich unterhalb der maus wird vergrößert}
begin
GetCursorPos(Pt);
x := 0;
y := 0;
{ermittelt die Eckpunkte von panel1}
GetWindowRect(form1.Handle, Rt);
end;
{******************STANDORT DER LUPE**************************}
if Mausverfolgen = 'Ja' then
{Lupe folgt der Maus}
begin
{abfragen rechter rand}
if pt.x <= screen.width - form1.width - abwx then form1.left := pt.x +abwx else
form1.left := screen.width - form1.width;
{abfragen unterer Rand}
if pt.y <= screen.height - form1.height - abwx then form1.top := pt.y +abwx else
form1.top := screen.height - form1.height-abwy;
end;
if Mausverfolgen = 'gehweg' then
{Lupe geht der Maus aus dem weg}
begin
{wenn die maus von links kommt geht die lupe nach rechts}
if (pt.x +10 >= form1.left-10) and (pt.x + 10 <= form1.left) and (pt.y > form1.top)
and (pt.y < form1.top+form1.height) then
if form1.left + form1.width + 10 <= screen.width then form1.left := form1.left + 10;
{wenn die maus von rechts kommt geht die lupe nach links}
if (pt.x -10 <= form1.left+form1.width+10) and (pt.x - 10 >= form1.left+form1.width) and (pt.y > form1.top)
and (pt.y < form1.top+form1.height) then
if form1.left - 10 >= 0 then form1.left := form1.left - 10;
{wenn die maus von unten kommt geht die lupe nach oben}
if (pt.y -10 <= form1.top+form1.height+10) and (pt.y - 10 >= form1.top+form1.height)
and (pt.x > form1.left) and (pt.x < form1.left+form1.width) then
if form1.top -10 >= 0 then form1.top := form1.top - 10;
{wenn die maus von oben kommt geht die lupe nach unten}
if (pt.x > form1.left) and (pt.x < form1.left+form1.width)
and (pt.y + 10 < form1.top) and (pt.y + 10 > form1.top-10)
and (form1.top+10+form1.height <= screen.height-10) then form1.top := form1.top + 10;
end;
{deskbmp ist vom typ bitmap}
DeskBmp.Canvas.FillRect(DeskBmp.Canvas.ClipRect);
if ((OldPt.x<>Pt.x) or (OldPt.y<>Pt.y)) or (GetTickCount - Tick >= 100) // sind 100 Millisekunden vergangen ?
then
begin
Tick := GetTickCount; // sichere neue zeit
{die Mauszeigerposition wird gespeichert}
OldPt:=Pt;
if vergroeserungsbereich = 'Maus' then
begin
form1.ScanDC(DC, DeskBmp.Canvas.handle, x, y, Rect(Pt.x-w div
ich habe festgestellt, daß die timerkomponente, wenn viel quellcode drin
steht, ziemlich resourcen frißt. jetzt wollte ich den timer durch einen
thread ersetzen. hier mein versuch:
type
TLupenThread = class(TThread)
protected
procedure Execute; override;
public
constructor create;
end;
constructor tlupenthread.create;
begin
FreeOnTerminate := True;
inherited Create(False);
end;
procedure tlupenthread.execute;
var r,Rt: TRect;
Pt, OldPt: tPoint;
DC: HDC;
x,y:integer;
handle:hwnd;
tick,punkt,akt:integer;
begin
while not terminated do
begin
{ermitteln des Desktophandles}
DC:=GetDC(GetDesktopWindow);
{*****************VERGRÖSSERUNGSBEREICH*********** ***********}
if vergroeserungsbereich = 'Maus' then
{Bereich unterhalb der maus wird vergrößert}
begin
GetCursorPos(Pt);
x := 0;
y := 0;
{ermittelt die Eckpunkte von panel1}
GetWindowRect(form1.Handle, Rt);
end;
{******************STANDORT DER LUPE**************************}
if Mausverfolgen = 'Ja' then
{Lupe folgt der Maus}
begin
{abfragen rechter rand}
if pt.x <= screen.width - form1.width - abwx then form1.left := pt.x +abwx else
form1.left := screen.width - form1.width;
{abfragen unterer Rand}
if pt.y <= screen.height - form1.height - abwx then form1.top := pt.y +abwx else
form1.top := screen.height - form1.height-abwy;
end;
if Mausverfolgen = 'gehweg' then
{Lupe geht der Maus aus dem weg}
begin
{wenn die maus von links kommt geht die lupe nach rechts}
if (pt.x +10 >= form1.left-10) and (pt.x + 10 <= form1.left) and (pt.y > form1.top)
and (pt.y < form1.top+form1.height) then
if form1.left + form1.width + 10 <= screen.width then form1.left := form1.left + 10;
{wenn die maus von rechts kommt geht die lupe nach links}
if (pt.x -10 <= form1.left+form1.width+10) and (pt.x - 10 >= form1.left+form1.width) and (pt.y > form1.top)
and (pt.y < form1.top+form1.height) then
if form1.left - 10 >= 0 then form1.left := form1.left - 10;
{wenn die maus von unten kommt geht die lupe nach oben}
if (pt.y -10 <= form1.top+form1.height+10) and (pt.y - 10 >= form1.top+form1.height)
and (pt.x > form1.left) and (pt.x < form1.left+form1.width) then
if form1.top -10 >= 0 then form1.top := form1.top - 10;
{wenn die maus von oben kommt geht die lupe nach unten}
if (pt.x > form1.left) and (pt.x < form1.left+form1.width)
and (pt.y + 10 < form1.top) and (pt.y + 10 > form1.top-10)
and (form1.top+10+form1.height <= screen.height-10) then form1.top := form1.top + 10;
end;
{deskbmp ist vom typ bitmap}
DeskBmp.Canvas.FillRect(DeskBmp.Canvas.ClipRect);
if ((OldPt.x<>Pt.x) or (OldPt.y<>Pt.y)) or (GetTickCount - Tick >= 100) // sind 100 Millisekunden vergangen ?
then
begin
Tick := GetTickCount; // sichere neue zeit
{die Mauszeigerposition wird gespeichert}
OldPt:=Pt;
if vergroeserungsbereich = 'Maus' then
begin
form1.ScanDC(DC, DeskBmp.Canvas.handle, x, y, Rect(Pt.x-w div
Comment