欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C# 改变无边框窗体尺寸大小的方法

程序员文章站 2023-12-21 22:35:58
复制代码 代码如下:code highlighting produced by actipro codehighlighter (freeware)const int ht...

复制代码 代码如下:

code highlighting produced by actipro codehighlighter (freeware)
const int htleft = 10;
const int htright = 11;
const int httop = 12;
const int httopleft = 13;
const int httopright = 14;
const int htbottom = 15;
const int htbottomleft = 0x10;
const int htbottomright = 17;

protected override void wndproc(ref message m)
{
    switch (m.msg)
    {
        case 0x0084:
            base.wndproc(ref m);
            point vpoint = new point((int)m.lparam & 0xffff,
                (int)m.lparam >> 16 & 0xffff);
            vpoint = pointtoclient(vpoint);
            if (vpoint.x <= 5)
                if (vpoint.y <= 5)
                    m.result = (intptr)httopleft;
                else if (vpoint.y >= clientsize.height - 5)
                    m.result = (intptr)htbottomleft;
                else m.result = (intptr)htleft;
            else if (vpoint.x >= clientsize.width - 5)
                if (vpoint.y <= 5)
                    m.result = (intptr)httopright;
                else if (vpoint.y >= clientsize.height - 5)
                    m.result = (intptr)htbottomright;
                else m.result = (intptr)htright;
            else if (vpoint.y <= 5)
                m.result = (intptr)httop;
            else if (vpoint.y >= clientsize.height - 5)
                m.result = (intptr)htbottom;
            break;
        case 0x0201://鼠标左键按下的消息
            m.msg = 0x00a1;//更改消息为非客户区按下鼠标
            m.lparam = intptr.zero;//默认值
            m.wparam = new intptr(2);//鼠标放在标题栏内
            base.wndproc(ref m);
            break;
        default:
            base.wndproc(ref m);
            break;
    }
}

上一篇:

下一篇: