類似網(wǎng)絡(luò)螞蟻的懸浮窗體

字號(hào):

源碼:
    protected:
     virtual void __fastcall CreateParams(TCreateParams & Param);
    void __fastcall TForm2::CreateParams(TCreateParams & Param)
    {
       //調(diào)用基類
       TForm::CreateParams(Param);
       //去掉窗口標(biāo)題區(qū)
       Param.Style=Param.Style & ~WS_CAPTION;
       Param.Style=Param.Style | WS_POPUP;
       //設(shè)為總在最上面
       Param.ExStyle=Param.ExStyle | WS_EX_MOST;
       //設(shè)Windows Owner為Desktop Window
       Param.WndParent=GetDesktopWindow();
    }
    注意:
    1、Windows Owner與Windows Parent不同,用::SetParent函數(shù)和設(shè)置Form?->Parent這能設(shè)置Windows Parent,不能設(shè)置Windows Owner,要實(shí)現(xiàn)FlashGet的懸浮窗必須要設(shè)置Windows Owner。
    2、Form的BorderStyle要設(shè)為bsToolWindow,不然在任務(wù)欄上會(huì)顯示出這個(gè)窗口的標(biāo)題,將Caption設(shè)為空也沒有用。