Windows C++ 对话框缩放器类

发布于 2024-07-06 11:07:34 字数 524 浏览 6 评论 0 原文

我正在寻找一个非常好的对话框调整器类,它将在调整屏幕大小时根据需要拉伸和收缩各个项目。 Stephan Keil 有一个很好的工具(DlgResizeHelper),它基本上可以按设定的比例调整所有内容的大小,但我正在寻找更智能的东西。

例如:

  • 图标不应调整大小

  • 单行文本框不应垂直拉伸

  • 按钮应可能保持相同的大小

基本上我正在寻找一些东西来查看所有控件,找出静态文本字段与其旁边/下面的控件相关并锚定两个放在一起,并以“智能”方式调整大型控件的大小,使其看起来不错。

有这样的框架吗? 我一直在研究一个,但现成的东西可能会更好。

跟进:我正在查看建议的解决方案。 其中许多要求您在对话框中的每个控件中定位一个锚点。 我正在寻找一些智能的东西,它可以找出锚点应该是什么,并且能够在猜测错误时手动锚定。 看起来应该是可能的——大多数人都会同意编辑字段旁边的静态文本字段应该锚定在一起。 我猜我正在寻找一点人工智能:)

I'm looking for a really good dialog resizer class that will stretch and shrink individual items as needed as the screen is resized. Stephan Keil has a good one (DlgResizeHelper) which basically resizes everything by a set ratio, but I'm looking for something smarter.

For example:

  • Icons should not resize

  • Single-line text boxes should not be stretched vertically

  • Buttons should probably stay the same size

Basically I'm looking for something to look at all of the controls, figure out that a static text field is related to a control next/below it and anchor the two together, and resize large controls in a 'smart' way so it looks good.

Are there such frameworks out there? I've been working on one but something ready-made would probably be better.

FOLLOW UP: I'm looking at the suggested solutions. Many of them require you to go in an anchor each control on the dialog. I'm looking for something smart that will figure out what the anchors ought to be, with the ability to manually anchor if the guesses are wrong. Seems like it should be possible -- most humans would agree a static text field next to an edit field should be anchored together. Guess I'm almost looking for a little AI here :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

叹梦 2024-07-13 11:07:34

您可以使用 wxWidgets。 它完全取代了 MFC,是多平台的,并为您提供了基于布局的对话框机制。

You can use wxWidgets. It completely replaces MFC, is multi-platform, and gives you a layout-based dialog mechanism.

無處可尋 2024-07-13 11:07:34

我使用 可调整大小库(也包括 PropertySheets 和 Pages),来自代码项目,IIRC。 您可以设置锚点来确定对话框和控件如何随着对话框的移动而调整大小或移动。

您可以为每个控件设置最多 2 个锚点(左、右),以便您可以在对话框移动时移动它们,或在移动时调整它们的大小。 它很容易理解,但很难完全正确:)

I use ResizableLib (also does PropertySheets and Pages) off codeproject, IIRC. You set anchor points that determine how the dialog and controls resize or move as the dialog moves.

You can set up to 2 anchors per control, (left, right) so you can move them as the dialog moves, or resize them as it moves. Its very easy to understand, if difficult to get perfectly right :)

因为看清所以看轻 2024-07-13 11:07:34

我尝试了很多,最后选择了 http://www.codeproject.com/KB /dialog/layoutmgr.aspx。 但它并没有执行您建议的“智能”布局。 我从来没有在任何图书馆、任何平台上看到过这种情况——我不知道如果没有大量的底层魔法,它会如何工作,无论如何,这些魔法必须在一半的时间被覆盖。

I've tried many and finally settled on http://www.codeproject.com/KB/dialog/layoutmgr.aspx. It doesn't do the 'intelligent' layouting that you suggest though. I've never seen that in any library, on any platform - I don't see how it would work without having lots of under the hood magic that'd have to be overridden half of the time anyway.

一袭水袖舞倾城 2024-07-13 11:07:34

Ultimate Toolbox MFC 库(CodeProject 上此处)包含一个 布局管理器。 我自己没有使用过它,但看起来它可以满足您的要求。

The Ultimate Toolbox MFC library (here on CodeProject) includes a layout manager. I haven't used it myself, but it looks like it does what you want.

笔芯 2024-07-13 11:07:34

您可以查看Professional GUI,我们使用他们的类库来调整对话框控件的大小。 我认为这是他们免费版本的一部分。

You can look at Professional GUI we use their class library for resizing our dialog controls. I think that is part of their free version.

回梦 2024-07-13 11:07:34

我们使用 CodeGuru 中的 CResize 类来自动调整所有控件的大小。 您告诉您希望如何调整每个控件的大小,它就会为您完成工作。

调整大小范例是指定当调整对话框大小时控件的每一侧将移动多少。

SetResize(IDC_EDIT1, 0,   0,   0.5, 1);
SetResize(IDC_EDIT2, 0.5, 0,   1,   1);

当您有大量对话框控件时非常方便。

源代码

We use CResize class from CodeGuru to resize all controls automatically. You tell how you want each control to be resized and it does the job for you.

The resize paradigm is to specify how much each side of a control will move when the dialog is resized.

SetResize(IDC_EDIT1, 0,   0,   0.5, 1);
SetResize(IDC_EDIT2, 0.5, 0,   1,   1);

Very handy when you have a large number of dialog controls.

Source code

小鸟爱天空丶 2024-07-13 11:07:34

这也是来自 CodeProject 的免费解决方案
http://www.codeproject.com/KB/dialog/dlgresizearticle.aspx
它只是一组简单的宏,用于在对话框调整大小时定位控件。

编辑 - 按照OP的评论。 我不知道 MFC 是否有任何通用的 sizer 支持,例如 QT/WX,它似乎也不存在于像 Winforms 这样的新框架中。
它在 QT/WX 中,因为它对于多平台是必要的,其中小部件可能具有不同的大小,这解释了 MS 缺乏它。 但它对于多语言端口也至关重要,例如。 其中取消的德语长度为 30 个字符。

This is a free solution also from CodeProject
http://www.codeproject.com/KB/dialog/dlgresizearticle.aspx
It's just a set of simple macros that position controls as the dialog resizes.

Edit - following the OPs comments. I don't know of any general sizer support like QT/WX for MFC, it doesn't seem to be present in new frameworks like Winforms either.
It is in QT/WX because it is necessary for multiplatform where widgets may be a different size, which explains MS lack of it. But it is also vital for multi-language ports, eg. where the German for cancel is 30 characters long.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文