2010-08-25 50 views
0

我需要知道(移動)窗體是否懸停在組件上(可能是沒有鼠標的MouseEnter和MouseLeave)。如何知道表單是否在組件上懸停?

我有這個想法獲得組件的左,頂部,高度,寬度和計算(移動)窗體的位置是否在窗體的位置。 (我不完全確定我能做到這一點)

有關實施我的想法的任何建議嗎?有沒有其他辦法可以做到這一點?

+1

你*假設*的「顯示窗口內容的同時拖動」選項設置? – 2010-08-25 07:05:19

+0

@Rob:對不起,我不知道那是什麼。 (我嘗試了谷歌搜索這個,但結果是各種「顯示窗口」的問題) – Dian 2010-08-25 07:22:45

+0

把引號放在它周圍並再次搜索。或者瀏覽「顯示屬性」控制面板(在「效果」下)。 – 2010-08-25 07:25:29

回答

5

嘗試這樣:

var 
    P: TPoint; 
    R1, R2, I: TRect; 
begin 
    P := TheComponent.ClientOrigin; 
    R1 := TheComponent.ClientRect; 
    Windows.OffsetRect(R1, P.X, P.Y); 
    P := TheForm.ClientOrigin; 
    R2 := TheForm.ClientRect; 
    Windows.OffsetRect(R2, P.X, P.Y); 
    if Windows.IntersectRect(I, R1, R2) then 
    // the Form is over the component 
    else 
    // the Form is not over the component 
end; 
+0

Oooh。謝謝!我很感激。 – Dian 2010-08-25 07:19:37