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;

それは問題なく動作しますが、手を離すとプログラムがフォーカスを失い、他のボタンをクリックするためにフォームを 1 回クリックする必要があります。

ここで何が間違っているのですか?この質問の手順に従いました

4

1 に答える 1

4

メッセージを処理したことを VCL に伝えます。

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