我要求在一个已经显示在image里的图像(图像位于image的中央)上运用鼠标划定一个区域(可以是一个矩形),然后拖动这个区域,在这个图像上选择我所感兴趣的部分,再把最后确定的区域的四个顶点的坐标位置传送到一个过程里面
谢谢 那位大哥可以解答
谢谢 那位大哥可以解答
解决方案 »
- DataGrid显示小数的问题
- DELPHI菜鸟发问,大家帮忙啊。
- 奇怪,我这句怎么通不过呢:if assigned(FChild)<>nil then
- 大家好,我现在在用Microsoft Speech SDK 5.1开发语音软件,请问完成后,打安装包,怎么把它打进去????
- ADO平台下,怎么和数据库同步更新
- 連Linux 下面的Oracle數據庫問題﹖
- 有没有人有Delphi7.0中,Rave Reports5.0详细使用教程吗
- 共享软件注册!
- 请教复杂的sql问题!高手请进!!!
- 怎样模拟移动滚动条,如果我在richedit中按下空格键,richedit就向下滚动10个象素。
- 如何获得当前输入焦点中光标的位置,注意是光标不是鼠标?
- 是蜕化还是退化
Shift: TShiftState; X, Y, Precision: integer);
var
SC_MANIPULATE: Word;
begin
//光标在控件的最左侧
if (X <= Precision) and (Y > Precision) and (Y < Control.Height - Precision)
then
begin
SC_MANIPULATE := $F001;
Control.Cursor := crSizeWE;
end
//光标在控件的最右侧
else if (X >= Control.Width - Precision) and (Y > Precision) and
(Y < Control.Height - Precision) then
begin
SC_MANIPULATE := $F002;
Control.Cursor := crSizeWE;
end
//光标在控件的最上侧
else if (X > Precision) and (X < Control.Width - Precision) and (Y <=
Precision) then
begin
SC_MANIPULATE := $F003;
Control.Cursor := crSizeNS;
end
//光标在控件的左上角
else if (X <= Precision) and (Y <= Precision) then
begin
SC_MANIPULATE := $F004;
Control.Cursor := crSizeNWSE;
end
//光标在控件的右上角
else if (X >= Control.Width - Precision) and (Y <= Precision) then
begin
SC_MANIPULATE := $F005;
Control.Cursor := crSizeNESW;
end
//光标在控件的最下侧
else if (X > Precision) and (X < Control.Width - Precision) and
(Y >= Control.Height - Precision) then
begin
SC_MANIPULATE := $F006;
Control.Cursor := crSizeNS;
end
//光标在控件的左下角
else if (X <= Precision) and (Y >= Control.Height - Precision) then
begin
SC_MANIPULATE := $F007;
Control.Cursor := crSizeNESW;
end
//光标在控件的右下角
else if (X >= Control.Width - Precision) and (Y >= Control.Height - Precision)
then
begin
SC_MANIPULATE := $F008;
Control.Cursor := crSizeNWSE;
end
//光标在控件的客户区(移动整个控件)
else if (X > Precision) and (Y > Precision) and (X < Control.Width - Precision)
and
(Y < Control.Height - Precision) 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 SampleMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
ManipulateControl(TControl(Sender), Shift, X, Y, 5);
with TControl(Sender) do
begin
if Left < 0 then
Left := 0;
if Top < 0 then
Top := 0;
if Left + Width > Parent.Width then
Left := Parent.Width - Width;
if Top + Height > Parent.Height then
Top := Parent.Height - Height;
if Width < 20 then
Width := 20;
if Height < 20 then
Height := 20;
end;
end;
在Image的 MouseDown事件中AlarmRecBox:= TStaticText.Create(Self);//动态生成所画的框
with AlarmRecBox do
begin
Left := x;
Top := Y;
Width := 50;
Height := 50;
Caption := '';
Color := clFuchsia;
Parent := stt_Window;
BevelInner := bvLowered;
BevelKind := bkTile;
BevelOuter := bvRaised;
Visible := True;
OnMouseMove := SampleMouseMove;
end;
[Error] kuang.pas(134): Undeclared identifier: 'TStaticText'
[Error] kuang.pas(134): Missing operator or semicolon
[Error] kuang.pas(143): Undeclared identifier: 'stt_Window'
[Error] kuang.pas(12): Unsatisfied forward or external declaration: 'TForm1.ManipulateControl'
[Error] kuang.pas(13): Unsatisfied forward or external declaration: 'TForm1.SampleMouseMove'
uses
StdCtrls;
AlarmRecBox: TStaticText; stt_window:可以定义成TStaticText,哦,这里你是TImage;declaration: 'TForm1.ManipulateControl'
[Error] kuang.pas(13): Unsatisfied forward or external declaration: 'TForm1.SampleMouseMove'
你定义成窗体的函数即可嘛
unit kuang;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls,StdCtrls;type
TForm1 = class(TForm)
Image1: TImage;
AlarmRecBox: TStaticText;
stt_window:TStaticText;
//AlarmRecBox: TStaticText;
procedure ManipulateControl(Control: TControl;Shift: TShiftState; X, Y, Precision: integer);
procedure SampleMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
implementation{$R *.dfm}procedure TForm1.ManipulateControl(Control: TControl;
Shift: TShiftState; X, Y, Precision: integer);
var
SC_MANIPULATE: Word;
begin
//光标在控件的最左侧
if (X <= Precision) and (Y > Precision) and (Y < Control.Height - Precision)
then
begin
SC_MANIPULATE := $F001;
Control.Cursor := crSizeWE;
end
//光标在控件的最右侧
else if (X >= Control.Width - Precision) and (Y > Precision) and
(Y < Control.Height - Precision) then
begin
SC_MANIPULATE := $F002;
Control.Cursor := crSizeWE;
end
//光标在控件的最上侧
else if (X > Precision) and (X < Control.Width - Precision) and (Y <=
Precision) then
begin
SC_MANIPULATE := $F003;
Control.Cursor := crSizeNS;
end
//光标在控件的左上角
else if (X <= Precision) and (Y <= Precision) then
begin
SC_MANIPULATE := $F004;
Control.Cursor := crSizeNWSE;
end
//光标在控件的右上角
else if (X >= Control.Width - Precision) and (Y <= Precision) then
begin
SC_MANIPULATE := $F005;
Control.Cursor := crSizeNESW;
end
//光标在控件的最下侧
else if (X > Precision) and (X < Control.Width - Precision) and
(Y >= Control.Height - Precision) then
begin
SC_MANIPULATE := $F006;
Control.Cursor := crSizeNS;
end
//光标在控件的左下角
else if (X <= Precision) and (Y >= Control.Height - Precision) then
begin
SC_MANIPULATE := $F007;
Control.Cursor := crSizeNESW;
end
//光标在控件的右下角
else if (X >= Control.Width - Precision) and (Y >= Control.Height - Precision)
then
begin
SC_MANIPULATE := $F008;
Control.Cursor := crSizeNWSE;
end
//光标在控件的客户区(移动整个控件)
else if (X > Precision) and (Y > Precision) and (X < Control.Width - Precision)
and
(Y < Control.Height - Precision) 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 TForm1.SampleMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
ManipulateControl(TControl(Sender), Shift, X, Y, 5);
with TControl(Sender) do
begin
if Left < 0 then
Left := 0;
if Top < 0 then
Top := 0;
if Left + Width > Parent.Width then
Left := Parent.Width - Width;
if Top + Height > Parent.Height then
Top := Parent.Height - Height;
if Width < 20 then
Width := 20;
if Height < 20 then
Height := 20;
end;
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
AlarmRecBox:= TStaticText.Create(Self);//动态生成所画的框
with AlarmRecBox do
begin
Left := x;
Top := Y;
Width := 50;
Height := 50;
Caption := '';
Color := clFuchsia;
Parent := stt_Window;
BevelInner := bvLowered;
BevelKind := bkTile;
BevelOuter := bvRaised;
Visible := True;
OnMouseMove := SampleMouseMove;
end;
end;end.
其实我这个有点像图像局部放大的意思
在一个原本的图像上选择一个局部让它经过一些处理在另外一个IMAGE里显示出来,只不过中间就有一个鼠标选择局部区域的问题:)
AlarmRecBox。OnMouseMove := SampleMouseMove;AlarmRecBox。left
AlarmRecBox.top
AlarmRecBox.bottom
四点坐标阿