unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure buttonclick(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure muve(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
kk:byte;
xx,yy,xxl,yyl:integer;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var hwnd:longint;
rgn:hrgn;
poi:array[1..10] of tpoint;
n,m,l,i,j:integer;
begin m:=5;
poi[1].x:=0;
poi[1].y:=0;
poi[2].x:=0;
poi[2].y:=form1.Height div 2;
poi[3].x:=form1.Width div 2;
poi[3].y:=form1.Height;
poi[4].x:=form1.Width;
poi[4].y:=form1.Height div 2;
poi[5].x:=form1.Width;
poi[5].y:=0;
rgn:=CreatePolygonRgn(poi,m,i);
setwindowrgn(form1.Handle ,rgn,true);
end;
function BitmapToRegion(Bitmap: TBitmap; TransColor: TColor): HRGN;
var X,Y: Integer;
XStart: Integer;
pb

ByteArray;
begin Result:= 0;
for Y:= 0 to Bitmap.Height - 1 do
begin
X:= 0;
//with bitmap do
pb:=bitmap.ScanLine[y];
while X <Bitmap.Width do
begin
while (X <Bitmap.Width) and (pb^[X] =TransColor) do
inc(X);
if X >=Bitmap.Width then
Break;
XStart := X;
while (X <Bitmap.Width) and (pb^[x]<>TransColor) do
Inc(X);
if Result = 0 then
Result := CreateRectRgn(XStart, Y, X, Y + 1)
else
CombineRgn(Result, Result,CreateRectRgn(XStart, Y, X, Y + 1), RGN_OR);
end;
{with bitmap do
while X <Width do
begin
while (X <Width) and (Canvas.Pixels[X, Y] = TransColor) do
Inc(X);
if X >=Width then
Break;
XStart := X;
while (X <Width) and (Canvas.Pixels[X, Y] <>TransColor) do
Inc(X);
if Result = 0 then
Result := CreateRectRgn(XStart, Y, X, Y + 1)
else
CombineRgn(Result, Result,
CreateRectRgn(XStart, Y, X, Y + 1), RGN_OR);
end;}
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var rgn:hrgn;
Bitmap: TBitmap;
color:TColor;
begin Bitmap := TBitmap.Create;
Bitmap.LoadFromFile('c:\11.bmp');
color:=255;
rgn:=BitmapToRegion(bitmap,color);
setwindowrgn(form1.Handle ,rgn,true);
form1.Canvas.Draw(-3,-24,bitmap);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
CLOSE
end;
procedure TForm1.buttonclick(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin if ord(button)=0 then if kk=0 then kk:=1
else kk:=0
else kk:=1;
end;
procedure TForm1.muve(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var c:cardinal;
begin if kk=0 then begin
xx:=xx-(xxl-x);
yy:=yy-(yyl-y);
xxl:=x;
yyl:=y;
form1.Caption:=inttostr(xx);
SetWindowPos(form1.handle,form1.handle,xx,yy,form1.Width,form1.Height, c);
timer1.Interval:=100;
end
else form1.Caption:='aaaaaaaaaa';
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var c:cardinal;
begin //SetWindowPos(form1.handle,getnextwindow(form1.handle,1),xx,yy,form1.Wi dth,form1.Height,c);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin kk:=12;
end;
end.