mfc 控件大小 调整大小
This article describes a simple method to resize a control at runtime. It includes ready-to-use source code and a complete sample demonstration application. We'll also talk about C# Extension Methods.
本文介绍了一种在运行时调整控件大小的简单方法。 它包括现成的源代码和完整的示例演示应用程序。 我们还将讨论C#扩展方法。
Introduction
介绍
In one of my applications I needed a control that could be resizable at run time. Just like the canvas in MSPaint, you can resize it inside the host window. After a quick search on the internet I noticed that most solutions treating this simple issue as a beast. An example of a "complex implementation" is in the EE Solution, here.
在我的一个应用程序中,我需要一个可以在运行时调整大小的控件。 就像MSPaint中的画布一样,您可以在主机窗口中调整其大小。 在互联网上快速搜索之后,我注意到大多数解决方案都将这个简单的问题视为野兽。 “复杂实现”的一个示例在EE解决方案中( 此处) 。
Using SendMessage is an intuitive temptation. We could try the technique I descried in my previous article on how to drag a form -- wehe we simply flood mouse movement to the caption of the host form. However, the parameters for resizing message scattered to eight directions and you'd have to calculate the delta in each direction to make it work. That’s why the code tends to become so bulky.
使用SendMessage是一种直观的诱惑。 我们可以尝试在上一篇文章中介绍的有关如何拖动表单的技术-我们只是将鼠标移动泛滥到宿主表单的标题上。 但是&