P
pllink_qyd
Unregistered / Unconfirmed
GUEST, unregistred user!
来自:hb_126, 时间:2006-4-11 9:15:58, ID:3410744
一个简单的例子
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
Button2: TButton;
procedure Button2Click(Sender: TObject);
private
MouX, MouY: Integer;
procedure KeyDown1(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure MouseDown1(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MouseUp1(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var
FForm: TForm;
l:longint;
begin
Application.CreateForm(TForm,FForm);
with FForm do
begin
WindowState := wsMaximized;
BorderStyle := bsNone;
l:=GetWindowLong(Handle, GWL_EXSTYLE);
l := l Or $80000;
SetWindowLong (Handle, GWL_EXSTYLE, l);
SetLayeredWindowAttributes(Handle, 0, 1, 2);
OnKeyDown := KeyDown1;
OnMouseDown := MouseDown1;
OnMouseUp := MouseUp1;
ShowModal;
end;
end;
procedure TForm1.KeyDown1(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ESCAPE then
begin
(Sender as TForm).Close;
end;
end;
procedure TForm1.MouseDown1(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
p: TPoint;
begin
GetCursorPos(P);
MouX := P.X;
MouY := p.Y;
end;
procedure TForm1.MouseUp1(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Mybmp : Tbitmap;
Mycan : Tcanvas;
dc: Integer;
R : TRect;
FPixFmt : TPixelFormat;
p: TPoint;
begin
FPixFmt := pf32bit;
Mybmp := Tbitmap.Create;
Mycan := TCanvas.Create;
dc := GetwindowDC(0);
try
Mycan.Handle := DC;
GetCursorPos(P);
R := Rect(MouX, MouY, P.X, P.Y);
Mybmp.Width := R.Right;
Mybmp.Height := R.Bottom;
Mybmp.PixelFormat := FPixFmt;
BitBlt(Mybmp.Canvas.Handle, MouX, MouY, P.X, P.Y, Mycan.Handle, 0, 0, SRCCOPY);
Mybmp.Canvas.CopyRect(R, Mycan, R);
finally
ReleaseDC(0, DC);
end;
Mycan.Handle := 0;
Mycan.Free;
self.Image1.Picture.Bitmap := Mybmp;
end;
end.
来自:pllink_qyd, 时间:2006-4-11 9:41:11, ID:3410775 | 编辑
hb_126:首先很感謝你為我解答,那少少分就當我的一點心意吧。。我的MSN,qyd_0591@hotmail.com..希望你能加我。。做個朋友。其實我想拜師。
其次,為什麼你最後的那個我運行的時候。。會提示這個錯誤:
Project Project1.exe raised exception class EReadError with message 'Invalid property value'.
這個是什麼原因阿?
一个简单的例子
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
Button2: TButton;
procedure Button2Click(Sender: TObject);
private
MouX, MouY: Integer;
procedure KeyDown1(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure MouseDown1(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MouseUp1(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var
FForm: TForm;
l:longint;
begin
Application.CreateForm(TForm,FForm);
with FForm do
begin
WindowState := wsMaximized;
BorderStyle := bsNone;
l:=GetWindowLong(Handle, GWL_EXSTYLE);
l := l Or $80000;
SetWindowLong (Handle, GWL_EXSTYLE, l);
SetLayeredWindowAttributes(Handle, 0, 1, 2);
OnKeyDown := KeyDown1;
OnMouseDown := MouseDown1;
OnMouseUp := MouseUp1;
ShowModal;
end;
end;
procedure TForm1.KeyDown1(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ESCAPE then
begin
(Sender as TForm).Close;
end;
end;
procedure TForm1.MouseDown1(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
p: TPoint;
begin
GetCursorPos(P);
MouX := P.X;
MouY := p.Y;
end;
procedure TForm1.MouseUp1(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Mybmp : Tbitmap;
Mycan : Tcanvas;
dc: Integer;
R : TRect;
FPixFmt : TPixelFormat;
p: TPoint;
begin
FPixFmt := pf32bit;
Mybmp := Tbitmap.Create;
Mycan := TCanvas.Create;
dc := GetwindowDC(0);
try
Mycan.Handle := DC;
GetCursorPos(P);
R := Rect(MouX, MouY, P.X, P.Y);
Mybmp.Width := R.Right;
Mybmp.Height := R.Bottom;
Mybmp.PixelFormat := FPixFmt;
BitBlt(Mybmp.Canvas.Handle, MouX, MouY, P.X, P.Y, Mycan.Handle, 0, 0, SRCCOPY);
Mybmp.Canvas.CopyRect(R, Mycan, R);
finally
ReleaseDC(0, DC);
end;
Mycan.Handle := 0;
Mycan.Free;
self.Image1.Picture.Bitmap := Mybmp;
end;
end.
来自:pllink_qyd, 时间:2006-4-11 9:41:11, ID:3410775 | 编辑
hb_126:首先很感謝你為我解答,那少少分就當我的一點心意吧。。我的MSN,qyd_0591@hotmail.com..希望你能加我。。做個朋友。其實我想拜師。
其次,為什麼你最後的那個我運行的時候。。會提示這個錯誤:
Project Project1.exe raised exception class EReadError with message 'Invalid property value'.
這個是什麼原因阿?