procedure CursorControl(Control: TControl; Shift: TShiftState; X, Y,
Prec: integer); begin //光标在控件的最左侧 if (X<=Prec) and
(Y>Prec) and (Y<Control.Height-Prec) then Control.Cursor :=
crSizeWE // 光标在控件的最右侧 else if (X>=Control.Width-Prec) and
(Y>Prec) and (Y<Control.Height-Prec) then Control.Cursor :=
crSizeWE // 光标在控件的最上侧 else if (X>Prec) and
(X<Control.Width-Prec) and (Y<=Prec) then Control.Cursor :=
crSizeNS // 光标在控件的左上角 else if (X<=Prec) and (Y<=Prec)
then Control.Cursor := crSizeNWSE // 光标在控件的右上角 else if
(X>=Control.Width-Prec) and (Y<=Prec) then Control.Cursor :=
crSizeNESW // 光标在控件的最下侧 else if (X>Prec) and
(X<Control.Width-Prec) and (Y>=Control.Height-Prec) then
Control.Cursor := crSizeNS // 光标在控件的左下角 else if (X<=Prec)
and (Y>=Control.Height-Prec) then Control.Cursor := crSizeNESW //
光标在控件的右下角 else if (X>=Control.Width-Prec) and
(Y>=Control.Height-Prec) then Control.Cursor :=
crSizeNWSE // 光标在控件的客户区(移动整个控件) else if (X>5) and (Y>5)
and (X<Control.Width-5) and (Y<Control.Height-5) then Control.Cursor
:= crSizeAll else Control.Cursor :=
crDefault;//恢复默认光标 end; 2、修改窗体控件的大小和位置。其实有一种最简便的方法那就是向控件发送相应的消息即可。我也已将它封装成一个函数,在控件的OnMouseDown事件中调用即可。函数如下:
procedure ManipulateControl(Control: TControl; Shift: TShiftState; X,
Y, Prec: integer); var SC_MANIPULATE:
Word;//保存对应消息值 begin // 光标在控件的最左侧 if (X<=Prec) and
(Y>Prec) and (Y<Control.Height-Prec) then SC_MANIPULATE :=
$F001 // 光标在控件的最右侧 else if (X>=Control.Width-Prec) and
(Y>Prec) and (Y<Control.Height-Prec) then SC_MANIPULATE :=
$F002 // 光标在控件的最上侧 else if (X>Prec) and
(X<Control.Width-Prec) and (Y<=Prec) then begin SC_MANIPULATE
:= $F003 // 光标在控件的左上角 else if (X<=Prec) and (Y<=Prec)
then SC_MANIPULATE := $F004 // 光标在控件的右上角 else if
(X>=Control.Width-Prec) and (Y<=Prec) then SC_MANIPULATE :=
$F005 // 光标在控件的最下侧 else if (X>Prec) and
(X<Control.Width-Prec) and (Y>=Control.Height-Prec) then
SC_MANIPULATE := $F006 // 光标在控件的左下角 else if (X<=Prec) and
(Y>=Control.Height-Prec) then SC_MANIPULATE := $F007 // 光标在控件的右下角
else if (X>=Control.Width-Prec) and (Y>=Control.Height-Prec)
then SC_MANIPULATE := $F008 // 光标在控件的客户区 ( 移动整个控件 ) else if
(X>5) and (Y>5) and (X<Control.Width-5) and
(Y<Control.Height-5) then SC_MANIPULATE := $F009 else
SC_MANIPULATE := $F000; if Shift=[ssLeft]
then begin ReleaseCapture; Control.Perform(WM_SYSCOMMAND,
SC_MANIPULATE,
0);//向控件发送改变光标消息 end; end; 3、保存和恢复窗体控件的大小及位置。通过对窗体的Component元件进行遍历,然后将它们的位置及大小属性值写入INI文件中,窗体下次启动时再通过读取INI文件恢复窗体控件的这些属性即可。关于这个解决办法网上有很多,还有现成的控件不用写一行代码就可实现的,限于篇幅在此我就不再累述了。有兴趣的朋友不防一试。所有代码在WIN2000/DELPHI7下测试通过。
没有相关教程