如何增加mfc中组合框控制的高度? [英] How to increase the height of the combobox control in mfc?

查看:252
本文介绍了如何增加mfc中组合框控制的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想增加组合框控制的高度。增加组合框控制的宽度正在发生但是当我试图增加高度时控制我无法向下拖动。



我长时间用Google搜索,我没有找到任何答案,到处都提到如何增加高度组合文字而不是控制高度。





任何人都可以告诉我如何增加组合框控件的高度。







提前致谢,

Raja

解决方案

来自MSDN的C ++的SetItemHeight示例:



  //  将每个项目的高度设置为 
// 项目文本范围的垂直大小。
CString str ;
CSize sz;
CDC * pDC = m_pComboBox-> GetDC();
for int i = 0 ; i< m_pComboBox-> GetCount(); i ++)
{
m_pComboBox-> GetLBText(i,str);
sz = pDC-> GetTextExtent(str);

m_pComboBox-> SetItemHeight(i,sz.cy);
}
m_pComboBox-> ReleaseDC(pDC);





祝你好运,

Herb


要更改视觉高度,您需要将其设为OwnerDrawn并实现MeasureItem()函数,如:



void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)

{

lpMeasureItemStruct-> itemHeight = 17;

}



这是一个很好的例子:

IconComboBox - 选择图标 [ ^ ]

Hi,

I want to increase the height of the combobox control.Increasing the width of the combobox control is happening but when I am trying to increase the height of the control I am not able to drag it downwards.

I googled for long time and I did not find any answer, everywhere they are mentioning how to increase the height of the combo text but not the control height.


Can anyone please let me know how can I increase the height of the combobox control.



Thanks in advance,
Raja

解决方案

The C++'s SetItemHeight example from MSDN:

// Set the height of every item to be the 
// vertical size of the item's text extent.
CString str;
CSize   sz;
CDC*    pDC = m_pComboBox->GetDC();
for (int i = 0; i < m_pComboBox->GetCount(); i++)
{
   m_pComboBox->GetLBText(i, str);
   sz = pDC->GetTextExtent(str);

   m_pComboBox->SetItemHeight(i, sz.cy);
}
m_pComboBox->ReleaseDC(pDC);



Good luck,
Herb


To change the visual height, you need to make it OwnerDrawn and implement MeasureItem() function like:

void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
lpMeasureItemStruct->itemHeight = 17;
}

Here is a good example:
IconComboBox - Selecting Icons[^]


这篇关于如何增加mfc中组合框控制的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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