• 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。

  • 相关阅读:
    积分第一中值定理
    History of mathematics(19th century)
    使用多项式解决矩阵问题
    菊与刀
    Mathematics during the Scientific Revolution(18th century)
    摄动
    Cauchy中值定理
    Leetcode3---Longest Substring Without Repeating Characters
    Leetcode2---Add Two Numbers
    矩形覆盖
  • 原文地址:https://www.cnblogs.com/kongll/p/2514818.html
Copyright © 2020-2023  润新知