说明:做了着色处理;用Alt+F4关闭;鼠标拖动。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure WMWinPosChanging(var Message: TWMWindowPosChanging);
message WM_WINDOWPOSCHANGING;
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd);
message WM_ERASEBKGND;
procedure FormPaint(Sender: TObject);
procedure FormMouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
private
ScrBuff: TBitmap;
procedure GetScreen;
public
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
ScrBuff := TBitmap.Create;
BorderStyle := bsNone;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
ScrBuff.Free;
end;
procedure TForm1.GetScreen;
var
R: TRect;
begin
ScrBuff.Width := Screen.Width;
ScrBuff.Height := Screen.Height;
ScrBuff.Canvas.Brush.Style := bsSolid;
ScrBuff.Canvas.Brush.Color := $00FFFF80;
R := Rect(0, 0, Screen.Width, Screen.Height);
ScrBuff.Canvas.FillRect(R);
BitBlt(ScrBuff.Canvas.Handle, 0, 0, Screen.Width, Screen.Height, GetDC(0), 0, 0, srcAnd);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
GetScreen;
end;
procedure TForm1.WMWinPosChanging(var Message: TWMWindowPosChanging);
begin
Invalidate;
end;
procedure TForm1.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
{}
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
Canvas.Draw(- Left, - Top, ScrBuff);
end;
procedure TForm1.FormMouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
if Button = mbLeft then
begin
ReleaseCapture;
SendMessage(Handle, WM_SYSCOMMAND, SC_MOVE or 2, 0);
end;
end;
end.