如何使没有标题栏的窗口移动 [英] How to make a Window that does not have a Title bar move

查看:303
本文介绍了如何使没有标题栏的窗口移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何控件可以移动窗口而没有标题栏(顶部)/完全没有框架.

Is there any control that can move the Window without the Title bar(Top one)/No frame at all.

我正在制作一个便笺应用程序,所以我希望它紧凑.

I am making a note application as you know so I want it to be compact.

推荐答案

您需要从WndProc中的WM_NCHITTEST返回HTCAPTION:

You need to return HTCAPTION from the WM_NCHITTEST in your WndProc:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    const int WM_NCHITTEST = 0x0084;
    const int HTCLIENT = 1;
    const int HTCAPTION = 2;
    protected override void WndProc(ref Message msg)
    {
        base.WndProc(ref msg);
        if (msg.Msg == WM_NCHITTEST && msg.Result == (IntPtr)HTCLIENT)
        {
            msg.Result = (IntPtr)HTCAPTION;
        }
    }
}

这会使窗口的工作区在Windows中看起来像是标题栏.

That will make the client area of your window seem to Windows to be a caption bar.

这篇关于如何使没有标题栏的窗口移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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