欢迎来到天天文库
浏览记录
ID:12764171
大小:41.00 KB
页数:13页
时间:2018-07-18
《复选框的下拉列表》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、用自定义的CCheckComboBox类做带复选框的下拉列表1、添加ComboBox控件2.、改属性Style:DropList ; OwnerDraw:Fixed; Hasstring:true;Sort:false3、头文件中添加: CCheckComboBoxm_comboBox;4、DoDataExchange(CDataExchange*pDX)中添加: DDX_Control(pDX,IDC_COMBO1,m_comboBox);5、对话框初始化时添加 m_comboBox.AddStri
2、ng(_T("1"));//加入项目 m_comboBox.AddString(_T("2")); m_comboBox.AddString(_T("3")); m_comboBox.AddString(_T("4")); m_comboBox.SetCheck(0,TRUE);//设置选择状态 m_comboBox.SetCheck(1,FALSE); m_comboBox.SetCheck(2,TRUE); m_comboBox.SetCheck(3,TRUE); #if!defin
3、ed(AFX_CHECKCOMBOBOX_H__66750D93_95DB_11D3_9325_444553540000__INCLUDED_)#defineAFX_CHECKCOMBOBOX_H__66750D93_95DB_11D3_9325_444553540000__INCLUDED_#if_MSC_VER>1000#pragmaonce#endif//_MSC_VER>1000classCCheckComboBox:publicCComboBox{public:CCheckComboBox();virtual~
4、CCheckComboBox();BOOLCreate(DWORDdwStyle,constRECT&rect,CWnd*pParentWnd,UINTnID);//Selectsall/unselectsthespecifieditemINTSetCheck(INTnIndex,BOOLbFlag);//ReturnscheckedstateBOOLGetCheck(INTnIndex);//Selectsall/unselectsallvoidSelectAll(BOOLbCheck=TRUE);protected:
5、//ClassWizardgeneratedvirtualfunctionoverrides//{{AFX_VIRTUAL(CCheckComboBox)protected:virtualvoidDrawItem(LPDRAWITEMSTRUCTlpDrawItemStruct);virtualvoidMeasureItem(LPMEASUREITEMSTRUCTlpMeasureItemStruct);//}}AFX_VIRTUAL//{{AFX_MSG(CCheckComboBox)afx_msgLRESULTOnC
6、tlColorListBox(WPARAMwParam,LPARAMlParam);afx_msgLRESULTOnGetText(WPARAMwParam,LPARAMlParam);afx_msgLRESULTOnGetTextLength(WPARAMwParam,LPARAMlParam);afx_msgvoidOnDropDown();//}}AFX_MSGDECLARE_MESSAGE_MAP()public: CStringm_strText;protected://Routinetoupdatethet
7、extvoidRecalcText();//ThesubclassedCOMBOLBOXwindow(noticethe'L')HWNDm_hListBox;//ThestringcontainingthetexttodisplayBOOLm_bTextUpdated;//AflagusedinMeasureItem,seecommentsthereBOOLm_bItemHeightSet;};////////////////////////////////////////////////////////////////
8、///////////////{{AFX_INSERT_LOCATION}}//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.#endif//!defined(AFX_CHECKCOMBOBOX_H
此文档下载收益归作者所有