写了一个自定义函数功能为程序运行时用鼠标移动控件的如下所是
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擦除经过后从绘太耗资源。有没有别的画线函数解决问题。谢谢

解决方案 »

  1.   

    1) 在onMouseMove事件中调用ManipulateControl
    2)在StrigGrid的ondraw事件(我记不清了,总之是刷新事件)中,
    加入你的处理
      

  2.   

    tccb不好意思我去吃饭了,你误解我了。情况如下:
      StringGrid:=TStringGrid.Create(self);
      StringGrid.Parent:=Form1;
      StringGrid.onMouseMove:=ManipulateControl;或  StringGrid.onMouseMove:=ManipulateControl(self; Shift1; X, Y);
    都编译不过。出错就在StringGrid.onMouseMove:=...上。
    而画线时Form1是图形载体不是StrigGrid,stringGrid和line同在Form1上。
      

  3.   

    procedure ManipulateControl(Control: TControl; Shift: TShiftState;
      X, Y, Precision: integer);
    ManipulateControl中的参数要和标准的OnMouseMove一致
    参数命名可以不一样,但是个数和类型要一致
      

  4.   

    好像有一种pen样式在同一个地方划一次能看到,再划一次就消失了,是不是要你要的效果
      

  5.   

    您说的是异或笔我现在不需要修改,是要保持住form1上的line而不是象现在被stringgrid碰上就化了没有了(人间蒸发)。