如何在combobox中加入不同类型的线条? 如何在combobox中加入不同类型的线条 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是不是还得重载DrawItem,还得处理WM_DRAWITEM,可是不知道如何具体实现啊 百度吧,网上重绘combobox的示例多的很 void CShowComboBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) {// TODO: Add your code to determine the size of specified itemlpMeasureItemStruct->itemHeight = CComboBox::GetItemHeight(0);}void CShowComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) //combobo{// TODO: Add your code to draw the specified item CDC *pDC=CDC::FromHandle(lpDrawItemStruct->hDC);int nSaveDC=pDC->SaveDC();CRect itemRect = lpDrawItemStruct->rcItem;int nItem = lpDrawItemStruct->itemID; if(lpDrawItemStruct->itemAction & ODA_DRAWENTIRE){ DrawItemBk(pDC,itemRect,nItem, CS_NORMAL); //画正常状态item的背景 DrawItemImage(pDC,itemRect,nItem,GetItemImage(nItem),CS_NORMAL); DrawItemText(pDC,itemRect,nItem,CS_NORMAL);//画正常状态item文if(!GetItemDisable(nItem)) {DrawItemBk(pDC,itemRect,nItem,CS_DISABLED);DrawItemImage(pDC,itemRect,nItem,GetItemImage(nItem),CS_DISABLED);DrawItemText(pDC,itemRect,nItem,CS_DISABLED);}}if((lpDrawItemStruct->itemState & ODS_SELECTED) && (lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) ){DrawItemBk(pDC,itemRect,nItem,CS_HOT);DrawItemImage(pDC,itemRect,nItem,GetItemImage(nItem),CS_HOT);DrawItemText(pDC,itemRect,nItem,CS_HOT);}if(!(lpDrawItemStruct->itemState & ODS_SELECTED) && (lpDrawItemStruct->itemAction & ODA_SELECT ) ){DrawItemBk(pDC,itemRect,nItem,CS_SELECT);DrawItemImage(pDC,itemRect,nItem,GetItemImage(nItem),CS_SELECT);DrawItemText(pDC,itemRect,nItem,CS_SELECT);}pDC->RestoreDC(nSaveDC);}void CShowComboBox::OnPaint(),多处理OnPaint主要是处理edit/static的部分,上边的drawitem是只能处理list中的.{CPaintDC dc(this); // device context for paintingCRect rectBk;GetClientRect(rectBk);DrawBorder(&dc,rectBk,GetComboState());DrawBackGround(&dc,rectBk,GetComboState());DrawDownButton(&dc,rectBk,GetComboState()); //与按钮一样,有正常,HOT,按下和非激活状态if ( CComboBox::GetCount() >0 && CComboBox::GetCurSel() >= 0 ){ int nState = CS_NORMAL;int nItem = CComboBox::GetCurSel();GetComboState()== CS_SELECT ? nState = CS_DISABLED : nState = CS_NORMAL ;CString strItemText = "" ;GetLBText(nItem,strItemText);DrawItemText(&dc,rectBk,nItem,strItemText,nState);DrawItemImage(&dc,rectBk,nItem,GetItemImage(nItem),nState);}}由于,设置重绘的combobox,在EDIT/STATIC的部分,高度很难看,所以可以用CComboBox::SetItemHeight(-1, 13)来设置一下可以放在PreSubclassWindow中,不然太高了,难看.可以扩展,下拉列表框带列头, 支持多列,支持disiable等.稍做变动便可. 谁能给个比较好一点的VC++开发论坛吗 如何实现编辑框不可用而滚动条可用? 关于GridCtrl控件的保存问题?........... 读注注册表问题(附代码) socket中 FD_ISSET宏的作用?见代码 thanks for your help! 有个问题问一下阿,在鼠标钩子的回调函数中,怎么取得鼠标的坐标阿 是否可以调用被集合的内部组件? 在Service我想创建一个线程实现定时调用我的COM方法,为什么我不能在我的线程里边创建我的COM对象? 请问在SDI中如何建立控件与变量的关联? MFC 点击一个编辑框弹出一个对话框 如何比较两个IXMLDOMNode是否相等?
void CShowComboBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
// TODO: Add your code to determine the size of specified item
lpMeasureItemStruct->itemHeight = CComboBox::GetItemHeight(0);
}void CShowComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) //combobo
{
// TODO: Add your code to draw the specified item
CDC *pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
int nSaveDC=pDC->SaveDC();
CRect itemRect = lpDrawItemStruct->rcItem;
int nItem = lpDrawItemStruct->itemID;
if(lpDrawItemStruct->itemAction & ODA_DRAWENTIRE)
{
DrawItemBk(pDC,itemRect,nItem, CS_NORMAL); //画正常状态item的背景
DrawItemImage(pDC,itemRect,nItem,GetItemImage(nItem),CS_NORMAL);
DrawItemText(pDC,itemRect,nItem,CS_NORMAL);//画正常状态item文if(!GetItemDisable(nItem))
{
DrawItemBk(pDC,itemRect,nItem,CS_DISABLED);
DrawItemImage(pDC,itemRect,nItem,GetItemImage(nItem),CS_DISABLED);
DrawItemText(pDC,itemRect,nItem,CS_DISABLED);
}
}if((lpDrawItemStruct->itemState & ODS_SELECTED) &&
(lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) )
{
DrawItemBk(pDC,itemRect,nItem,CS_HOT);
DrawItemImage(pDC,itemRect,nItem,GetItemImage(nItem),CS_HOT);
DrawItemText(pDC,itemRect,nItem,CS_HOT);
}if(!(lpDrawItemStruct->itemState & ODS_SELECTED) &&
(lpDrawItemStruct->itemAction & ODA_SELECT ) )
{
DrawItemBk(pDC,itemRect,nItem,CS_SELECT);
DrawItemImage(pDC,itemRect,nItem,GetItemImage(nItem),CS_SELECT);
DrawItemText(pDC,itemRect,nItem,CS_SELECT);
}pDC->RestoreDC(nSaveDC);
}void CShowComboBox::OnPaint(),多处理OnPaint主要是处理edit/static的部分,上边的drawitem是只能处理list中的.
{
CPaintDC dc(this); // device context for painting
CRect rectBk;
GetClientRect(rectBk);DrawBorder(&dc,rectBk,GetComboState());
DrawBackGround(&dc,rectBk,GetComboState());
DrawDownButton(&dc,rectBk,GetComboState()); //与按钮一样,有正常,HOT,按下和非激活状态if ( CComboBox::GetCount() >0 && CComboBox::GetCurSel() >= 0 )
{
int nState = CS_NORMAL;
int nItem = CComboBox::GetCurSel();
GetComboState()== CS_SELECT ? nState = CS_DISABLED : nState = CS_NORMAL ;
CString strItemText = "" ;
GetLBText(nItem,strItemText);
DrawItemText(&dc,rectBk,nItem,strItemText,nState);
DrawItemImage(&dc,rectBk,nItem,GetItemImage(nItem),nState);
}
}
由于,设置重绘的combobox,在EDIT/STATIC的部分,高度很难看,所以可以用CComboBox::SetItemHeight(-1, 13)来设置一下可以放在PreSubclassWindow中,不然太高了,难看.可以扩展,下拉列表框带列头, 支持多列,支持disiable等.稍做变动便可.