Delphi窗口在自定义拖动后失去焦点 [英] Delphi window losing focus after custom drag

查看:223
本文介绍了Delphi窗口在自定义拖动后失去焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码移动我的主窗口,当我拖动 MyThingThatDragsIt

I've got this code that moves my Main Window around when I drag around 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;

这样可以,但是当我放开时,我的程序已经失去了重点,在表单上点击一次,只需点击任何其他按钮。

That works OK, but when I let go, my program has lost it's focus and I've got to click once on the form just to click on any other buttons.

任何想法这里有什么问题?我遵循此问题的步骤

Any idea what is wrong here? I followed steps from this question

推荐答案

告诉VCL你已经处理的消息:

Tell the VCL that you've taken care of the message:

  ...
  Perform(WM_SYSCOMMAND, SC_MOVE or $0002, 0 );
  Handled := True;
  ...

这篇关于Delphi窗口在自定义拖动后失去焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆