改变位置:
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
Panel1.perform(WM_SysCommand,$F012,0);
end;
给分.改变大小呢,你可以MouseMove中的X,Y参数,想应的Panel1.Width+-*/X-原先的x; Panel1.Height+-*/Y.
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
Panel1.perform(WM_SysCommand,$F012,0);
end;
给分.改变大小呢,你可以MouseMove中的X,Y参数,想应的Panel1.Width+-*/X-原先的x; Panel1.Height+-*/Y.
解决方案 »
- 没分了,在问个问题,如何写这样的查询?
- 关于stringgrid改变列宽的问题
- 真奇怪,ADOQuery1.Sort中的ASC和DESC要大写
- 请教:殊条件下的窗体透明
- 用qreport怎样打印stringgrid生成的临时表啊????[悬赏100分]
- 取得外部程序中控件的句柄
- 关于报表预栏的问题..
- 在ADO的TAdoQuery中过滤Filter中如何使用通配符?
- 如何给acrobat 制作插件?象金山词霸那样的。
- (WIN2000)隐藏进程?(按CTRL+ALT+DEL应用程序不显示在进程中)?(50)内空
- 我的程序只有一个窗口,我在设计时将其visible属性设为false,但在应用自动创建窗体时又将其设为true,这样,窗体还是可见的。问题是:能不能在窗体显示之前,将其设为不可见的?
- copy函数引用效率很差劲,而且引用多了,容易出现问题?谁有好的方法替代它!
Panel1.perform(WM_SysCommand,$F002,0);
Panel1.perform(WM_SysCommand,$F003,0);
Panel1.perform(WM_SysCommand,$F004,0);
Panel1.perform(WM_SysCommand,$F005,0);
Panel1.perform(WM_SysCommand,$F006,0);
Panel1.perform(WM_SysCommand,$F007,0);
Panel1.perform(WM_SysCommand,$F008,0);
分别对应改变大小的8个方向,你可以编程判断x,y的位置(取Panel的8个控制点,上下左右....),然后根据不同的控制点改变不同的光标,在执行不同的perform。
嘻嘻成功了,一个完整的移动并改变大小的代码。
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
Panel1: TPanel;
procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
if (x>=0)and(x<=3) then
begin
if (y>=0)and(y<=3) then Panel1.perform(WM_SysCommand,$F004,0);
if (y>3)and(y<Panel1.Height-3) then Panel1.perform(WM_SysCommand,$F001,0);
if (y>=Panel1.Height-3)and(y<=Panel1.Height) then Panel1.perform(WM_SysCommand,$F007,0);
end
else if (x>3)and(x<Panel1.Width-3) then
begin
if (y>=0)and(y<=3) then Panel1.perform(WM_SysCommand,$F003,0);
if (y>3)and(y<Panel1.Height-3) then Panel1.perform(WM_SysCommand,$F012,0);
if (y>=Panel1.Height-3)and(y<=Panel1.Width) then Panel1.perform(WM_SysCommand,$F006,0);
end
else if (x>=Panel1.Width-3)and(x<=Panel1.Width) then
begin
if (y>=0)and(y<=3) then Panel1.perform(WM_SysCommand,$F005,0);
if (y>3)and(y<Panel1.Height-3) then Panel1.perform(WM_SysCommand,$F002,0);
if (y>=Panel1.Height-3)and(y<=Panel1.Width) then Panel1.perform(WM_SysCommand,$F008,0);
end;
end;procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if (x>=0)and(x<=3) then
begin
if (y>=0)and(y<=3) then Panel1.Cursor:=crSizeNWSE;
if (y>3)and(y<Panel1.Height-3) then Panel1.Cursor:=crSizeWE;
if (y>=Panel1.Height-3)and(y<=Panel1.Height) then Panel1.Cursor:=crSizeNESW;
end
else if (x>3)and(x<Panel1.Width-3) then
begin
if (y>=0)and(y<=3) then Panel1.Cursor:=crSizeNS;
if (y>3)and(y<Panel1.Height-3) then Panel1.Cursor:=crArrow;
if (y>=Panel1.Height-3)and(y<=Panel1.Width) then Panel1.Cursor:=crSizeNS;
end
else if (x>=Panel1.Width-3)and(x<=Panel1.Width) then
begin
if (y>=0)and(y<=3) then Panel1.Cursor:=crSizeNESW;
if (y>3)and(y<Panel1.Height-3) then Panel1.Cursor:=crSizeWE;
if (y>=Panel1.Height-3)and(y<=Panel1.Width) then Panel1.Cursor:=crSizeNWSE;
end;
end;end.
在窗口里只加了一个Panel1,你运行运行吧
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;type
TForm1 = class(TForm)
Image1: TImage;
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
x0,y0:integer;
down,resized:Boolean;implementation{$R *.DFM}procedure Tform1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
x0:=x;
y0:=y;
if (x>Image1.Width-10)or(y>image1.Height-10) then begin
Image1.Cursor:=crSize;
resized:=true;
end else begin
Image1.Cursor:=crDefault;
down:=TRUE;
end;
end;procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if x>Image1.Width-10 then begin
Image1.Cursor:=crSize;
end else begin
Image1.Cursor:=crDefault;
end;
if down then begin
Image1.Left:=Image1.Left+x-x0;
Image1.top:=Image1.top+y-y0;
end;
if resized then begin
Image1.Width:=Image1.Width+x-x0;
Image1.Height:=Image1.Height+y-y0;
x0:=x;y0:=y;
end;
end;procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
down:=False;
resized:=False;
end;
end.