如何设置任务拦的总在最前和自动隐藏属性(100分)

  • 主题发起人 主题发起人 onedot
  • 开始时间 开始时间
O

onedot

Unregistered / Unconfirmed
GUEST, unregistred user!
查MSDN很旧,就是没查到。唯一有点关系的好象我测试也不行。<br>只好求助大家了
 
用findwindows<br>setwindows
 
禁止/隐藏整条任务栏<br>procedure TForm1.Button1Click(Sender: TObject);<br>Var Wnd: THandle;<br>begin<br>&nbsp; Wnd := FindWindow('Shell_TrayWnd', nil);<br>&nbsp; //用下面这一句实现隐藏<br>&nbsp; if Wnd &lt;&gt; 0 then ShowWindow(Wnd, SW_HIDE);<br>&nbsp; //用下面这一句实现禁止<br>&nbsp; if Wnd &lt;&gt; 0 then EnableWindow(Wnd, False);<br>end;<br>恢复正常必须用ShowWindow(Wnd, SW_SHOW)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 和EnableWindow(Wnd, True)。<br>
 
谢谢,这个我很早就知道。但不是我说的<br>因为这种当窗口最大化时,它边界不到屏幕最下方,而是有个任务栏的空间<br>所以我说要总在最前和自动隐藏属性 ----》等价于设置--任务拦和开始彩旦---总在罪前。。。
 
事实上我就不清楚它的最前和自动隐藏到底算FindWindow('Shell_TrayWnd', nil)后<br>窗口的哪个属性,反正我看了SETWINDOW,里面的属性要不不是,要么好象是它的,但测试不行<br>
 
你看一下SystemParametersInfo这个函数,仔细看一下,应该在这里面
 
Desktop parameter,我都测试了,没有效果,我晕<br>当然一点很重要,我E文太拦,所以很多时候也许错过必要提示
 
在工具栏的属性里不是有'自动隐藏'和'总在最前'吗.
 
weekboy:晕,我意思就是怎么用API实现和你用工具栏属性的目的
 
你干什么要对任务栏操作啊,你只要让你的程序always on top不就行了吗?
 
function IsTaskbarAutoHideOn : Boolean;<br>var <br>&nbsp; ABData : TAppBarData; <br>begin <br>&nbsp; ABData.cbSize := SizeOf (ABData); <br>&nbsp; result := (SHAppBarMessage (ABM_GETSTATE, ABData) and ABS_AUTOHIDE) &gt; 0 <br>end; <br><br>做程序好象只能判断任务栏是否自动隐藏,无法设置其自动隐藏状态。至少我没有作到,希望高手可以作到
 
应该可以通过注册表实现,但不知其键值何处
 
不过你的程序完全有另一种解决方法。<br><br>function SetFullscreenMode(ModeIndex: Integer) : Boolean; <br>// changes to the video mode given by 'ModeIndex' <br>var DeviceMode : TDevMode; <br>begin <br>&nbsp; with DeviceMode do <br>&nbsp; begin <br>&nbsp; &nbsp; dmSize:=SizeOf(DeviceMode); <br>&nbsp; &nbsp; dmBitsPerPel:=VideoModes[ModeIndex].ColorDepth; <br>&nbsp; &nbsp; dmPelsWidth:=VideoModes[ModeIndex].Width; <br>&nbsp; &nbsp; dmPelsHeight:=VideoModes[ModeIndex].Height; <br>&nbsp; &nbsp; dmFields:=DM_BITSPERPEL or DM_PELSWIDTH or DM_PELSHEIGHT; <br>&nbsp; &nbsp; // if mode set failed, we'll just run in windowed mode <br>&nbsp; &nbsp; Result:=ChangeDisplaySettings(DeviceMode,CDS_FULLSCREEN) = <br>DISP_CHANGE_SUCCESSFUL; <br>&nbsp; &nbsp; if Result then ScreenModeChanged:=True; <br>&nbsp; &nbsp; if ModeIndex = 0 then ScreenModeChanged:=False; <br>&nbsp; end; <br>end; <br>
 
How to run an application fullscreen?<br><br>From: "Mike Lischke" &lt;Lischke@imib.med.tu-dresden.de&gt;<br><br>Running an application full screen means that the application window covers the entire desktop area. This is often necessary because of some video cards which can only accelerate full screen apps., but you may also often want that nothing else than your program is visible to the user. BTW: Running fullscreen isn't only related to OpenGL, DirectX or 3D in general. Strictly taken would fullscreen only require that you set your window state to wsMaximize, that's all.<br><br>But there's another question implied by asking for fullscreen applications. It's the point that you either may want to let the user choose a specific color and pixel resolution or you want to run your program in a fixed resolution. The latter is in particular very important since not all video cards support all resolutions and often a game or other 3D application has to run in a different (mostly lower) resolution than the user uses for everday work.<br><br>So the complete question should read as: How to run an application fullscreen in a specific color and pixel resolution (whithout reboot)? The key point is the function ChangeDisplaySettings. Depending on the video driver you can set many video modes dynamically, without rebooting the computer:<br><br><br>--------------------------------------------------------------------------------<br><br>function SetFullscreenMode(ModeIndex: Integer) : Boolean;<br>// changes to the video mode given by 'ModeIndex'<br>var DeviceMode : TDevMode;<br>begin<br>&nbsp; with DeviceMode do<br>&nbsp; begin<br>&nbsp; &nbsp; dmSize:=SizeOf(DeviceMode);<br>&nbsp; &nbsp; dmBitsPerPel:=VideoModes[ModeIndex].ColorDepth;<br>&nbsp; &nbsp; dmPelsWidth:=VideoModes[ModeIndex].Width;<br>&nbsp; &nbsp; dmPelsHeight:=VideoModes[ModeIndex].Height;<br>&nbsp; &nbsp; dmFields:=DM_BITSPERPEL or DM_PELSWIDTH or DM_PELSHEIGHT;<br>&nbsp; &nbsp; // if mode set failed, we'll just run in windowed mode<br>&nbsp; &nbsp; Result:=ChangeDisplaySettings(DeviceMode,CDS_FULLSCREEN) = DISP_CHANGE_SUCCESSFUL;<br>&nbsp; &nbsp; if Result then ScreenModeChanged:=True;<br>&nbsp; &nbsp; if ModeIndex = 0 then ScreenModeChanged:=False;<br>&nbsp; end;<br>end;<br><br><br>--------------------------------------------------------------------------------<br><br>As you may have noticed there's a global variable VideoModes in this example. The reason is that you should enumerate all available video modes which can be set dynamically and store them into a structur like VideoModes, to ensure only these are tried to be set:<br><br><br>--------------------------------------------------------------------------------<br><br>const MaxVideoModes = 200; // this isn't very much actually<br>type TVideoMode = record<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Width,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Height,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ColorDepth &nbsp;: Word;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Description : String[20];<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>var VideoModes &nbsp; &nbsp; &nbsp; &nbsp;: array[0..MaxVideoModes] of TVideoMode;<br>&nbsp; &nbsp; NumberVideomodes &nbsp;: Integer = 1; // 1 because we have a default mode<br><br><br>--------------------------------------------------------------------------------<br><br>This makes our example much larger as you will see, but you'll get a very useful functionality by implementing it. If you still want you can replace VideoModes in the above function by fixed values (say 640, 480, 16). Enumerating all video modes is done by EnumDisplaySettings:<br><br><br>--------------------------------------------------------------------------------<br><br>procedure ReadVideoModes;<br>var I, ModeNumber : Integer;<br>&nbsp; &nbsp; done &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: Boolean;<br>&nbsp; &nbsp; DeviceMode &nbsp; &nbsp;: TDevMode;<br>&nbsp; &nbsp; DeskDC &nbsp; &nbsp; &nbsp; &nbsp;: HDC;<br><br>begin<br>&nbsp; // prepare 'default' entry<br>&nbsp; with VideoModes[0] do<br>&nbsp; try<br>&nbsp; &nbsp; DeskDC:=GetDC(0);<br>&nbsp; &nbsp; ColorDepth:=GetDeviceCaps(DeskDC,BITSPIXEL);<br>&nbsp; &nbsp; Width:=Screen.Width;<br>&nbsp; &nbsp; Height:=Screen.Height;<br>&nbsp; &nbsp; Description:='default';<br>&nbsp; finally<br>&nbsp; &nbsp; ReleaseDC(0,DeskDC);<br>&nbsp; end;<br><br>&nbsp; // enumerate all available video modes<br>&nbsp; ModeNumber:=0;<br>&nbsp; done:=False;<br>&nbsp; repeat<br>&nbsp; &nbsp; done:=not EnumDisplaySettings(nil,ModeNumber,DeviceMode);<br>&nbsp; &nbsp; TryToAddToList(DeviceMode);<br>&nbsp; &nbsp; Inc(ModeNumber);<br>&nbsp; until (done or (NumberVideomodes &gt;= MaxVideoModes));<br><br>&nbsp; // low-res modes don't always enumerate, ask about them explicitly<br>&nbsp; with DeviceMode do<br>&nbsp; begin<br>&nbsp; &nbsp; dmBitsPerPel:=8;<br>&nbsp; &nbsp; dmPelsWidth:=42;<br>&nbsp; &nbsp; dmPelsHeight:=37;<br>&nbsp; &nbsp; dmFields:=DM_BITSPERPEL or DM_PELSWIDTH or DM_PELSHEIGHT;<br>&nbsp; &nbsp; // make sure the driver doesn't just answer yes to all tests<br>&nbsp; &nbsp; if ChangeDisplaySettings(DeviceMode,CDS_TEST or CDS_FULLSCREEN) &lt;&gt; DISP_CHANGE_SUCCESSFUL then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; I:=0;<br>&nbsp; &nbsp; &nbsp; while (I &lt; NumberLowResModes-1) and (NumberVideoModes &lt; MaxVideoModes) do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; dmSize:=Sizeof(DeviceMode);<br>&nbsp; &nbsp; &nbsp; &nbsp; dmBitsPerPel:=LowResModes.ColorDepth;<br>&nbsp; &nbsp; &nbsp; &nbsp; dmPelsWidth:=LowResModes.Width;<br>&nbsp; &nbsp; &nbsp; &nbsp; dmPelsHeight:=LowResModes.Height;<br>&nbsp; &nbsp; &nbsp; &nbsp; dmFields:=DM_BITSPERPEL or DM_PELSWIDTH or DM_PELSHEIGHT;<br>&nbsp; &nbsp; &nbsp; &nbsp; TryToAddToList(DeviceMode);<br>&nbsp; &nbsp; &nbsp; &nbsp; Inc(I);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>end;<br><br><br>--------------------------------------------------------------------------------<br><br>I think this function isn't hard to understand. There are two parts to consider. The first is the standard way to enumerate the video modes. The second ensures that also all low-res modes are tested . This requires, though, a list of low-res modes:<br><br><br>--------------------------------------------------------------------------------<br><br>type TLowResMode = record<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Width,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Height,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ColorDepth &nbsp;: Word;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br><br>const NumberLowResModes = 60;<br>&nbsp; &nbsp; &nbsp; LowResModes &nbsp; &nbsp; &nbsp; : array[0..NumberLowResModes-1] of TLowResMode =<br>&nbsp; &nbsp; &nbsp; ((Width:320;Height:200;ColorDepth:8),(Width:320;Height:200;ColorDepth:15),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:320;Height:200;ColorDepth:16),(Width:320;Height:200;ColorDepth:24),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:320;Height:200;ColorDepth:32),(Width:320;Height:240;ColorDepth: 8),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:320;Height:240;ColorDepth:15),(Width:320;Height:240;ColorDepth:16),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:320;Height:240;ColorDepth:24),(Width:320;Height:240;ColorDepth:32),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:320;Height:350;ColorDepth: 8),(Width:320;Height:350;ColorDepth:15),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:320;Height:350;ColorDepth:16),(Width:320;Height:350;ColorDepth:24),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:320;Height:350;ColorDepth:32),(Width:320;Height:400;ColorDepth: 8),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:320;Height:400;ColorDepth:15),(Width:320;Height:400;ColorDepth:16),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:320;Height:400;ColorDepth:24),(Width:320;Height:400;ColorDepth:32),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:320;Height:480;ColorDepth: 8),(Width:320;Height:480;ColorDepth:15),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:320;Height:480;ColorDepth:16),(Width:320;Height:480;ColorDepth:24),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:320;Height:480;ColorDepth:32),(Width:360;Height:200;ColorDepth: 8),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:360;Height:200;ColorDepth:15),(Width:360;Height:200;ColorDepth:16),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:360;Height:200;ColorDepth:24),(Width:360;Height:200;ColorDepth:32),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:360;Height:240;ColorDepth: 8),(Width:360;Height:240;ColorDepth:15),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:360;Height:240;ColorDepth:16),(Width:360;Height:240;ColorDepth:24),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:360;Height:240;ColorDepth:32),(Width:360;Height:350;ColorDepth: 8),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:360;Height:350;ColorDepth:15),(Width:360;Height:350;ColorDepth:16),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:360;Height:350;ColorDepth:24),(Width:360;Height:350;ColorDepth:32),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:360;Height:400;ColorDepth: 8),(Width:360;Height:400;ColorDepth:15),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:360;Height:400;ColorDepth:16),(Width:360;Height:400;ColorDepth:24),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:360;Height:400;ColorDepth:32),(Width:360;Height:480;ColorDepth: 8),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:360;Height:480;ColorDepth:15),(Width:360;Height:480;ColorDepth:16),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:360;Height:480;ColorDepth:24),(Width:360;Height:480;ColorDepth:32),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:400;Height:300;ColorDepth: 8),(Width:400;Height:300;ColorDepth:15),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:400;Height:300;ColorDepth:16),(Width:400;Height:300;ColorDepth:24),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:400;Height:300;ColorDepth:32),(Width:512;Height:384;ColorDepth: 8),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:512;Height:384;ColorDepth:15),(Width:512;Height:384;ColorDepth:16),<br>&nbsp; &nbsp; &nbsp; &nbsp; (Width:512;Height:384;ColorDepth:24),(Width:512;Height:384;ColorDepth:32));<br><br><br>--------------------------------------------------------------------------------<br><br>What remains is the function TryToAddToList:<br><br><br>--------------------------------------------------------------------------------<br><br>procedure TryToAddToList(DeviceMode: TDevMode);<br>// Adds a video mode to the list if it's not a duplicate and can actually be set.<br>var I : Integer;<br>begin<br>&nbsp; // See if this is a duplicate mode (can happen because of refresh<br>&nbsp; // rates, or because we explicitly try all the low-res modes)<br>&nbsp; for I:=1 to NumberVideomodes-1 do<br>&nbsp; &nbsp; with DeviceMode do<br>&nbsp; &nbsp; &nbsp; if ((dmBitsPerPel = VideoModes.ColorDepth) and<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (dmPelsWidth &nbsp;= VideoModes.Width) &nbsp; &nbsp; &nbsp;and<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (dmPelsHeight = VideoModes.Height)) &nbsp; &nbsp;then Exit; // it's a duplicate mode<br><br>&nbsp; // do a mode set test (doesn't actually do the mode set, but reports whether it would have succeeded).<br>&nbsp; if ChangeDisplaySettings(DeviceMode,CDS_TEST or CDS_FULLSCREEN) &lt;&gt; DISP_CHANGE_SUCCESSFUL then Exit;<br><br>&nbsp; // it's a new, valid mode, so add this to the list<br>&nbsp; with DeviceMode do<br>&nbsp; begin<br>&nbsp; &nbsp; VideoModes[NumberVideomodes].ColorDepth:=dmBitsPerPel;<br>&nbsp; &nbsp; VideoModes[NumberVideomodes].Width:=dmPelsWidth;<br>&nbsp; &nbsp; VideoModes[NumberVideomodes].Height:=dmPelsHeight;<br>&nbsp; &nbsp; VideoModes[NumberVideomodes].Description:=Format('%d x %d, %d bpp',[dmPelsWidth,dmPelsHeight,dmBitsPerPel]);<br>&nbsp; end;<br>&nbsp; Inc(NumberVideomodes);<br>end;<br><br><br>--------------------------------------------------------------------------------<br><br>To make your implementation complete, you'd need a function to restore the default video mode, after your program exits:<br><br><br>--------------------------------------------------------------------------------<br><br>procedure RestoreDefaultMode;<br>// restores default desktop video mode<br>var T : TDevMode absolute 0; // a little trick to create a nil pointer<br>begin<br>&nbsp; // Since the first parameter must be a var, we cannot use nil directly. Instead<br>&nbsp; // &nbsp;we use a variable with an absolute address of 0.<br>&nbsp; ChangeDisplaySettings(T,CDS_FULLSCREEN);<br>end;<br><br>
 
谢谢wk_knife!<br>我和你一样查MSDN就只到了发现它只可以查到状态,但没有方法设置那些状态属性!<br>哎,我发现MS还是够恶,很多API还是不为人所知。<br>你后面的方法应该来说还可以,我以前看了好象一个什么控件的代码似乎也很烦琐<br>我真是不知道如何用API作到?
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部