English 中文(简体)
缩略语 Grid - OnMouseUp不叫!
原标题:TStringGrid - OnMouseUp is not called!
  • 时间:2010-07-19 22:28:45
  •  标签:
  • delphi

I have a weird behavior with TStringGrid in Delphi 7. Delphi does not call the OnMouseUp event if a pop-up menu is associated to the grid. Basically, when the RMB is pressed, the pop of the menu somehow cancels/delays the OnMouseUp. Actually, to be 100% accurate, next time you push a mouse button the OnMouseUp is called twice – once for the current event, and once for the lost/delayed event.

这将使方案的整个逻辑变得模糊,因为今后当用户发布一个 mo子时,便会把不想要的代码称为。

最佳回答

我已经采取与Sertac所描述的方法类似的做法: 我再不使用PopupMenu财产来分配一个人口菜单。 相反,在我的电网内(米电网是一个从TStringGrid衍生的经过重大修改的电网)。 我处理 down倒性事件,并展示我所希望的外加处理方式,以及我所希望的外加处理方式。

问题回答

环形镜的自动收集是对烟雾正确点击的反应。 同一点还击了OnMouseUp活动。 武革阵的研制者可以选择在登峰之前或之后发射“OnMouseUp”事件。 很显然,后者实际上就是,当人口关闭时,即会发生这种事件(无论是通过摩擦还是由诸如Esc等关键板发射)。

活动没有翻一番,当你敦促左顿关闭人口时,你又通过释放左顿再次开枪。


有几种选择。 一种做法是产生新的类别,超越<代码>MouseDown方法,以发射你自己的活动。 例如:

type
  TMyStringGrid = class(TStringGrid)
  private
    FOnRButtonUp: TMouseEvent;
  protected
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
      X, Y: Integer); override;
  published
    property OnRButtonUp: TMouseEvent read FOnRButtonUp write FOnRButtonUp;
  end;
[...]

procedure TStringGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
  Y: Integer);
begin
  if (Button = mbRight) and Assigned(FOnRButtonUp) then
    FOnRButtonUp(Self, Button, Shift, X, Y);
  inherited;
end;

www.un.org/Depts/DGACM/index_french.htm 这样做的方法要么是按上列,要么取代电网的<条码>。 here>。


另一种选择是,单单单靠 mo,在登革热的<密码>上处理。 这一事件是在人群出现之前发射的。 您可使用<代码>Mouse.CursorPos。


Still, 另一种选择是,在>上,以及在<关于Mouse的活动(或者在<关于ContextMenu/code>的<编码>上做得更好)中,首先进行一些处理,然后显示人口。 例如:

procedure TForm1.StringGrid1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  Pt: TPoint;
begin
  // Do processing

  if Button = mbRight then begin
    Pt := (Sender as TStringGrid).ClientToScreen(Point(X, Y));
    PopupMenu1.Popup(Pt.X, Pt.Y);
  end;
end;




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签