Winform 去掉 最大化 最小化 关闭按钮(不是关闭按钮变灰)终极解决办法
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Drawing.Drawing2D;
- using System.Runtime.InteropServices;
- namespace WinDemo
- {
- public partial class Form5 : Form
- {
- public Form5()
- {
- InitializeComponent();
- }
- /// <summary>
- /// Button 按钮重绘事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Paint(object sender, PaintEventArgs e)
- {
- GraphicsPath myPath = new GraphicsPath();
- Rectangle rect = new Rectangle(0,0,574,362);//后面2个数据调整窗体大小
- myPath.AddRectangle(rect);
- this.Region = new Region(myPath);
- }
- [DllImport("user32.dll")]
- static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
- [DllImport("User32.dll")]
- private static extern IntPtr GetWindowDC(IntPtr hWnd);
- protected override void WndProc(ref System.Windows.Forms.Message m)
- {
- const int WM_NCPAINT = 0x85;
- base.WndProc(ref m);
- if (m.Msg == WM_NCPAINT)
- {
- IntPtr hdc = GetWindowDC(m.HWnd);
- if ((int)hdc != 0)
- {
- Graphics g = Graphics.FromHdc(hdc);
- Pen pen1 = new Pen(Color.FromArgb(64,64,64));
- Pen pen2 = new Pen(Color.FromArgb(128, 128, 128));
- Pen pen3 = new Pen(Color.FromArgb(212, 208, 200));
- g.DrawLine(pen1, 573, 0, 573, 360);//最外边
- g.DrawLine(pen2, 572, 1, 572, 359);//最外边第二条白色
- g.DrawLine(pen3, 571, 2, 571, 359);
- g.DrawLine(pen3, 571, 2, 571, 359);
- g.Flush();
- ReleaseDC(m.HWnd, hdc);
- }
- }
- }
- private void Form5_MouseCaptureChanged(object sender, EventArgs e)
- {
- Graphics g = this.CreateGraphics();
- Pen pen1 = new Pen(Color.FromArgb(64, 64, 64));
- Pen pen2 = new Pen(Color.FromArgb(128, 128, 128));
- Pen pen3 = new Pen(Color.FromArgb(212, 208, 200));
- g.DrawLine(pen1, 573, 0, 573, 360);//最外边
- g.DrawLine(pen2, 572, 1, 572, 359);//最外边第二条白色
- g.DrawLine(pen3, 571, 2, 571, 359);
- g.DrawLine(pen3, 571, 2, 571, 359);
- g.Flush();
- }
- }
- }
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
internal static extern IntPtr GetSystemMenu(IntPtr hwnd, bool bRevert);
[DllImport("user32.dll")]
internal static extern int GetMenuItemCount(IntPtr hMenu);
[DllImport("user32.dll")]
internal static extern int RemoveMenu(IntPtr hMenu, int uPosition, int uFlags);
/// <summary>
/// 窗体的关闭按钮失效
/// </summary>
protected void CloseButtonEnable()
{
// 默认窗口去除关闭按钮
const int MF_BYPOSITION = 0x00000400;
IntPtr hWindow = this.Handle;
IntPtr hMenu = GetSystemMenu(hWindow, false);
int count = GetMenuItemCount(hMenu);
RemoveMenu(hMenu, count - 1, MF_BYPOSITION);
RemoveMenu(hMenu, count - 2, MF_BYPOSITION);
}
private void confirm_Load(object sender, EventArgs e)
{
CloseButtonEnable();
}
Winform 去掉 最大化 最小化 关闭按钮(不是关闭按钮变灰)终极解决办法的更多相关文章
- 【转】Winform 去掉 最大化 最小化 关闭按钮(不是关闭按钮变灰)终极解决办法
不墨迹, 如图 : 网上 看了,好多 给的 答案 乱码七糟,都是扯淡,于是乎 自己 写,代码如下:窗体的大小暂时设置为:(598, 362) 涂红的数据根据你的窗体大小改动 using System; ...
- 通过virtualbox最小化安装centos 6.3后无法上网解决办法
通过virtualbox最小化安装centos 6.3后无法上网解决办法 1.设置virtualbox的网络连接方式,如下图使用桥接方式,桥接的网卡为宿主正在上网的网卡,现在我是通过无线来上网的,所以 ...
- 监听Activity进入后台(最小化),并根据时间判断是否超时,此解决办法可用于超时重登陆
通过重写一个继承自Activity的基类中的onUserLeaveHint()方法,当用户按Home键等操作使程序进入后台时即开始计时,当用户使程序恢复为前台显示时执行onResume()方法,在其中 ...
- C#winform如何主窗口最大化最小化默认大小
this.WindowState = FormWindowState.Minimized; bool b = true; private void button2_Click(object sende ...
- PyQt:无边框自定义标题栏及最大化最小化窗体大小调整
环境 Python3.5.2 PyQt5 陈述 隐藏掉系统的控制栏,实现了自定义的标题控制栏,以及关闭/最大化/最小化的功能,自由调整窗体大小的功能(跟随一个大佬学的),代码内有详细注释 只要把Mai ...
- Qt 窗口操作函数(置顶、全屏,最大化最小化按钮设置等)
一.窗口置顶 与 取消置顶 void MainWindow::on_windowTopButton_clicked() { if (m_flags == NULL) { m_flags = windo ...
- c# 窗体相关操作(最大化/最小化/关闭/标题栏)
/// <summary> /// 窗体跟随鼠标移动的标记 /// </summary> private bool normalmoving = false; /// < ...
- 【转】ubuntu 12.04 LTS将关闭最大化最小化移动到右上角
原文网址:http://www.4byte.cn/learning/114801.html ubuntu 12.04 LTS将关闭最大化最小化移动到右上角 还是按下“ALT +F2”组合键,输入g ...
- C#程序实现窗体的最大化/最小化
C#程序实现窗体的最大化/最小化 http://blog.csdn.net/jiangqin115/article/details/41251215 private void button1_Clic ...
随机推荐
- 在Windows下使用CodeBlock使用libiconv第三方库
在Windows下使用CodeBlock使用libiconv第三方库 1. 选择在Project->Build options下: 2. 如下图添加libicon ...
- Markdown 语法详解
Markdown 学习 标题 三级标题 四级标题 最多支持六级标题 "#... + 标题名称" 字体 hello, world "** 内容 **" hello ...
- 半监督伪标签方法:Feature Space Regularization和Joint-Distance
原文链接 小样本学习与智能前沿 . 在这个公众号后台回复"200706",即可获得课件电子资源. @ 目录 Abstract I. INTRODUCTION Framework. ...
- 再也不担心写出臃肿的Flink流处理程序啦,发现一款将Flink与Spring生态完美融合的脚手架工程-懒松鼠Flink-Boot
目录 你可能面临如下苦恼: 接口缓存 重试机制 Bean校验 等等...... 它为流计算开发工程师解决了 有了它你的代码就像这样子: 仓库地址:懒松鼠Flink-Boot 1. 组织结构 2. 技术 ...
- 学习笔记(1):零基础掌握 Python 入门到实战-列表与元祖到底该用哪个?(二)...
立即学习:https://edu.csdn.net/course/play/26676/338778?utm_source=blogtoedu 列表不能通过增加索引增加元素 可以使用list中的app ...
- day1(初始化项目结构)
1.初始化项目结构 └─shiyanlou_project │ .gitignore │ README.en.md # 英文 │ README.md ...
- 【Docker】 CentOS7 安装 Docker 及其使用方法 ( 一 )
系列目录: [Docker] CentOS7 安装 Docker 及其使用方法 ( 一 ) [Docker] 使用Docker 在阿里云 Centos7 部署 MySQL 和 Redis (二) [D ...
- Samba服务器搭建,匿名访问,用户密码访问
环境 #服务端:centos7 客户端:centos7,windows10 配置yum源,使用光盘镜像安装Samba服务 #挂载光盘:mount /dev/sr0 /mnt/cdrom #安装sa ...
- c++如何按照map的value进行排序?
static bool cmp(pair<char, int> a , pair<char,int> b) { return a.second>b.second; //按 ...
- MyBatis if 标签的坑,居然被我踩到了。。。
事件的原因是这样的,需求是按条件查数据然后给前端展示就行了,写的时候想着挺简单的,不就是使用 MyBatis 动态 SQL 去查询数据吗? 现实还是很残酷的,等我写完上完 UAT 后,前端同学说根据s ...