J
jbas
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是程序代码!不过有很多东西可以删除,各位可以自己删除。发表这个小东西,就当我为
dfw提供一点hook的资料,大家可别把它当垃圾了。
资源文件:
mycur cursor pen.cur //pen的资源文件定义
程序代码:
unit tymain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
GroupBox1: TGroupBox;
GroupBox3: TGroupBox;
SpeedButton3: TSpeedButton;
Panel1: TPanel;
Image1: TImage;
Panel2: TPanel;
Panel3: TPanel;
SpeedButton4: TSpeedButton;
Panel4: TPanel;
Panel5: TPanel;
Panel6: TPanel;
Panel7: TPanel;
Panel8: TPanel;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure Image1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
procedure Image1DblClick(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure Panel2DblClick(Sender: TObject);
procedure Image1Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure Panel5Click(Sender: TObject);
procedure Panel6Click(Sender: TObject);
procedure Panel7Click(Sender: TObject);
procedure Panel8Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
pencolor:tcolor;
mycanvas:tcanvas;
screendc:hdc;
pensize,hook,mm:integer;
can:boolean=false;
implementation
{$R *.dfm}
{$R mycursor.res}
function hookproc(icode:integer;wparam:wparam;lparam:lparam):lresult;stdcall;
var
evtmsg:teventmsg;
begin
evtmsg:=peventmsg(lparam)^;
if evtmsg.message=WM_LBUTTONDOWN then
begin
can:=true;
mycanvas.moveto(mouse.CursorPos.X,mouse.CursorPos.Y);
end;
if evtmsg.message=WM_LBUTTONUP then
can:=false;
if can=true then
begin
if evtmsg.message=WM_MOUSEMOVE then
begin
with mycanvasdo
begin
Pen.Color:=form1.Panel1.Color;
lineto(mouse.CursorPos.X,mouse.CursorPos.Y);
end;
end;
end;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
screendc:=getdc(0);
mycanvas:=tcanvas.Create;
mycanvas.Handle:=screendc;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
InvalidateRect(0, nil, true);
//屏幕刷新
close;
end;
procedure TForm1.Image1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
begin
pencolor:=image1.Picture.Bitmap.Canvas.Pixels[X,Y];
panel3.Color:=pencolor;
end;
procedure TForm1.Image1DblClick(Sender: TObject);
var
colordial:tcolordialog;
begin
colordial:=tcolordialog.Create(self);
colordial.Color:=pencolor;
colordial.Execute;
panel2.Color:=colordial.Color;
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
var
scr:hicon;
begin
panel2.SetFocus;
scr:=loadcursor(hinstance,'mycur');
setsystemcursor(scr,ocr_normal);
//改变系统的鼠标图标
mycanvas.Pen.Color:=panel1.Color;
hook:=setwindowshookex(WH_JOURNALRECORD,hookproc,hinstance,0);
//安装钩子
end;
procedure TForm1.Panel2DblClick(Sender: TObject);
var
mycolor:tcolordialog;
begin
mycolor:=tcolordialog.Create(self);
mycolor.Color:=panel2.Color;
mycolor.Execute;
panel2.Color:=mycolor.Color;
end;
procedure TForm1.Image1Click(Sender: TObject);
begin
panel2.Color:=panel3.Color;
end;
procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
systemparametersinfo(spi_setcursors,0,nil,spif_sendchange);
//恢复系统的鼠标图标
unhookwindowshookex(hook);//撤销钩子
end;
procedure TForm1.Panel5Click(Sender: TObject);
begin
pensize:=panel5.Height;
if panel5.BorderStyle=bssingle then
begin
panel5.BorderStyle:=bsnone;
panel5.BevelInner:=bvnone;
panel5.BevelOuter:=bvnone;
end
else
begin
panel5.BorderStyle:=bssingle;
panel5.BevelInner:=bvlowered;
panel5.BevelOuter:=bvraised;
end;
end;
procedure TForm1.Panel6Click(Sender: TObject);
begin
pensize:=panel6.Height;
if panel6.BorderStyle=bssingle then
begin
panel6.BorderStyle:=bsnone;
panel6.BevelInner:=bvnone;
panel6.BevelOuter:=bvnone;
end
else
begin
panel6.BorderStyle:=bssingle;
panel6.BevelInner:=bvlowered;
panel6.BevelOuter:=bvraised;
end;
end;
procedure TForm1.Panel7Click(Sender: TObject);
begin
pensize:=panel7.Height;
if panel7.BorderStyle=bssingle then
begin
panel7.BorderStyle:=bsnone;
panel7.BevelInner:=bvnone;
panel7.BevelOuter:=bvnone;
end
else
begin
panel7.BorderStyle:=bssingle;
panel7.BevelInner:=bvlowered;
panel7.BevelOuter:=bvraised;
end;
end;
procedure TForm1.Panel8Click(Sender: TObject);
begin
pensize:=panel8.Height;
if panel8.BorderStyle=bssingle then
begin
panel8.BorderStyle:=bsnone;
panel8.BevelInner:=bvnone;
panel8.BevelOuter:=bvnone;
end
else
begin
panel8.BorderStyle:=bssingle;
panel8.BevelInner:=bvlowered;
panel8.BevelOuter:=bvraised;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
screendc:=getdc(0);
mycanvas:=tcanvas.Create;
mycanvas.Handle:=screendc;
end;
end.
可以在vcd播放的画面上画东西,挺有趣的。
dfw提供一点hook的资料,大家可别把它当垃圾了。
资源文件:
mycur cursor pen.cur //pen的资源文件定义
程序代码:
unit tymain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
GroupBox1: TGroupBox;
GroupBox3: TGroupBox;
SpeedButton3: TSpeedButton;
Panel1: TPanel;
Image1: TImage;
Panel2: TPanel;
Panel3: TPanel;
SpeedButton4: TSpeedButton;
Panel4: TPanel;
Panel5: TPanel;
Panel6: TPanel;
Panel7: TPanel;
Panel8: TPanel;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure Image1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
procedure Image1DblClick(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure Panel2DblClick(Sender: TObject);
procedure Image1Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure Panel5Click(Sender: TObject);
procedure Panel6Click(Sender: TObject);
procedure Panel7Click(Sender: TObject);
procedure Panel8Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
pencolor:tcolor;
mycanvas:tcanvas;
screendc:hdc;
pensize,hook,mm:integer;
can:boolean=false;
implementation
{$R *.dfm}
{$R mycursor.res}
function hookproc(icode:integer;wparam:wparam;lparam:lparam):lresult;stdcall;
var
evtmsg:teventmsg;
begin
evtmsg:=peventmsg(lparam)^;
if evtmsg.message=WM_LBUTTONDOWN then
begin
can:=true;
mycanvas.moveto(mouse.CursorPos.X,mouse.CursorPos.Y);
end;
if evtmsg.message=WM_LBUTTONUP then
can:=false;
if can=true then
begin
if evtmsg.message=WM_MOUSEMOVE then
begin
with mycanvasdo
begin
Pen.Color:=form1.Panel1.Color;
lineto(mouse.CursorPos.X,mouse.CursorPos.Y);
end;
end;
end;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
screendc:=getdc(0);
mycanvas:=tcanvas.Create;
mycanvas.Handle:=screendc;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
InvalidateRect(0, nil, true);
//屏幕刷新
close;
end;
procedure TForm1.Image1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
begin
pencolor:=image1.Picture.Bitmap.Canvas.Pixels[X,Y];
panel3.Color:=pencolor;
end;
procedure TForm1.Image1DblClick(Sender: TObject);
var
colordial:tcolordialog;
begin
colordial:=tcolordialog.Create(self);
colordial.Color:=pencolor;
colordial.Execute;
panel2.Color:=colordial.Color;
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
var
scr:hicon;
begin
panel2.SetFocus;
scr:=loadcursor(hinstance,'mycur');
setsystemcursor(scr,ocr_normal);
//改变系统的鼠标图标
mycanvas.Pen.Color:=panel1.Color;
hook:=setwindowshookex(WH_JOURNALRECORD,hookproc,hinstance,0);
//安装钩子
end;
procedure TForm1.Panel2DblClick(Sender: TObject);
var
mycolor:tcolordialog;
begin
mycolor:=tcolordialog.Create(self);
mycolor.Color:=panel2.Color;
mycolor.Execute;
panel2.Color:=mycolor.Color;
end;
procedure TForm1.Image1Click(Sender: TObject);
begin
panel2.Color:=panel3.Color;
end;
procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
systemparametersinfo(spi_setcursors,0,nil,spif_sendchange);
//恢复系统的鼠标图标
unhookwindowshookex(hook);//撤销钩子
end;
procedure TForm1.Panel5Click(Sender: TObject);
begin
pensize:=panel5.Height;
if panel5.BorderStyle=bssingle then
begin
panel5.BorderStyle:=bsnone;
panel5.BevelInner:=bvnone;
panel5.BevelOuter:=bvnone;
end
else
begin
panel5.BorderStyle:=bssingle;
panel5.BevelInner:=bvlowered;
panel5.BevelOuter:=bvraised;
end;
end;
procedure TForm1.Panel6Click(Sender: TObject);
begin
pensize:=panel6.Height;
if panel6.BorderStyle=bssingle then
begin
panel6.BorderStyle:=bsnone;
panel6.BevelInner:=bvnone;
panel6.BevelOuter:=bvnone;
end
else
begin
panel6.BorderStyle:=bssingle;
panel6.BevelInner:=bvlowered;
panel6.BevelOuter:=bvraised;
end;
end;
procedure TForm1.Panel7Click(Sender: TObject);
begin
pensize:=panel7.Height;
if panel7.BorderStyle=bssingle then
begin
panel7.BorderStyle:=bsnone;
panel7.BevelInner:=bvnone;
panel7.BevelOuter:=bvnone;
end
else
begin
panel7.BorderStyle:=bssingle;
panel7.BevelInner:=bvlowered;
panel7.BevelOuter:=bvraised;
end;
end;
procedure TForm1.Panel8Click(Sender: TObject);
begin
pensize:=panel8.Height;
if panel8.BorderStyle=bssingle then
begin
panel8.BorderStyle:=bsnone;
panel8.BevelInner:=bvnone;
panel8.BevelOuter:=bvnone;
end
else
begin
panel8.BorderStyle:=bssingle;
panel8.BevelInner:=bvlowered;
panel8.BevelOuter:=bvraised;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
screendc:=getdc(0);
mycanvas:=tcanvas.Create;
mycanvas.Handle:=screendc;
end;
end.
可以在vcd播放的画面上画东西,挺有趣的。