写了一个自定义函数功能为程序运行时用鼠标移动控件的如下所是
procedure ManipulateControl(Control: TControl; Shift: TShiftState;
X, Y, Precision: integer);
begin
//光标在控件的客户区(移动整个控件)******************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (X>5) and (Y>5) and (X<Control.Width-5) and (Y<Control.Height-5)
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;
1)小弟在程序运行时动态生成数十个StringGrid控件要模仿Visio用于工作流定义请问ManipulateControl函数怎样和StringGrid的onMouseMove事件绑定。2)小弟用canvas.moveto和canvas.Lineto画在StringGrid间的连线被拖动时经过的StrigGrid擦除经过后从绘太耗资源。有没有别的画线函数解决问题。谢谢
procedure ManipulateControl(Control: TControl; Shift: TShiftState;
X, Y, Precision: integer);
begin
//光标在控件的客户区(移动整个控件)******************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (X>5) and (Y>5) and (X<Control.Width-5) and (Y<Control.Height-5)
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;
1)小弟在程序运行时动态生成数十个StringGrid控件要模仿Visio用于工作流定义请问ManipulateControl函数怎样和StringGrid的onMouseMove事件绑定。2)小弟用canvas.moveto和canvas.Lineto画在StringGrid间的连线被拖动时经过的StrigGrid擦除经过后从绘太耗资源。有没有别的画线函数解决问题。谢谢
2)在StrigGrid的ondraw事件(我记不清了,总之是刷新事件)中,
加入你的处理
StringGrid:=TStringGrid.Create(self);
StringGrid.Parent:=Form1;
StringGrid.onMouseMove:=ManipulateControl;或 StringGrid.onMouseMove:=ManipulateControl(self; Shift1; X, Y);
都编译不过。出错就在StringGrid.onMouseMove:=...上。
而画线时Form1是图形载体不是StrigGrid,stringGrid和line同在Form1上。
X, Y, Precision: integer);
ManipulateControl中的参数要和标准的OnMouseMove一致
参数命名可以不一样,但是个数和类型要一致