911224 - 如何调整对话框的大小以使其具有指定的客户端大小? [英] 911224 - how to resize a dialog to have a specified client size?

查看:131
本文介绍了911224 - 如何调整对话框的大小以使其具有指定的客户端大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我正在使用位图背景进行对话。我已经通过CStatic ctrl实现了背景位图,并设置了SS_BITMAP样式。这会导致ctrl被拉伸到位图尺寸,以便位图可以显示为对话框背景。但我也需要调整对话框尺寸的大小,以便它也适合位图尺寸。如果我通过SetWindowPos执行此操作,则生成的客户端大小小于位图大小,因为该对话框包含标题和边框。我不想为此值添加固定大小。因为根据Windows的外观显示对话框,标题和边框的大小可能不同。

更改对话框大小的最佳方法是什么,以便位图可以适合在它内部?

thx

hi i''m working on a dialog with a bitmap background. i''ve implemented the background bitmap by a CStatic ctrl with SS_BITMAP style set. this causes the ctrl to be stretched to the bitmap dimensions so that the bitmap can be shown as the dialog background. but i need to resize the dialog dimensions too, so that it also fits the bitmap dimensions. if i do this by SetWindowPos, the resulting client size is less than the bitmap size, because the dialog contains caption and border. i don''t want to add a fixed size to this value. because based on the appearance of the Windows the dialog appears on, the size of caption and border may differ.
what''s the best method for changing the size of the dialog so that the bitmap can fit inside it?
thx

推荐答案

对话框的客户区域与外部尺寸之间的大小差异通常被称为修剪。确定修剪的一种相对简单的方法是调用GetClientRect和GetWindowRect。后者提供对话窗口的外部大小。减去客户端尺寸,你可以修剪。



为了放大你的CStatic适合的对话框,你必须添加修剪尺寸静态控制。



计算修剪的另一种方法是MFC功能CaclWindowRect,基本上和上面描述的相同。



希望能让你前进。
The difference in size between the client area of the dialog and the outer dimensions is generally referred to as the "trim". One relatively easy way of determining the trim is to call GetClientRect and GetWindowRect. The latter delivers the outer size of the dialog window. Subbtract the client size and you have the trim.

In order to enlarge your dialog in way that your CStatic will fit inside, you have to add the trim to the size of the static control.

Another method to calculate the trim is the MFC function CaclWindowRect, which basically does the same as described above.

Hope that gets you going.


这篇关于911224 - 如何调整对话框的大小以使其具有指定的客户端大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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