如何使用下拉列表而不是ownerdraw样式更改Combobox控件的表观高度? [英] How to change the apparent height of a Combobox control with the dropdownlist but not ownerdraw style?

查看:434
本文介绍了如何使用下拉列表而不是ownerdraw样式更改Combobox控件的表观高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:在某个对话框中,有几个控件连续。我想所有的人都有相同的表观高度。但是对于具有CBS_DROPDOWNLIST样式和没有CBS_OWNERDRAW *的组合框我无法更改表观高度。

Background: In a certain dialog there are several controls in a row. I would like all of them to have the same apparent height. However for a combobox with the CBS_DROPDOWNLIST style and no CBS_OWNERDRAW* I am having trouble changing the apparent height.

问题:如何更改此类DROPDOWNLIST组合框的显示高度?

Question: How can I change the apparent height of such a DROPDOWNLIST combobox?

我知道组合框不允许改变SetWindowPos的高度。但是我的印象是,发送带有wParam = -1的CB_SETITEMHEIGHT消息应该修改高度。此方法适用于设置了CBS_OWNERDRAWFIXED样式的组合框(我想避免设置此样式以保留按钮状外观)。

I am aware that the combobox does not allow changing the height with SetWindowPos. I was however under the impression that sending a CB_SETITEMHEIGHT message with wParam= -1 should modify the height. This method does work for comboboxes with the CBS_OWNERDRAWFIXED style set (I wanted to avoid setting this style though to preserve the "button-like" look).

环境:My Win32应用程序使用Common-Controls 6.0,并且我关心在启用视觉样式的环境(Windows 7,Aero)中的外观。

Environment: My Win32 application uses Common-Controls 6.0 and I am concerned about the appearance in an environment where visual styles are enabled (Windows 7, Aero).

推荐答案

我不认为这是可能的。

正如你所提到的, SetWindowPos $ c> MoveWindow 工作就像你期望的。这是因为 ComboBox的高度包括下拉的高度下来。控件根据其使用的字体大小自动调整自身大小。所以要更改大小,通过发送一个 WM_SETFONT 消息。

As you mention, neither SetWindowPos nor MoveWindow work like you expect. That's because the height of a ComboBox includes the height of the drop-down. The control automatically resizes itself according to the size of the font it uses. So to change the size, change the size of the control's font by sending it a WM_SETFONT message.

但我不明白为什么这是一个问题。你说你想要一系列控件具有相同的高度,但除非你改变其他控件的高度,它们应该已经匹配。由于对话框上的所有控件通常使用相同的字体,组合框和文本框应该都具有相同的高度。当您使用v6的常用控件和视觉样式启用时,它们将应用于所有这些控件,他们应该有一个统一的外观。你不应该手动混乱的高度。

But I don't understand why this is a problem. You say that you want a series of controls to have the same height, but unless you're changing the height of the other controls, they should already match. Since all controls on a dialog generally use the same font, combo boxes and text boxes should all have the same height already. When you use v6 of the common controls and Visual Styles are enabled, they'll be applied to all of these controls and they should have a uniform appearance. You shouldn't have to mess with the heights manually.

这篇关于如何使用下拉列表而不是ownerdraw样式更改Combobox控件的表观高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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