应用程序在全屏启动时停留在任务栏后面! [英] App staying behind taskbar when starting in fullscreen!
问题描述
BorderStyle:= bsNone;
WindowState:= wsMaximized;
我的问题是应用程序不会覆盖任务栏,而是落在后面。
在运行时切换全屏时,它工作正常,但在启动时启动应用程序时不起作用。
更新
事实证明,这两行工作得很好。他们在FormShow事件处理程序。如果我断点,直到FormShow结束,那么应用程序似乎是全屏的。我可以通过任务栏看到应用程序。但是,在FormShow应用程序的顶级属性被改变之后(我不改变代码,值为-20,所以应用程序不会被最大化)。有没有办法跟踪哪里或何时改变?
提前感谢!
更新
此帖被标记。请不要发布任何答案!谢谢
根据这个MSDN博客,更改参数样式:
http://blogs.msdn.com/b/oldnewthing/archive/2005/05/05 /414910.aspx
procedure TForm1.CreateParams(var Params:TCreateParams);
开始
继承;
Params.Style:= WS_POPUP或WS_VISIBLE; //将覆盖任务栏
end;
procedure TForm1.FormCreate(Sender:TObject);
begin
Self.WindowState:= wsMaximized; // fullscreen
end;
=================== ===============
从Windowed切换到全屏模式并返回(Win7 64bit,Aero测试)的完整代码
(编辑:在Windows XP(vmware)中工作)
var
_OrgWindowedStyle:DWORD ;
程序TForm6.btnWindowedClick(发件人:TObject);
begin
Self.WindowState:= wsNormal;
//设置原始样式
SetWindowLong(Application.Handle,GWL_STYLE,
_OrgWindowedStyle);
//重新创建窗口,使用改变的样式
RecreateWnd;
结束
程序TForm6.btnFullScreenClick(发件人:TObject);
begin
_OrgWindowedStyle:= 0; // clear:在CreateParams中重新应用全屏模式
Self.WindowState:= wsMaximized;
//重新创建窗口,使用改变的样式
RecreateWnd;
结束
程序TForm6.CreateParams(var Params:TCreateParams);
开始
继承;
//第一次?默认全屏
如果_OrgWindowedStyle = 0然后
begin
_OrgWindowedStyle:= Params.Style;
Params.Style:= // WS_POPUP或//不需要?
WS_VISIBLE
或WS_BORDER或WS_CAPTION //注释此行以删除border + titlebar
end;
结束
procedure TForm6.FormCreate(Sender:TObject);
begin
Self.WindowState:= wsMaximized; //默认全屏
end;
Hey, this is the code i'm using
BorderStyle := bsNone;
WindowState := wsMaximized;
My problem is that the application won't cover taskbar, but goes behind it.
It works fine when switching fullscreen at runtime, but it wont work when starting the app at startup.
UPDATE
It turns out that those two lines work very well. They are in FormShow event handler. If i break point til the end of FormShow, then the application seems to be in fullscreen. i can see application trough the taskbar. But after FormShow application's top property gets changed somehow (i don't change it in code. The value is -20, so application is not maximized anymore). Is there a way to track where or when it is changed?
Thanks in advance!
UPDATE
This post is flagged. Please to not post any answers! Thank you
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;
====================================
Full code to switch from Windowed to fullscreen mode and back (tested on Win7 64bit, Aero)
(Edit: 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屋!