禁止移动窗口 [英] Disable moving of window

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

问题描述

大家好,

我正在尝试禁用在窗口周围拖动的功能,但似乎还没有找到正确的代码.

我发现的是检查WM_NCHITTEST消息,如果它属于标题栏,请将其移至其他内容.我希望有一个更直接的解决方案.

在此先感谢!

Hi all,

I''m trying to disable the ability to drag a window around but I haven''t seem to find the correct code for it.

The ones that I have found is to do check for the WM_NCHITTEST message and if it belongs to the title bar, shift it to something else. I was hoping for a more direct solution.

Thanks in advance!

推荐答案

设法解决了这个问题.

使用OnMoving函数和ON_WM_MOVING消息,只需将LPRECT的函数参数的值更改为当前窗口大小即可.

Managed to to solved this.

Using the OnMoving function and ON_WM_MOVING message, just change the values of the function parameter of the LPRECT to the current window size.

void MyClass::OnMoving(UINT nSide, LPRECT lpRect)
{
	CDialog::OnMoving(nSide, lpRect);

	// TODO: Add your message handler code here and/or call default
	
	// Find Current location of the dialog
	CRect CurRect;
	GetWindowRect(&CurRect);

	// Set current location as the moving location
	lpRect->left = CurRect.left;
	lpRect->top = CurRect.top;
	lpRect->right = CurRect.right;
	lpRect->bottom = CurRect.bottom;
}


将对您有用WM_GETMINMAXINFO [
will this work for you WM_GETMINMAXINFO [^]


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

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