你怎么prevent Windows窗体移动? [英] How do you prevent a windows form being moved?
问题描述
我将如何去有关从移动停止的形式。我已经设定为FixedSingle形式的边框风格,并希望保持这种方式,因为它看起来很不错的远景:)
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 :)
推荐答案
看看这个<一href="http://vaibhavgaikwad.word$p$pss.com/2006/06/05/creating-a-immovable-windows-form-in-c/">link.您可能会感兴趣的#3选项。它会要求你包装一些本土code,但应该工作。还有一个评论,在显示一个简单的方法来做到这一点的链接的底部。从注释拍摄(不能把它的信用,但我会为你节省一些搜索):
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);
}
这篇关于你怎么prevent Windows窗体移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!