全屏启动时,应用程序停留在任务栏后面 [英] App staying behind taskbar when starting in fullscreen

查看:88
本文介绍了全屏启动时,应用程序停留在任务栏后面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我正在使用的代码:

This is the code I'm using:

BorderStyle := bsNone;
WindowState := wsMaximized;

我的问题是应用程序无法覆盖任务栏,但会覆盖任务栏。

My problem is that the application won't cover the taskbar, but go behind it.

在运行时切换到全屏模式时效果很好,但是在系统启动时启动应用程序时则无效。

It works fine when switching to fullscreen at runtime, but it doesn't work when starting the app at system startup.

更新

事实证明,这两行效果很好。它们在FormShow事件处理程序中。如果我断点直到FormShow结束,则该应用程序似乎处于全屏状态;我可以通过任务栏看到该应用程序。但是在FormShow之后,应用程序的Top属性得到了某种改变。我不会在代码中更改它-值是-20,因此该应用程序不再最大化。

It turns out that those two lines work very well. They are in the FormShow event handler. If I break point until the end of FormShow, the application seems to be in fullscreen; I can see the application trough the taskbar. But after FormShow the application's Top property gets changed somehow. I don't change it in code - the value is -20, so the application is not maximized anymore.

是否可以跟踪更改的位置或时间?

Is there a way to track where or when it is changed?

谢谢!

更新

该帖子已被标记。请不要发表任何答案!谢谢。

This post is flagged. Please do not post any answers! Thank you.

推荐答案

根据此MSDN博客更改参数样式:
http://blogs.msdn.com/b/oldnewthing/archive/2005/05/ 05 / 414910.aspx

Change the param style, according to this MSDN blog: 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;

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

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

完整代码从Windowed模式切换到全屏模式并返回(在Win7 64bit,Aero上测试) b $ b
(编辑:也可在Windows XP(vmware)中使用)

Full code to switch from Windowed to fullscreen mode and back (tested on Win7 64bit, Aero)
( works in Windows XP (vmware) too)

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;

这篇关于全屏启动时,应用程序停留在任务栏后面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆