my codes was run normally! if possible, please send your more codes *.h ---------------------------------------- class AFX_EXT_CLASS CLineStyleComboBox : public CComboBox { protected: virtual void MeasureItem( LPMEASUREITEMSTRUCT lpMIS); virtual void DrawItem( LPDRAWITEMSTRUCT lpDIS); virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCIS); //{{AFX_MSG(CLineStyleComboBox) afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct ); //}}AFX_MSG DECLARE_MESSAGE_MAP() public: void AddStyleItem(int Style) { AddString((LPCTSTR)Style);} int SelectItem(int Style); }; *.cpp ---------------------------------------- #define LSTYLE_ITEM_HEIGHT 18 BEGIN_MESSAGE_MAP(CLineStyleComboBox, CComboBox) //{{AFX_MSG_MAP(CLineStyleComboBox) ON_WM_CREATE() //}}AFX_MSG_MAP END_MESSAGE_MAP() int CLineStyleComboBox::OnCreate( LPCREATESTRUCT lpCreateStruct ) { int nRet = CComboBox::OnCreate(lpCreateStruct); if( nRet==-1 ) return nRet; static int styles[] = { PS_SOLID,PS_DASH,PS_DOT,PS_DASHDOT,PS_DASHDOTDOT,PS_NULL }; for(int i=0;iitemHeight = LSTYLE_ITEM_HEIGHT; } void CLineStyleComboBox::DrawItem(LPDRAWITEMSTRUCT lpDIS) { CDC* pDC = CDC::FromHandle(lpDIS->hDC); COLORREF Color = (lpDIS->itemState & ODS_SELECTED)?RGB(0xff,0,0):RGB(0,0,0); int nPenStyle = int(lpDIS->itemData); CPen Pen( nPenStyle,1, Color ); CPen * pOldPen = pDC->SelectObject( &Pen ); pDC->SetBkMode(TRANSPARENT); int y = (lpDIS->rcItem.top+lpDIS->rcItem.bottom)>>1; pDC->MoveTo( lpDIS->rcItem.left,y ); pDC->LineTo( lpDIS->rcItem.right,y ); pDC->SelectObject( pOldPen ); } int CLineStyleComboBox::CompareItem(LPCOMPAREITEMSTRUCT lpCIS) { return int(lpCIS->itemData1)-int(lpCIS->itemData2); } int CLineStyleComboBox::SelectItem(int Style) { int n = GetCount(); for(int i=0;i