CComboBox下拉按钮的高度是多少呢?

ruoge2007 2010-08-12 06:17:28
RT,thanks...
...全文
324 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
五香花生米 2010-08-13
  • 打赏
  • 举报
回复
自绘的话是自己根据要载入的按钮图标的大小指定一个矩形区域就好了吧。
psbeond 2010-08-13
  • 打赏
  • 举报
回复
用它呀,GetSystemMetrics。上面不是讲了吗?
ruoge2007 2010-08-13
  • 打赏
  • 举报
回复
各位,我是要自绘,需要知道下拉按钮的大小。仅是下拉按钮的大小。
psbeond 2010-08-13
  • 打赏
  • 举报
回复
GetSystemMetrics获得下拉列表的宽度
这个是正解。
在程序中,这个高度是不能被修改的。要想修改这个下拉按钮的高度,必须调用SetSystemMetrics,但SetSystemMetrics会使操作系统中所有的下拉按钮的高度全部改变。类似的还有滚动条的宽度。
muzizongheng 2010-08-13
  • 打赏
  • 举报
回复
GetDroppedWidth


// Find the longest string in the combo box.
CString str;
CSize sz;
int dx = 0;
TEXTMETRIC tm;
CDC* pDC = m_pComboBox->GetDC();
CFont* pFont = m_pComboBox->GetFont();

// Select the listbox font, save the old font
CFont* pOldFont = pDC->SelectObject(pFont);
// Get the text metrics for avg char width
pDC->GetTextMetrics(&tm);

for (int i = 0; i < m_pComboBox->GetCount(); i++)
{
m_pComboBox->GetLBText(i, str);
sz = pDC->GetTextExtent(str);

// Add the avg width to prevent clipping
sz.cx += tm.tmAveCharWidth;

if (sz.cx > dx)
dx = sz.cx;
}
// Select the old font back into the DC
pDC->SelectObject(pOldFont);
m_pComboBox->ReleaseDC(pDC);

// Adjust the width for the vertical scroll bar and the left and right border.
dx += ::GetSystemMetrics(SM_CXVSCROLL) + 2*::GetSystemMetrics(SM_CXEDGE);

// Set the width of the list box so that every item is completely visible.
m_pComboBox->SetDroppedWidth(dx);
muzizongheng 2010-08-13
  • 打赏
  • 举报
回复
GetSystemMetrics(SM_CXVSCROLL),
GetSystemMetrics(SM_CYHSCROLL)

给你一个自绘下拉框的例子


// Get the size of the scroll box
CSize sizeScroll(GetSystemMetrics(SM_CXVSCROLL), GetSystemMetrics(SM_CYHSCROLL));

// enough room to draw?
if (sizeScroll.cy < rect.Width() && sizeScroll.cy < rect.Height())
{
// Draw control at RHS of cell
CRect ScrollRect = rect;
ScrollRect.left = rect.right - sizeScroll.cx;
ScrollRect.bottom = rect.top + sizeScroll.cy;

// Do the draw
pDC->DrawFrameControl(ScrollRect, DFC_SCROLL, DFCS_SCROLLDOWN);

// Adjust the remaining space in the cell
rect.right = ScrollRect.left;
}
m_tornado 2010-08-12
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 luxiaolai861227 的回复:]

自己去资源界面上把它拉长点就行了!
[/Quote]

最直接,可能不精确~
pjl110 2010-08-12
  • 打赏
  • 举报
回复
liuhaifeng1976 2010-08-12
  • 打赏
  • 举报
回复
GetSystemMetrics获得下拉列表的宽度
Eleven 2010-08-12
  • 打赏
  • 举报
回复
CComboBox中的CEdit框的高度:
int nEditHeight = CComboBox::GetItemHeight(-1);

CComboBox中的CListBox框的高度:
CRect rc;
CComboBox::GetClientRect(rc);
int nListBoxHeight = rc.Height() - nEditHeight;
处处留心 2010-08-12
  • 打赏
  • 举报
回复
自己去资源界面上把它拉长点就行了!
ruoge2007 2010-08-12
  • 打赏
  • 举报
回复
最好知道其大小。宽度和高度

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧