2011-02-09 161 views
6

開始時,這是我使用的代碼:應用留守任務欄在全屏

BorderStyle := bsNone; 
WindowState := wsMaximized; 

我的問題是,應用程序將不包括任務欄,而是去後面。

在運行時切換到全屏時它工作正常,但在系統啓動時啓動應用程序時無法正常工作。

UPDATE

事實證明,這兩條線工作得很好。他們在FormShow事件處理程序中。如果我斷點直到FormShow結束,應用程序似乎處於全屏狀態;我可以通過任務欄看到應用程序。但在FormShow之後,應用程序的Top屬性發生了某種變化。我不會在代碼中更改它 - 值爲-20,所以應用程序不再是最大化的。

有沒有一種方法來跟蹤它改變的地點或時間?

在此先感謝!

UPDATE

這個帖子被標記。請不要發佈任何答案!謝謝。

+1

?在什麼事件處理程序? – jpfollenius 2011-02-09 07:09:41

+0

這就是「工作區」的意思,主顯示器上桌面應用程序工具欄上的區域(任務欄爲1)。 – 2011-02-09 09:24:23

回答

1

嘗試:

Form.Left := 0; // set the x 
Form.Top := 0; // set the y 
Form.Width := Screen.Width; // width of the form 
Form.Height := Screen.Height; // height of the form 
// and 
Form.FormStyle := fsStayOnTop; // taskbar is always on top as well, setting the Style property to always on top will allow the form to cover the taskbar 

,如果你想隱藏標題然後設置邊框到bsnone

2

變化帕拉姆風格,根據這個MSDN博客: http://blogs.msdn.com/b/oldnewthing/archive/2005/05/05/414910.aspx

procedure TForm1.CreateParams(var Params: TCreateParams); 
begin 
    inherited; 
    Params.Style := WS_POPUP or WS_VISIBLE; //will overlay taskbar 
end; 

procedure TForm1.FormCreate(Sender: TObject); 
begin 
    Self.WindowState := wsMaximized; //fullscreen 
end; 

====================================

全部代碼從窗切換到全屏模式和背面(Win7上64位測試,航空)
(編輯:在Windows XP(VMware的)太作品)在哪裏使用這個代碼

var 
    _OrgWindowedStyle: DWORD; 

procedure TForm6.btnWindowedClick(Sender: TObject); 
begin 
    Self.WindowState := wsNormal; 
    //set original style 
    SetWindowLong(Application.Handle, GWL_STYLE, 
       _OrgWindowedStyle); 
    //re-create window, to use changed style 
    RecreateWnd; 
end; 

procedure TForm6.btnFullScreenClick(Sender: TObject); 
begin 
    _OrgWindowedStyle := 0; //clear: re-applies fullscreen mode in CreateParams 
    Self.WindowState := wsMaximized; 
    //re-create window, to use changed style 
    RecreateWnd; 
end; 

procedure TForm6.CreateParams(var Params: TCreateParams); 
begin 
    inherited; 

    //first time? default fullscreen 
    if _OrgWindowedStyle = 0 then 
    begin 
    _OrgWindowedStyle := Params.Style; 
    Params.Style := //WS_POPUP or    //not needed? 
        WS_VISIBLE 
        or WS_BORDER or WS_CAPTION //comment this line to remove border + titlebar 
    end; 
end; 

procedure TForm6.FormCreate(Sender: TObject); 
begin 
    Self.WindowState := wsMaximized;  //default fullscreen 
end;