2013-04-04 123 views
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; 

這一工程確定,但是當我放手,我的計劃已經失去了它的焦點移到我的主窗口我只需點擊表格上的一次即可點擊任何其他按鈕。

任何想法這裏有什麼問題嗎?我跟着steps from this question

+0

難道不是一個簡單的SetFocus的調用後執行這樣的伎倆? – 2013-04-04 21:42:05

+0

@UweRaabe是我徒勞地嘗試的前40個VCL命令之一:) – 2013-04-04 21:52:41

回答

4

告訴你已經採取了消息的照顧VCL:

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