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

下面综合整理下网上两位博主的用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. 程序运行之ELF 符号表

    当一个工程中有多个文件的时候,链接的本质就是要把多个不同的目标文件相互粘到一起.就想玩具积木一样整合成一个整体.为了使不同的目标文件之间能够相互粘合,这些目标文件之间必须要有固定的规则才行.比如目标文 ...

  2. 将本地jar包手动复制到Maven库中,在其它电脑上用Maven打包时出错

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/UP19910522/article/details/31396107 背景交代:在做图片水印时候引入 ...

  3. Open AI Gym简介

    介绍 OpenAI Gym是一款用于研发和比较强化学习算法的工具包,它支持训练智能体(agent)做任何事——从行走到玩Pong或围棋之类的游戏都在范围中. OpenAI Gym 是一个用于开发和比较 ...

  4. 使用django开发一个博客

    环境: MAC 10.10.5  Yosemite Python 3.73 Django 代码托管 github

  5. rails 字符串 转化为 html

    simple_format http://apidock.com/rails/v4.0.2/ActionView/Helpers/TextHelper/simple_format http://api ...

  6. 【BZOJ4361】isn

    题目 [BZOJ4361]isn 做法 \(dp_{i,j}\)表示以\(i\)结尾\(j\)长度,树状数组\(tree_{i,j}\)表长度为\(i\),以\(<=j\)结尾的个数,显然\(d ...

  7. etcd -> Highly-avaliable key value store for shared configuration and service discovery

    The name "etcd" originated from two ideas, the unix "/etc" folder and "d&qu ...

  8. BestCoder Round #4 之 Miaomiao's Geometry(2014/8/10)

    最后收到邮件说注意小数的问题!此代码并没有过所有数据,请读者参考算法, 自己再去修改一下吧!注意小数问题! Miaomiao's Geometry Time Limit: 2000/1000 MS ( ...

  9. UOJ279 【UTR #2】题目交流通道

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000  作者博客:http://www.cnblogs.com/ljh2000-jump ...

  10. Spark- 常见问题

    记录spark使用中常见问题 SparkSQL 日期解析时用到SimpleDateFormat, SimpleDateFormat是线程不安全的.可以使用 FastDateFormat 如: impo ...