zoukankan      html  css  js  c++  java
  • winform无标题窗体点击任务栏最小化、还原功能

    做winform开发的时候,常常为了美化界面,把窗体的FormBorderStyle属性设置为None,即所谓的无标题窗体,这个时候,在任务栏鼠标右击是没有菜单的,那么如何吧默认的系统菜单还原回来呢?

    第一步,引用命名空间 

    using System.Windows.Forms;
    using System.Runtime.InteropServices;

    第二步,把以下代码添加到Form的类中

    #region 右击菜单
            [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
            public static extern int GetWindowLong(HandleRef hWnd, int nIndex);
    
            [DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)]
            public static extern IntPtr SetWindowLong(HandleRef hWnd, int nIndex, int dwNewLong);
    
            const int WS_CLIPCHILDREN = 0x2000000;
            const int WS_MINIMIZEBOX = 0x20000;
            const int WS_MAXIMIZEBOX = 0x10000;
            const int WS_SYSMENU = 0x80000;
            const int CS_DBLCLKS = 0x8;
            protected override CreateParams CreateParams
            {
                get
                {
                    CreateParams cp = base.CreateParams;
    
                    cp.Style = WS_CLIPCHILDREN | WS_MINIMIZEBOX | WS_SYSMENU;
                    cp.ClassStyle = CS_DBLCLKS;
    
                    return cp;
                }
            }
    
    
            #endregion
    

     OK。

  • 相关阅读:
    redhat 6.7 telnet rpm 安装包
    linux下网络配置 命令
    修复南尼U盘
    mac获取root权限
    ubuntu二进制包安装openresty
    ubuntu18源码包安装openresty
    Python监控rabbitmq的代码
    win10不能将文件拖到另外一个程序中去的解决办法
    docker配置远程管理端口
    nginx的代理配置
  • 原文地址:https://www.cnblogs.com/kongll/p/2514818.html
Copyright © 2011-2022 走看看