SDI程序,重画菜单的时候,MeasureItem 函数错误!

pig1210127 2004-07-06 09:14:29
void CMenuEx::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
CMenuItemContext * pItem = (CMenuItemContext *)(lpMeasureItemStruct->itemData);
if (pItem->nMenuID == 0) //错误
lpMeasureItemStruct->itemHeight = 10;
else
{
CDC * pDC = AfxGetMainWnd()->GetDC();

CString strText = pItem->strText;
CSize size;

size = pDC->GetTextExtent(pItem->strText);

lpMeasureItemStruct->itemWidth = size.cx + 4;
lpMeasureItemStruct->itemHeight = size.cy + 4;

AfxGetMainWnd()->ReleaseDC(pDC);
}
}

struct CMenuItemContext
{
public:
CString strText;
UINT nMenuID;
UINT U;
};
...全文
56 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

15,979

社区成员

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

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