用常规方法实现全屏显示时,由于采用的三方控件导致界面顶端一直有一条半透明的类似标题栏的东西无法去除,原因一直没找到。

下面综合整理下网上两位博主的用WindowsAPI实现全屏的方法:

控件全屏显示: http://www.cnblogs.com/lmcblog/archive/2012/07/14/2591501.html

任务栏、开始菜单栏显示隐藏:http://www.cnblogs.com/ITBread/p/3503801.html

我把代码整理下,方便下次自己查看

1、任务栏、菜单栏的显示与隐藏

 [DllImport("user32.dll")]
public static extern bool GetCursorPos(ref Point lpPoint); [DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)]
public static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow); public static Point GetCursorPos()
{
Point point = new Point();
GetCursorPos(ref point);
return point;
} public static void HideTask(bool isHide)
{
try
{
IntPtr trayHwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);
IntPtr hStar = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Button", null); if (isHide)
{
ShowWindow(trayHwnd, );
ShowWindow(hStar, );
}
else
{
ShowWindow(trayHwnd, );
ShowWindow(hStar, );
}
}
catch { }
}

2、控件的全屏与取消

{
WindowFullScreenApi.HideTask(true);//先隐藏工具栏
var axTeWnd = axTe3DWindow;
axTeWnd.Dock = DockStyle.None;
axTeWnd.Left = ;
axTeWnd.Top = ;
axTeWnd.Width = Screen.PrimaryScreen.Bounds.Width;//获取显示器大小
axTeWnd.Height = Screen.PrimaryScreen.Bounds.Height;
WindowFullScreenApi.SetParent(axTeWnd.Handle, IntPtr.Zero); axTe3DWindow.Focus(); //axTeDWindow是我需要全屏的窗体控件
Application3D.CurrentSystemState.onKeyboardMessage = OnKeyDown;
} //按下Wsc键取消全屏
private void OnKeyDown(object sender, _ITE3DWindowEvents_OnKeyboardMessageEvent e)
{
if (e.keyCode == )
{
//SenceContrl.NormalForm();
WindowFullScreenApi.SetParent(axTe3DWindow.Handle, axTe3DWindow.Parent.Handle);
axTe3DWindow.OnKeyboardMessage -= OnKeyDown;
axTe3DWindow.Dock = DockStyle.Fill;
WindowFullScreenApi.HideTask(false);
}
}

winfrom实现控件全屏效果的更多相关文章

  1. C# WinForm中 让控件全屏显示的实现代码

    夏荣全 ( lyout(at)163.com )原文 C#中让控件全屏显示的实现代码(WinForm) 有时候需要让窗口中某一块的内容全屏显示,比如视频播放.地图等等.经过摸索,暂时发现两种可行方法, ...

  2. Extjs 疑难杂症 (LoadMark 遮罩、Panel Update无效、chrome浏览器date控件全屏)

    一.在extjs gridPanel中使用LoadMark无效,三步搞定. 原代码: grid = new Ext.grid.GridPanel({ store: store, title:'资料列表 ...

  3. Qt 之容器内的控件全屏

    m_label = new QLabel(); ui->stackedWidget->addWidget(m_label); ui->stackedWidget->setCur ...

  4. jQuery制作Web全屏效果

    需要的资源 1.jQuery版本库是必不可少的2.jQuery FullScreen plugin如果你下载不方便的话,你可以直接把下面的代码copy到你本地JQuery FullScreen plu ...

  5. Android学习之Android 5.0分享动画实现微信点击全屏效果

    Android5.0过渡动画,请看 http://blog.csdn.net/qq_16131393/article/details/51112772 今天用分享动画实现微信点击全屏效果 本文源代码下 ...

  6. js 实现浏览器全屏效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. axTE3DWindowEx双屏对比控件白屏解决方法以及网上方法的校正(CreateControlOveride)

    环境:vs2012,TE 6.5.1,winfrom C# 要做skyline的双屏显示功能,网上找到方法是用axTE3DWindowEx控件实现,把控件拖进去,运行,发现axTE3DWindow是正 ...

  8. 使控件具有 Tilt 效果

    步骤1:添加类: /* Copyright (c) 2010 Microsoft Corporation. All rights reserved. Use of this sample source ...

  9. Android -- 常见控件的小效果

    1,EditText控件 ① 修改光标颜色 自定义drawable 创建cursor.xml文件 <?xml version="1.0" encoding="utf ...

随机推荐

  1. Django开发模式会加载两次settings文件导致RotatingFileHandlerError

    当使用RotatingFileHandler作为django的日志处理器的时候,会报: Traceback (most recent call last): File "C:\Python2 ...

  2. Django自定义对象转成json字符串

    1.定义转换函数:def convert_to_builtin_type(obj): print 'default(', repr(obj), ')' # 把MyObj对象转换成dict类型的对象 d ...

  3. shell基础part2

    shell基础 一.bash中的变量 1.变量的定义:变量是计算机的内存单元,其中存放的值是可以改变的. 2.变量的设定规则:变量名不能以数字开头:变量的等号两边不能有空格,变量的值如果想有空格必须用 ...

  4. 【leetcode刷题笔记】Binary Tree Inorder Traversal

    Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tre ...

  5. sublime text的pylinter插件设置pylint_rc后提示错误

    sublime text插件pylinter提示错误 Warning: option include-ids is deprecated and ignored. 错误本身是Python的错误,这说明 ...

  6. shell 查看系统有关信息

    磁盘: 查看磁盘空间或者挂载情况 df -ah 或者 df -h 内存: 查看内存使用情况 free -m total used free shared buffers cached Mem: -/+ ...

  7. JavaScript在执行代码之前会校验代码,声明变量提前至当前作用域最前面。

    var name = 123; function getName(){ console.log(name); } getName(); 输出123 -------------------------- ...

  8. mysql 在windows server下发生系统错误 1067, 进程意外终止的解决方法

    mysql 在windows server下发生系统错误 1067, 进程意外终止,请检查系统盘下的windows目录下是否存在mysql的配置文件my.ini,如存在,将其删除或改名即可.

  9. linux 交换分区 swap

    linux swap分区用来保证内存过载时也可以使用,是在磁盘级别对内存的一次扩展,swap分区必须是一个单独的分区 创建过程: 1.用fdisk 命令新建分区,在创建过程中通过L命令和t命令来调整分 ...

  10. BZOJ 3943 [Usaco2015 Feb]SuperBull:最大生成树

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3943 题意: 有n只队伍,每个队伍有一个编号a[i]. 每场比赛有两支队伍参加,然后选一支 ...