stringgrid我在属性里关联了一个popmenu,要求是:当鼠标在cell范围里右键,才出现弹出菜单,在cell范围之外(stringgrid范围中)右键,不出现

解决方案 »

  1.   

    楼主是不是指鼠标点在fixed范围内,则不出现右键菜单么?
      

  2.   

    fixed范围内也算(其他fixed我隐掉了),表格之外,但在stringgrid中也是的
      

  3.   

    放一个 TApplicationEvents,使用他的 OnMessageprocedure TForm3.ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
    var
      Cell: TGridCoord;
      MousePos: TPoint;
    begin
      if (Msg.hwnd = sg1.Handle) and (Msg.message = WM_RBUTTONUP) then
      begin
        MousePos.X := Msg.lParam and $0000FFFF;
        MousePos.Y := Msg.lParam and $FFFF0000 shr 16;
        Cell := sg1.MouseCoord(MousePos.X, MousePos.Y);
        if (Cell.X <> -1) and (Cell.Y <> -1) then
        begin
          GetCursorPos(MousePos);
          pm1.Popup(MousePos.X, MousePos.Y);
        end;
      end;
    end;