使用C#扩展非客户区的大小 [英] Extend size of non client area using C#

查看:228
本文介绍了使用C#扩展非客户区的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要扩展客户区顶部边缘的大小,以输入该位置的非GUI组件。我使用下面的代码,但是,通过将扩展区域代码变为空白,您无法获得Windows 7 Professional的透明度,这是我正在使用的操作系统。

我是新编程和C#Windows API。我感谢关注。



I need to extend the size of the top edge of the client area to enter non GUI components that location. I am using the code below to this, however, by turning the extended area code is blank, you do not get the transparency of Windows 7 Professional, which is the OS I'm using.
I am new to programming and C # Windows API. I thank the attention.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    namespace InstrumentalCsharp
    {
    public partial class WExplorerPadrao : Form
    {

        [StructLayout(LayoutKind.Sequential)]
        public struct MARGINS
        {
            public int cxLeftWidth;      // width of left border that retains  its size
            public int cxRightWidth;     // width of right border that retains its size
            public int cyTopHeight;      // height of top border that retains its size
            public int cyBottomHeight;   // height of bottom border that retains its size
        };

    [DllImport("dwmapi.dll", PreserveSig = false)]
    public static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref     MARGINS margins);

    [DllImport("dwmapi.dll", PreserveSig = false)]
    public static extern bool DwmIsCompositionEnabled();


        public WExplorerPadrao()
        {
            InitializeComponent();
        }

    protected void WExplorerPadrao_Load(object sender, System.EventArgs e)
        {
            WExplorerPadrao.MARGINS margins = new WExplorerPadrao.MARGINS();
            margins.cxLeftWidth = 0;
            margins.cxRightWidth = 0;
            margins.cyTopHeight = 20;
            margins.cyBottomHeight = 0;
            IntPtr hwnd = this.Handle;
            WExplorerPadrao.DwmExtendFrameIntoClientArea(hwnd, ref margins);
        }
    }
}





我尝试了什么:



我尝试用其他语言扩展非客户区域的顶部,但是,结果与我上面描述的相同。



What I have tried:

I tried extend the top of non client area in other languages, however, the result is the same as I described above.

推荐答案

您无法扩展非客户区域的大小。但是您可以将窗口放在可见屏幕上。只需将非客户区窗口的位置设置为负Y坐标,并确保窗口的高度合适。因此,如果您的窗口位于0,-100,那么您的窗口高度应该大于 Math.Abs​​(pos.Y)



最后,设置窗口不要出现在任务栏中(如有必要)。
You can't "expand the size of the non-client area". But you can position a window off the visible screen. Simply set the position of the "non-client area" window to a negative Y coordinate, and make sure the window's height is appropriate. So if your window is positioned at 0,-100, then your window height should be larger than Math.Abs(pos.Y).

Finally, set your window not to appear in the task bar (if necessary).


这篇关于使用C#扩展非客户区的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆