窗口全屏,覆盖任务栏

给人做个东西,有这个要求

先放上一些玩意的隐藏
任务栏::ShowWindow(::FindWindow(_T("Shell_TrayWnd"), NULL), SW_HIDE);
开始菜单 ::ShowWindow(::GetDlgItem(::FindWindow(_T("Shell_TrayWnd"), NULL),0x130), SW_HIDE);//0x130 是开始按钮的ID
桌面 ::ShowWindow(::FindWindow(_T("ProgMan"), NULL), SW_HIDE);

禁用可以用EnableWindow()

以为隐藏任务栏就完事,结果下面不给腾出位子来,任务栏原先的地方还是不会被覆盖
在任务栏上右键,属性,设置任务栏自动隐藏任务栏时发现窗口会占据那块位置,网上找到个设置自动隐藏的代码,结合隐藏任务栏,成功达到目的

VOID HideTaskBar(BOOL bHide) { int nCmdShow; HWND hWnd; LPARAM lParam; hWnd = FindWindow(_T("Shell_TrayWnd"),NULL); if(bHide == TRUE) { nCmdShow = SW_HIDE; lParam = ABS_AUTOHIDE | ABS_ALWAYSONTOP; } else { nCmdShow = SW_SHOW; lParam = ABS_ALWAYSONTOP; } ShowWindow(hWnd,nCmdShow); APPBARDATA apBar; memset(&apBar, 0, sizeof(apBar)); apBar.cbSize = sizeof(apBar); apBar.hWnd = hWnd; if(apBar.hWnd != NULL) { apBar.lParam = lParam; SHAppBarMessage(ABM_SETSTATE, &apBar); } }用到shellapi需要包含头文件

vs08+xp测试通过



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现WinForm窗口全屏显示并隐藏下方任务,我们可以按照以下步骤进行操作: 1. 将窗口的BorderStyle属性设置为None,这样可以去掉窗口的标题和边框。 2. 使用窗口的WindowState属性将窗口最大化,即将其状态设置为Maximized。 3. 在窗口加载时,使用Screen类的PrimaryScreen属性获取主屏幕的大小信息。 4. 获取任务的高度,可以使用Screen类的WorkingArea属性的Height属性减去Screen类的PrimaryScreen属性的Height属性来计算。 5. 将窗口的Height属性设置为主屏幕的Height减去任务的高度,这样窗口就可以全屏显示了。 6. 在窗口的VisibleChanged事件中,使用Win32 API函数FindWindow和ShowWindow来隐藏任务。 下面是示例代码,实现了窗口全屏显示并隐藏任务: ```c# using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace FullScreenApp { public partial class MainForm : Form { // 引入Win32 API函数 [DllImport("user32.dll")] private static extern IntPtr FindWindow(string className, string windowName); [DllImport("user32.dll")] private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); // 窗口消息常量 private const int SW_HIDE = 0; private const int SW_SHOW = 1; public MainForm() { InitializeComponent(); } private void MainForm_Load(object sender, EventArgs e) { // 窗口最大化 WindowState = FormWindowState.Maximized; // 获取主屏幕大小和任务高度 int screenWidth = Screen.PrimaryScreen.Bounds.Width; int screenHeight = Screen.PrimaryScreen.Bounds.Height; int taskbarHeight = Screen.PrimaryScreen.Bounds.Height - Screen.PrimaryScreen.WorkingArea.Height; // 全屏显示窗口 Height = screenHeight - taskbarHeight; } private void MainForm_VisibleChanged(object sender, EventArgs e) { // 隐藏任务 IntPtr taskbarHandle = FindWindow("Shell_TrayWnd", null); ShowWindow(taskbarHandle, SW_HIDE); } } } ``` 使用以上的代码和步骤,我们就可以将WinForm窗口全屏显示,并在显示窗口时隐藏下方任务

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值