如何在一个在FORM里的IMAGE里实现,鼠标任意移动到屏幕的某个位置 ,以鼠标指针为中心点的自定义边长的一个矩形筐,时时抓取矩形内屏幕图像到IMAGE中?
解决方案 »
- 培训
- 散分 宣传
- 如果query中添加了lookup字段,如何将与它相连的dbgrid中的数据applyupdates到表中
- 哥哥们,能给我点力量吗?
- 这年头,有用MySQL做C/S结构的应用的数据库的么?用InterBase的我倒是见过,例如速达,那么MySQL是否有IB那么方便呢?!
- 创建窗体
- 请问如何把paradox7 的数据导出到sql2000中呢
- 往Memo控件里面添加十六进制的数据,当识别但某个字时(如AA),就在Memo中换行显示,请问该如何做???在线等待!!!!
- adodataset按给定条件(dblookupcombobox和edit1控件中输入)查询出错?????
- Tdatetime字段
- 请教!!希望各位大虾不吝赐教~~
- 请问<<DELPHI 5开发人员指南>>有没有随书原码?
Shift: TShiftState; X, Y: Integer);
var
R1: TRect;
R2: TRect;
begin
R2.Left:=x-35;
R2.Top:=y-35;
R2.Right:=x+35;
R2.Bottom:=y+35; R1.Left:=0;
R1.Top:=0;
R1.Right:=70;
R1.Bottom:=70;
Image2.Canvas.CopyRect(R1,Image1.Canvas,R2)
end;
不行啊 在IMAGE里面只有白色的筐 我在timer里写的 x,y坐标我都有
我想时时随着鼠标指针的移动 IMAGE里也跟着变
随鼠标动,可以写到onMouseMove里面啊
白色的筐?加张图片试试?
Mo:integer; //全局变量,记录指针是否按下procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
R1: TRect;
R2: TRect;
begin
if mo=1 then
begin
R2.Left:=x-35;
R2.Top:=y-35;
R2.Right:=x+35;
R2.Bottom:=y+35; R1.Left:=0;
R1.Top:=0;
R1.Right:=70;
R1.Bottom:=70;
form1.Canvas.CopyRect(R1,Image1.Canvas,R2)
end;
end;procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
mo:=1;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
mo:=0;
end;procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
mo:=0;
end;
已知鼠标在屏幕上得X,Y,在IMAGE中实现以鼠标指针为中心点的自定义边长的一个矩形筐,时时抓取矩形内屏幕图像到IMAGE中
重点:不能在MOUSEMOVE中写 因为这只能局限在IMAGE中
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
function LowLevelKeyboardFunc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
const WH_MOUSE_LL=14;
var
Form1: TForm1;
hkNTKeyboard: HHOOK;implementation{$R *.dfm}{ TForm1 }
function LowLevelKeyboardFunc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;var
cav:Tcanvas;
dc:HDC;
p:Tpoint;
i,j:integer;
rectdest,rectSource:TRect;
begin
if ncode<>0 then
begin
Result:=CallNextHookEx(0, nCode, wParam, lParam);
exit;
end; case wParam of
WM_MOUSEMOVE:
begin dc:=GetDc(0);
cav:=Tcanvas.Create;
cav.Handle:=dc;
Getcursorpos(p);
rectsource.Top:=p.y-30;
rectsource.Left:=p.X-30;
rectsource.Right:=p.X+30;
rectsource.Bottom:=p.Y+30;
rectdest.Top:=0;
rectdest.Left:=0;
rectdest.Right:=60;
rectdest.Bottom:=60;
Form1.Image1.Canvas.CopyRect(rectdest,cav,rectsource);
end;
end;
Result:=CallNextHookEx(0, nCode, wParam, lParam);
end;procedure TForm1.FormCreate(Sender: TObject);
begin
hkNTKeyboard:=SetWindowsHookEx(WH_MOUSE_LL, LowLevelKeyboardFunc, HInstance, 0);
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnHookWindowsHookEx(hkNTKeyboard);end;end.
var
SC_MANIPULATE: Word;
begin
if (X<=Precision) and (Y>Precision) and (Y<Control.Height-Precision) and (Size) then
begin
SC_MANIPULATE := $F001;
Control.Cursor := crSizeWE;
end
else if (X>=Control.Width-Precision) and (Y>Precision) and (Y<Control.Height-Precision) and (Size) then
begin
SC_MANIPULATE := $F002;
Control.Cursor := crSizeWE;
end
else if (X>Precision) and (X<Control.Width-Precision) and (Y<=Precision) and (Size) then
begin
SC_MANIPULATE := $F003;
Control.Cursor := crSizeNS;
end
else if (X<=Precision) and (Y<=Precision) and (Size) then
begin
SC_MANIPULATE := $F004;
Control.Cursor := crSizeNWSE;
end
else if (X>=Control.Width-Precision) and (Y<=Precision) and (Size) then
begin
SC_MANIPULATE := $F005;
Control.Cursor := crSizeNESW;
end
else if (X>Precision) and (X<Control.Width-Precision) and (Y>=Control.Height-Precision) and (Size) then
begin
SC_MANIPULATE := $F006;
Control.Cursor := crSizeNS;
end
else if (X<=Precision) and (Y>=Control.Height-Precision) and (Size) then
begin
SC_MANIPULATE := $F007;
Control.Cursor := crSizeNESW;
end
else if (X>=Control.Width-Precision) and (Y>=Control.Height-Precision) and (Size) then
begin
SC_MANIPULATE := $F008;
Control.Cursor := crSizeNWSE;
end
else if (X>5) and (Y>5) and (X<Control.Width-5) and (Y<Control.Height-5) and (Move) then
begin
SC_MANIPULATE := $F009;
Control.Cursor := crSizeAll;
end
else
begin
SC_MANIPULATE := $F000;
Control.Cursor := crDefault;
end;
if Shift=[ssLeft] then
begin
ReleaseCapture;
Control.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);
end;
end;procedure TForm3.TheImageMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
with Form1 do
if ButtonToolIndex=0 then
ManipulateControl((Sender as TControl),True,False,Shift, X, Y, 10)
else
TControl(Sender).Cursor := crDefault;
end;