当我拖动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;
这样可行,但是当我放手时,我的程序已经失去了它的焦点,我必须在表单上单击一次才能点击任何其他按钮。
知道这里有什么问题吗?我跟着steps from this question
答案 0 :(得分:4)
告诉VCL您已经处理了这条消息:
...
Perform(WM_SYSCOMMAND, SC_MOVE or $0002, 0 );
Handled := True;
...