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

下面综合整理下网上两位博主的用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. ZOJ - 3537 Cake (凸包+区间DP+最优三角剖分)

    Description You want to hold a party. Here's a polygon-shaped cake on the table. You'd like to cut t ...

  2. JVM性能优化, Part 5 Java的伸缩性

    很多程序员在解决JVM性能问题的时候,花开了很多时间去调优应用程序级别的性能瓶颈,当你读完这本系列文章之后你会发现我可能更加系统地看待这类的问题.我说过JVM的自身技术限制了Java企业级应用的伸缩性 ...

  3. Linux ~ termios 串口编程

    ermios 结构是在POSIX规范中定义的标准接口,它类似于系统V中的termio接口,通过设置termios类型的数据结构中的值和使用一小 组函数调用,你就可以对终端接口进行控制. 可以被调整来影 ...

  4. html5 css3 进度条特效

    https://www.html5tricks.com/tag/css3%E8%BF%9B%E5%BA%A6%E6%9D%A1/page/3

  5. URL重定向之一.htaccess文件和AllowOverride指令

    通常利用Apache的rewrite模块对URL进行重写的时候,rewrite规则会写在 .htaccess文件里.但是要使Apache能够正常读取 .htaccess文件的内容,就必须对 .htac ...

  6. C语言的操作符号

    #include <iostream> int main(void) { int a = 100, b = 40; //理解++在前还后的区别: a = b++; //a = b ; b= ...

  7. <HTTP协议详解>由浅入深看HTTP

    一. HTTP协议的应用简单概况 HTTP协议的主要特点可概括如下: 1.支持客户/服务器模式.2.简单快速:客户向服务器请求服务时,只需传送请求方法和路径.请求方法常用的有GET.HEAD.POST ...

  8. UNIDBgrid里动态添加clientevents实现回车替换TAB

    //GRID里回车替换TABfunction cellkeydown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts){ if (e.get ...

  9. 在windows下进行linux开发:利用Vagrant+virtualbox

    1,介绍Vagrant 我们做web开发的时候经常要安装各种本地测试环境,比如apache,php,mysql,redis等等.出于个人使用习惯,可能我们还是比较习惯用windows.虽然说在wind ...

  10. GridView设置多个DatakeyNames

    1.aspx页面GridView直接绑定DataKeyNames aspx设置: <asp:GridView ID="grvGrid" runat="server& ...