2

我有这段代码可以在我拖动时移动我的主窗口MyThingThatDragsIt

procedure TMainForm.ApplicationMessage(var Msg: TMsg; var Handled: Boolean);
var
  ScreenPt : TPoint;
  DragControl : TControl;

begin
  inherited;
  if Msg.message = WM_LBUTTONDOWN then
  begin

    ScreenPt := ScreenToClient(Msg.pt);
    DragControl := FindDragTarget(Msg.pt , false);
    if Assigned(DragControl) and
      ((DragControl = MyThingThatDragsIt)
      ) then
    begin
      ReleaseCapture;
      self.Perform(WM_SYSCOMMAND, SC_MOVE or $0002, 0 );
    end;
  end
end;

这工作正常,但是当我放手时,我的程序失去了焦点,我必须在表单上单击一次才能单击任何其他按钮。

知道这里有什么问题吗?我按照这个问题的步骤

4

1 回答 1

4

告诉 VCL 你已经处理了这个消息:

  ...
  Perform(WM_SYSCOMMAND, SC_MOVE or $0002, 0 );
  Handled := True;
  ...
于 2013-04-04T21:37:41.293 回答