如何防止窗户被移动? [英] How do you prevent a windows from being moved?

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

问题描述

我将如何阻止表单被移动.我将表单边框样式设置为 FixedSingle 并希望保持这种方式,因为它在 vista 中看起来不错:)

How would i go about stopping a form from being moved. I have the form border style set as FixedSingle and would like to keep it this way because it looks good in vista :)

推荐答案

看看这个 链接.您可能对选项 #3 感兴趣.它需要您包装一些本机代码,但应该可以工作.链接底部还有一条评论,显示了一种更简单的方法.摘自评论(不能相信它,但我会为您节省一些搜索时间):

Take a look at this link. You might be interested in option #3. It will require you to wrap some native code, but should work. There's also a comment at the bottom of the link that shows an easier way to do it. Taken from the comment (can't take credit for it, but I'll save you some searching):

protected override void WndProc(ref Message message)
{
    const int WM_SYSCOMMAND = 0x0112;
    const int SC_MOVE = 0xF010;

    switch(message.Msg)
    {
        case WM_SYSCOMMAND:
           int command = message.WParam.ToInt32() & 0xfff0;
           if (command == SC_MOVE)
              return;
           break;
    }

    base.WndProc(ref message);
}

这篇关于如何防止窗户被移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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