Exemplo n.º 1
0
BOOL CConsoleCombo::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class

	if (pMsg->message == WM_KEYDOWN)
	{
		CString str;				
		int nVirtKey = (int) pMsg->wParam;

		
		switch (nVirtKey)
		{
		//checks if up arrow key is pressed
		case VK_UP:
			
			//if this is first position save current text
			if (m_nPos == -1)
			{
				GetWindowText(str);
				m_current = str;
			}

			
			//makes sure an invalid position isn't going to be set
			if (m_nPos + 1 < GetCount())
			{				
				//increase position
				m_nPos++;
				//get text at current position display it highlighted
				GetLBText(m_nPos, str);
				SetWindowText(str);
				SetEditSel(0, str.GetLength());									
				
			}

			
			return TRUE;
		
		case VK_DOWN:
			
			//if going back to bottem restore previously entered text
			if (m_nPos - 1 == -1)
			{
				SetWindowText(m_current);
				SetEditSel(m_current.GetLength(), m_current.GetLength());
				m_nPos = -1;
			}
			
			if (m_nPos - 1 >= 0)
			{
								
				//decrease position
				m_nPos--;
				//get text at current position display it highlighted
				GetLBText(m_nPos, str);
				SetWindowText(str);
				SetEditSel(0, str.GetLength());								
				
			}
			return TRUE;
		
		//if enter key is pressed do following
		case VK_RETURN:
			
			GetWindowText(str);
			
			//make sure there is something input
			if (str != _T(""))
			{			
				//add string to the bottem of the list
				InsertString(0, str);
				m_nPos = -1;
				SetWindowText(_T(""));

				//function that must be customized for each program				
				ParseCommand(str);

			}
			break;
		
		}

		
		
	}
	
	return CComboBox::PreTranslateMessage(pMsg);
}
void CXTPSyntaxEditColorComboBox::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
	CDC*  pDC       = CDC::FromHandle(lpDIS->hDC);
	UINT  itemState = lpDIS->itemState;
	UINT  itemID    = lpDIS->itemID;
	CRect rcItem    = lpDIS->rcItem;

	if (itemID == (UINT)-1)
	{
		return;
	}

	BOOL bDisabled = ((itemState & ODS_DISABLED) == ODS_DISABLED);
	BOOL bSelected = ((itemState & ODS_SELECTED) == ODS_SELECTED);
	BOOL bFocus    = ((itemState & ODS_FOCUS)    == ODS_FOCUS);

	// draw background.
	if (bDisabled)
	{
		pDC->SetTextColor(GetXtremeColor(COLOR_GRAYTEXT));
		pDC->SetBkColor(GetXtremeColor(COLOR_3DFACE));
		pDC->FillSolidRect(&rcItem, GetXtremeColor(COLOR_3DFACE));
	}
	else
	{
		if (bSelected)
		{
			pDC->SetTextColor(GetXtremeColor(COLOR_HIGHLIGHTTEXT));
			pDC->SetBkColor(GetXtremeColor(COLOR_WINDOW));
			pDC->FillSolidRect(&rcItem, GetXtremeColor(COLOR_HIGHLIGHT));
		}
		else
		{
			pDC->SetTextColor(GetXtremeColor(COLOR_WINDOWTEXT));
			pDC->SetBkColor(GetXtremeColor(COLOR_WINDOW));
			pDC->FillSolidRect(&rcItem, GetXtremeColor(COLOR_WINDOW));
		}

		// draw focus rectangle.
		if (bFocus)
		{
			pDC->DrawFocusRect(&rcItem);
		}
	}

	// determine the size of the color rectangle.
	CRect rColor(rcItem);
	rColor.DeflateRect(2,2);
	rColor.right = rColor.left + COLOR_ITEM_WIDTH;
	rColor.bottom = rColor.top + COLOR_ITEM_WIDTH;

	// draw color rectangle.
	pDC->FillSolidRect(rColor,
		bDisabled? GetXtremeColor(COLOR_3DFACE): (COLORREF)lpDIS->itemData);

	pDC->Draw3dRect(rColor,
		GetXtremeColor(bDisabled? COLOR_GRAYTEXT: COLOR_WINDOWTEXT),
		GetXtremeColor(bDisabled? COLOR_GRAYTEXT: COLOR_WINDOWTEXT));

	// determine the size of the text display.
	CRect rText(rColor);
	rText.top -= 2;
	rText.bottom = rText.top + (::GetSystemMetrics(SM_CYVTHUMB)-::GetSystemMetrics(SM_CYEDGE));
	rText.left = rText.right + 4;
	rText.right = rcItem.right;

	// draw text.
	CString csItemText;
	GetLBText(itemID, csItemText);
	if (!csItemText.IsEmpty())
	{
		pDC->SetBkMode(TRANSPARENT);
		pDC->DrawText(csItemText, rText, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	}
}
Exemplo n.º 3
0
void CColorComboBox::DrawItem(LPDRAWITEMSTRUCT lpDIS) 
{
	CDC* pDC = CDC::FromHandle (lpDIS->hDC);
	ASSERT_VALID (pDC);

	CRect rect = lpDIS->rcItem;
	int nIndex = lpDIS->itemID;

	COLORREF	clText;
	CBrush*		pBrush = NULL;

	if (lpDIS->itemState & ODS_SELECTED)  
	{
		clText = globalData.clrTextHilite; 
		pBrush = &globalData.brHilite;
	} 
	else 
	{
		pBrush = &globalData.brWindow;
		clText = globalData.clrWindowText;
	} 

	if (lpDIS->itemAction & (ODA_DRAWENTIRE | ODA_SELECT))
	{
		pDC->FillRect (rect, pBrush);
	}

	if (nIndex < 0)
	{
		return;
	}

	CString strLabel;
	GetLBText (nIndex, strLabel);

	CRect rectBox = rect;
	rectBox.DeflateRect (nMargin, nMargin);
	
	if (!strLabel.IsEmpty ())
	{
		rectBox.right = rectBox.left + rectBox.Height ();
	}

	COLORREF color = GetColor (nIndex);

	CBrush br (color);
	pDC->FillRect (rectBox, &br);
	pDC->Draw3dRect (rectBox, globalData.clrWindowText, globalData.clrWindowText);

	if (!strLabel.IsEmpty ())
	{
		CFont* pOldFont = pDC->SelectObject (&globalData.fontRegular);

		pDC->SetBkMode (TRANSPARENT);
		pDC->SetTextColor (clText);

		CRect rectText = rect;
		rectText.left = rectBox.right + 2 * nMargin;

		pDC->DrawText (strLabel, rectText, DT_SINGLELINE | DT_VCENTER);

		pDC->SelectObject (pOldFont);
	}
}
Exemplo n.º 4
0
INT_PTR CALLBACK ConfigureBitmapTransitionProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
        case WM_INITDIALOG:
            {
                ConfigBitmapInfo *configInfo = (ConfigBitmapInfo*)lParam;
                SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)configInfo);
                LocalizeWindow(hwnd);

                //--------------------------

                HWND hwndTemp = GetDlgItem(hwnd, IDC_BITMAPS);

                StringList bitmapList;
                configInfo->data->GetStringList(TEXT("bitmap"), bitmapList);
                for(UINT i=0; i<bitmapList.Num(); i++)
                {
                    CTSTR lpBitmap = bitmapList[i];

                    if(OSFileExists(lpBitmap))
                        SendMessage(hwndTemp, LB_ADDSTRING, 0, (LPARAM)lpBitmap);
                }

                //--------------------------

                hwndTemp = GetDlgItem(hwnd, IDC_TRANSITIONTIME);

                UINT transitionTime = configInfo->data->GetInt(TEXT("transitionTime"));
                SendMessage(hwndTemp, UDM_SETRANGE32, MIN_TRANSITION_TIME, MAX_TRANSITION_TIME);

                if(!transitionTime)
                    transitionTime = 10;

                SendMessage(hwndTemp, UDM_SETPOS32, 0, transitionTime);

                EnableWindow(GetDlgItem(hwnd, IDC_REPLACE), FALSE);
                EnableWindow(GetDlgItem(hwnd, IDC_REMOVE), FALSE);
                EnableWindow(GetDlgItem(hwnd, IDC_MOVEUPWARD), FALSE);
                EnableWindow(GetDlgItem(hwnd, IDC_MOVEDOWNWARD), FALSE);

                //--------------------------

                BOOL bFadeInOnly = configInfo->data->GetInt(TEXT("fadeInOnly"), 1);
                BOOL bDisableFading = configInfo->data->GetInt(TEXT("disableFading"));
                BOOL bRandomize = configInfo->data->GetInt(TEXT("randomize"));
                SendMessage(GetDlgItem(hwnd, IDC_FADEINONLY), BM_SETCHECK, bFadeInOnly ? BST_CHECKED : BST_UNCHECKED, 0);
                SendMessage(GetDlgItem(hwnd, IDC_DISABLEFADING), BM_SETCHECK, bDisableFading ? BST_CHECKED : BST_UNCHECKED, 0);
                SendMessage(GetDlgItem(hwnd, IDC_RANDOMIZE), BM_SETCHECK, bRandomize ? BST_CHECKED : BST_UNCHECKED, 0);
                
                
                EnableWindow(GetDlgItem(hwnd, IDC_FADEINONLY), !bDisableFading);

                return TRUE;
            }

        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case IDC_ADD:
                    {
                        TSTR lpFile = (TSTR)Allocate(32*1024*sizeof(TCHAR));
                        zero(lpFile, 32*1024*sizeof(TCHAR));

                        OPENFILENAME ofn;
                        zero(&ofn, sizeof(ofn));
                        ofn.lStructSize = sizeof(ofn);
                        ofn.lpstrFile = lpFile;
                        ofn.hwndOwner = hwnd;
                        ofn.nMaxFile = 32*1024*sizeof(TCHAR);
                        ofn.lpstrFilter = TEXT("All Formats (*.bmp;*.dds;*.jpg;*.png;*.gif)\0*.bmp;*.dds;*.jpg;*.png;*.gif\0");
                        ofn.nFilterIndex = 1;
                        ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER;

                        TCHAR curDirectory[MAX_PATH+1];
                        GetCurrentDirectory(MAX_PATH, curDirectory);

                        BOOL bOpenFile = GetOpenFileName(&ofn);

                        TCHAR newDirectory[MAX_PATH+1];
                        GetCurrentDirectory(MAX_PATH, newDirectory);

                        SetCurrentDirectory(curDirectory);

                        if(bOpenFile)
                        {
                            TSTR lpCurFile = lpFile+ofn.nFileOffset;

                            while(lpCurFile && *lpCurFile)
                            {
                                String strPath;
                                strPath << newDirectory << TEXT("\\") << lpCurFile;

                                SendMessage(GetDlgItem(hwnd, IDC_BITMAPS), LB_ADDSTRING, 0, (LPARAM)strPath.Array());

                                lpCurFile += slen(lpCurFile)+1;
                            }
                        }

                        Free(lpFile);

                        break;
                    }

                case IDC_BITMAPS:
                    if(HIWORD(wParam) == LBN_SELCHANGE)
                    {
                        EnableWindow(GetDlgItem(hwnd, IDC_REPLACE), TRUE);
                        EnableWindow(GetDlgItem(hwnd, IDC_REMOVE), TRUE);
                        EnableWindow(GetDlgItem(hwnd, IDC_MOVEUPWARD), TRUE);
                        EnableWindow(GetDlgItem(hwnd, IDC_MOVEDOWNWARD), TRUE);
                    }
                    break;

                case IDC_REMOVE:
                    {
                        UINT curSel = (UINT)SendMessage(GetDlgItem(hwnd, IDC_BITMAPS), LB_GETCURSEL, 0, 0);
                        if(curSel != LB_ERR)
                        {
                            SendMessage(GetDlgItem(hwnd, IDC_BITMAPS), LB_DELETESTRING, curSel, 0);
                            EnableWindow(GetDlgItem(hwnd, IDC_REPLACE), FALSE);
                            EnableWindow(GetDlgItem(hwnd, IDC_REMOVE), FALSE);
                            EnableWindow(GetDlgItem(hwnd, IDC_MOVEUPWARD), FALSE);
                            EnableWindow(GetDlgItem(hwnd, IDC_MOVEDOWNWARD), FALSE);
                        }
                    }
                    break;

                case IDC_MOVEUPWARD:
                    {
                        HWND hwndBitmaps = GetDlgItem(hwnd, IDC_BITMAPS);
                        UINT curSel = (UINT)SendMessage(hwndBitmaps, LB_GETCURSEL, 0, 0);
                        if(curSel != LB_ERR)
                        {
                            if(curSel > 0)
                            {
                                String strText = GetLBText(hwndBitmaps, curSel);

                                SendMessage(hwndBitmaps, LB_DELETESTRING, curSel, 0);
                                SendMessage(hwndBitmaps, LB_INSERTSTRING, --curSel, (LPARAM)strText.Array());
                                PostMessage(hwndBitmaps, LB_SETCURSEL, curSel, 0);
                            }
                        }
                    }
                    break;

                case IDC_MOVEDOWNWARD:
                    {
                        HWND hwndBitmaps = GetDlgItem(hwnd, IDC_BITMAPS);

                        UINT numBitmaps = (UINT)SendMessage(hwndBitmaps, LB_GETCOUNT, 0, 0);
                        UINT curSel = (UINT)SendMessage(hwndBitmaps, LB_GETCURSEL, 0, 0);
                        if(curSel != LB_ERR)
                        {
                            if(curSel < (numBitmaps-1))
                            {
                                String strText = GetLBText(hwndBitmaps, curSel);

                                SendMessage(hwndBitmaps, LB_DELETESTRING, curSel, 0);
                                SendMessage(hwndBitmaps, LB_INSERTSTRING, ++curSel, (LPARAM)strText.Array());
                                PostMessage(hwndBitmaps, LB_SETCURSEL, curSel, 0);
                            }
                        }
                    }
                    break;

                case IDC_DISABLEFADING:
                    {
                        BOOL bDisableFading = SendMessage(GetDlgItem(hwnd, IDC_DISABLEFADING), BM_GETCHECK, 0, 0) == BST_CHECKED;
                        EnableWindow(GetDlgItem(hwnd, IDC_FADEINONLY), !bDisableFading);
                    }
                    break;

                case IDOK:
                    {
                        HWND hwndBitmaps = GetDlgItem(hwnd, IDC_BITMAPS);

                        UINT numBitmaps = (UINT)SendMessage(hwndBitmaps, LB_GETCOUNT, 0, 0);
                        if(!numBitmaps)
                        {
                            OBSMessageBox(hwnd, Str("Sources.TransitionSource.Empty"), NULL, 0);
                            break;
                        }

                        //---------------------------

                        StringList bitmapList;
                        for(UINT i=0; i<numBitmaps; i++)
                            bitmapList << GetLBText(hwndBitmaps, i);

                        ConfigBitmapInfo *configInfo = (ConfigBitmapInfo*)GetWindowLongPtr(hwnd, DWLP_USER);

                        D3DX10_IMAGE_INFO ii;
                        if(SUCCEEDED(D3DX10GetImageInfoFromFile(bitmapList[0], NULL, &ii, NULL)))
                        {
                            configInfo->cx = ii.Width;
                            configInfo->cy = ii.Height;
                        }
                        else
                        {
                            configInfo->cx = configInfo->cy = 32;
                            AppWarning(TEXT("ConfigureBitmapTransitionSource: could not get image info for bitmap '%s'"), bitmapList[0].Array());
                        }

                        configInfo->data->SetStringList(TEXT("bitmap"), bitmapList);

                        UINT transitionTime = (UINT)SendMessage(GetDlgItem(hwnd, IDC_TRANSITIONTIME), UDM_GETPOS32, 0, 0);
                        configInfo->data->SetInt(TEXT("transitionTime"), transitionTime);

                        BOOL bFadeInOnly = SendMessage(GetDlgItem(hwnd, IDC_FADEINONLY), BM_GETCHECK, 0, 0) == BST_CHECKED;
                        BOOL bDisableFading = SendMessage(GetDlgItem(hwnd, IDC_DISABLEFADING), BM_GETCHECK, 0, 0) == BST_CHECKED;
                        BOOL bRandomize = SendMessage(GetDlgItem(hwnd, IDC_RANDOMIZE), BM_GETCHECK, 0, 0) == BST_CHECKED;
                        configInfo->data->SetInt(TEXT("fadeInOnly"), bFadeInOnly);
                        configInfo->data->SetInt(TEXT("disableFading"), bDisableFading);
                        configInfo->data->SetInt(TEXT("randomize"), bRandomize);
                    }

                case IDCANCEL:
                    EndDialog(hwnd, LOWORD(wParam));
                    break;
            }
            break;
    }

    return 0;
}
void CPrimitiveHistoryCombo::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
  INDEX iItem = lpDrawItemStruct->itemID;
  BOOL bSelected = lpDrawItemStruct->itemState & (ODS_FOCUS|ODS_SELECTED);
  COLORREF clrfBcgColor;
  UINT ulEdgeType;
  if( bSelected)
  {
    clrfBcgColor = CLRF_CLR( 0xDFDFFF00UL); 
    ulEdgeType = EDGE_SUNKEN;
  }
  else
  {
    clrfBcgColor = CLRF_CLR( C_WHITE);
    ulEdgeType = EDGE_RAISED;
  }
  
  CValuesForPrimitive *pVFP = (CValuesForPrimitive *) GetItemData( iItem);
  if( (ULONG) pVFP == CB_ERR) return;

  CDC *pDC = CDC::FromHandle( lpDrawItemStruct->hDC);
  RECT rectItem = lpDrawItemStruct->rcItem;
  pDC->SetBkMode( TRANSPARENT);
  pDC->SetBkColor( clrfBcgColor);
  pDC->FillSolidRect( &rectItem, clrfBcgColor);
  
  // polygon color
  RECT rectPolygon = rectItem;
  rectPolygon.top+=1;
  rectPolygon.bottom-=1;
  rectPolygon.left += 2;
  rectPolygon.right = rectPolygon.left+16;
  COLORREF clrfColor = CLRF_CLR( pVFP->vfp_colPolygonsColor);
  pDC->FillSolidRect( &rectPolygon, clrfColor);

  // sector color
  RECT rectSector = rectPolygon;
  rectSector.left += 16;
  rectSector.right += 16;
  clrfColor = CLRF_CLR( pVFP->vfp_colSectorsColor);
  pDC->FillSolidRect( &rectSector, clrfColor);

  RECT rectBorder = rectPolygon;
  rectBorder.right += 16;
  pDC->DrawEdge( &rectBorder, ulEdgeType, BF_RECT);

  // used for rendering from left to right
  PIX pixCursor = 38;
  
  UINT uiPrimitiveIconID;
  switch( pVFP->vfp_ptPrimitiveType)
  {
  case PT_CONUS:{       uiPrimitiveIconID = IDR_ICON_CONUS; break;}
  case PT_TORUS:{       uiPrimitiveIconID = IDR_ICON_TORUS; break;}
  case PT_STAIRCASES:
    {
    if( pVFP->vfp_bLinearStaircases) uiPrimitiveIconID = IDR_ICON_LINEAR_STAIRCASES;
    else                             uiPrimitiveIconID = IDR_ICON_SPIRAL_STAIRCASES; 
    break;
    }
  case PT_SPHERE:{      uiPrimitiveIconID = IDR_ICON_SPHERE; break;}
  case PT_TERRAIN:{     uiPrimitiveIconID = IDR_ICON_TERRAIN; break;}
  }
  HICON hPrimitiveIcon = theApp.LoadIcon( uiPrimitiveIconID);
  pDC->DrawIcon( pixCursor, rectItem.top, hPrimitiveIcon);
  pixCursor += 22;

  UINT uiPrimitiveOperationID;
  switch( pVFP->vfp_csgtCSGOperation)
  {
  case CSG_ADD: {             uiPrimitiveOperationID = IDR_ICON_ADD; break;}
  case CSG_ADD_REVERSE: {     uiPrimitiveOperationID = IDR_ICON_ADD_REVERSE; break;}
  case CSG_REMOVE:  {         uiPrimitiveOperationID = IDR_ICON_REMOVE; break;}
  case CSG_REMOVE_REVERSE:  { uiPrimitiveOperationID = IDR_ICON_REMOVE_REVERSE; break;}
  case CSG_SPLIT_SECTORS: {   uiPrimitiveOperationID = IDR_ICON_SPLIT_SECTORS; break;}
  case CSG_SPLIT_POLYGONS:  { uiPrimitiveOperationID = IDR_ICON_SPLIT_POLYGONS; break;}
  case CSG_JOIN_LAYERS: {     uiPrimitiveOperationID = IDR_ICON_JOIN_LAYERS; break;}
  }
  HICON hOperationIcon = theApp.LoadIcon( uiPrimitiveOperationID);
  pDC->DrawIcon( pixCursor, rectItem.top, hOperationIcon);
  pixCursor += 22;

  HICON hRoomIcon;
  if( pVFP->vfp_bClosed) hRoomIcon = theApp.LoadIcon( IDR_ICON_ROOM);
  else                   hRoomIcon = theApp.LoadIcon( IDR_ICON_MATERIAL);
  pDC->DrawIcon( pixCursor, rectItem.top, hRoomIcon);
  pixCursor += 22;

  if( !pVFP->vfp_bOuter &&
      (pVFP->vfp_csgtCSGOperation != PT_SPHERE) &&
      (pVFP->vfp_csgtCSGOperation != PT_TERRAIN) )
  {
    HICON hOuterIcon;
    hOuterIcon = theApp.LoadIcon( IDR_ICON_INNER);
    pDC->DrawIcon( pixCursor, rectItem.top, hOuterIcon);
    pixCursor += 22;
  }

  if( pVFP->vfp_ptPrimitiveType == PT_STAIRCASES)
  {
    HICON hTopStairsIcon;
    if(      pVFP->vfp_iTopShape == 0) hTopStairsIcon = theApp.LoadIcon( IDR_ICON_TOP_STAIRS);
    else if( pVFP->vfp_iTopShape == 1) hTopStairsIcon = theApp.LoadIcon( IDR_ICON_TOP_SLOPE);
    else                               hTopStairsIcon = theApp.LoadIcon( IDR_ICON_TOP_CEILING);
    pDC->DrawIcon( pixCursor, rectItem.top, hTopStairsIcon);
    pixCursor += 22;

    HICON hBottomStairsIcon;
    if(      pVFP->vfp_iTopShape == 0) hBottomStairsIcon = theApp.LoadIcon( IDR_ICON_BOTTOM_STAIRS);
    else if( pVFP->vfp_iTopShape == 1) hBottomStairsIcon = theApp.LoadIcon( IDR_ICON_BOTTOM_SLOPE);
    else                               hBottomStairsIcon = theApp.LoadIcon( IDR_ICON_BOTTOM_FLOOR);
    pDC->DrawIcon( pixCursor, rectItem.top, hBottomStairsIcon);
    pixCursor += 22;
  }

  // obtain text of drawing item
  CString strText;
  GetLBText( iItem, strText);
  pDC->TextOut( pixCursor, rectItem.top, strText);
}
Exemplo n.º 6
0
void CCheckComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	HDC dc = lpDrawItemStruct->hDC;

	CRect rcBitmap = lpDrawItemStruct->rcItem;
	CRect rcText   = lpDrawItemStruct->rcItem;

	CString strText;

	
	INT nCheck = 0;

	
	if ((LONG)lpDrawItemStruct->itemID < 0) {
		
		RecalcText();

		
		strText = m_strText;

		
		nCheck = 0;
	}

	
	else {
		GetLBText(lpDrawItemStruct->itemID, strText);
		nCheck = 1 + (GetItemData(lpDrawItemStruct->itemID) != 0);

		TEXTMETRIC metrics;
		GetTextMetrics(dc, &metrics);

		rcBitmap.left    = 0;
		rcBitmap.right   = rcBitmap.left + metrics.tmHeight + metrics.tmExternalLeading + 6;
		rcBitmap.top    += 1;
		rcBitmap.bottom -= 1;

		rcText.left = rcBitmap.right;
	}
	
	 

	if (nCheck > 0) {
		SetBkColor(dc, GetSysColor(COLOR_WINDOW));
		SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));

		UINT nState = DFCS_BUTTONCHECK;

		if (nCheck > 1)
			nState |= DFCS_CHECKED;

		
		DrawFrameControl(dc, rcBitmap, DFC_BUTTON, nState);
	}

	if (lpDrawItemStruct->itemState & ODS_SELECTED) {
		SetBkColor(dc, GetSysColor(COLOR_HIGHLIGHT));
		SetTextColor(dc, GetSysColor(COLOR_HIGHLIGHTTEXT));
	}
	else {
		SetBkColor(dc, GetSysColor(COLOR_WINDOW));
		SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
	}

	
	ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rcText, 0, 0, 0);
	DrawText(dc, ' ' + strText, strText.GetLength() + 1, &rcText, DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS);

	if ((lpDrawItemStruct->itemState & (ODS_FOCUS|ODS_SELECTED)) == (ODS_FOCUS|ODS_SELECTED))
		DrawFocusRect(dc, &rcText);
	
}
Exemplo n.º 7
0
void CColourComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{

	if (lpDrawItemStruct->CtlType != ODT_COMBOBOX)
    return;


	CDC*	pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	CRect	rc = lpDrawItemStruct->rcItem;
  CString strText;

  int iItem = lpDrawItemStruct->itemID - 1;   // 0 is actually "no change" here

  if (lpDrawItemStruct->itemState  & ODS_DISABLED)
    {
		pDC->FillSolidRect(rc, RGB (192, 192, 192));  // grey background
    pDC->SetTextColor (RGB (0, 0, 0));    // black text
    }
  else
    {
    if (iItem >= 0 && iItem < MAX_CUSTOM)
      {
      // if same colour on itself, just show black on white
      if (m_customtext [iItem] == m_customback [iItem])
        {
		    pDC->FillSolidRect(rc, RGB (255, 255, 255));  // white background
        pDC->SetTextColor (RGB (0, 0, 0));    // black text
        }
      else
        {
		    // Draw colour
		    pDC->FillSolidRect(rc, m_customback [iItem]);
        pDC->SetTextColor (m_customtext [iItem]);
        }
      }    // end of custom colour (0 to 15)
    else if (iItem == OTHER_CUSTOM)
      {
      // if same colour on itself, just show black on white
      if (m_iOtherForeground == m_iOtherBackground)
        {
		    pDC->FillSolidRect(rc, RGB (255, 255, 255));  // white background
        pDC->SetTextColor (RGB (0, 0, 0));    // black text
        }
      else
        {
		    // Draw colour
		    pDC->FillSolidRect(rc, m_iOtherBackground);
        pDC->SetTextColor (m_iOtherForeground);
        }
      }  // end of "other" custom
    else
      {
		  pDC->FillSolidRect(rc, RGB (255, 255, 255));  // white background
      pDC->SetTextColor (RGB (0, 0, 0));    // black text
      }   // something else? (no change) for instance
    }   // not disabled

  // sometimes itemID is 0xFFFFFFFF it seems
  if (lpDrawItemStruct->itemID != UINT_MAX)
    {
    GetLBText(lpDrawItemStruct->itemID, strText);
    rc.left += 2;    // draw two pixels in
    pDC->DrawText (strText, rc, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
    rc.left -= 2;    // undo add above
    }

  // if it has the focus, draw a dotted line
  if (lpDrawItemStruct->itemState  & ODS_FOCUS)
    {
    CRect rcFocus (rc);
    rcFocus.DeflateRect (1, 1);
    pDC->DrawFocusRect (rcFocus); 
    }

	
}
Exemplo n.º 8
0
void CColourPickerCB::DrawItem( LPDRAWITEMSTRUCT pDIStruct )
{
	CString strColour;
	CDC dcContext;
	CRect rItemRect( pDIStruct->rcItem );
	CRect rBlockRect( rItemRect );
	CRect rTextRect( rBlockRect );
	CBrush brFrameBrush;
	int iFourthWidth = 0;
	int iItem = pDIStruct->itemID;
	int iAction = pDIStruct->itemAction;
	int iState = pDIStruct->itemState;
	COLORREF crColour = NULL;
	COLORREF crNormal = GetSysColor( COLOR_WINDOW );
	COLORREF crSelected = GetSysColor( COLOR_HIGHLIGHT );
	COLORREF crText = GetSysColor( COLOR_WINDOWTEXT );

	if( !dcContext.Attach( pDIStruct->hDC ) )
	{
		return;
	}

	iFourthWidth = ( rBlockRect.Width() / 4 );
	brFrameBrush.CreateStockObject( BLACK_BRUSH );

	if( iState & ODS_SELECTED )
	{
		dcContext.SetTextColor(	( 0x00FFFFFF & ~( crText ) ) );
		dcContext.SetBkColor( crSelected );
		dcContext.FillSolidRect( &rBlockRect, crSelected );
	}
	else
	{
		dcContext.SetTextColor( crText );
		dcContext.SetBkColor( crNormal );
		dcContext.FillSolidRect( &rBlockRect, crNormal );
	}

	if( iState & ODS_FOCUS )
	{
		dcContext.DrawFocusRect( &rItemRect );
	}

	// calculate text area.
	rTextRect.left += ( iFourthWidth + 2 );
	rTextRect.top += 2;

	// calculate colour block area.
	rBlockRect.DeflateRect( CSize( 2, 2 ) );
	rBlockRect.right = iFourthWidth;

	// draw colour text and block.
	if( iItem != -1 )
	{
		GetLBText( iItem, strColour );

		if( iState & ODS_DISABLED )
		{
			crColour = GetSysColor( COLOR_INACTIVECAPTIONTEXT );
			dcContext.SetTextColor( crColour );
		}
		else
		{
			crColour = (COLORREF)GetItemData( iItem );
		}

		dcContext.SetBkMode( TRANSPARENT );
		dcContext.TextOut( rTextRect.left, rTextRect.top,	strColour );

		dcContext.FillSolidRect( &rBlockRect, crColour );
				
		dcContext.FrameRect( &rBlockRect, &brFrameBrush );
	}

	dcContext.Detach();
}
Exemplo n.º 9
0
void CCheckComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	HDC dc = lpDrawItemStruct->hDC;

	CRect rcBitmap = lpDrawItemStruct->rcItem;
	CRect rcText   = lpDrawItemStruct->rcItem;

	CString strText;

	// 0 - No check, 1 - Empty check, 2 - Checked
	INT nCheck = 0;

	// Check if we are drawing the static portion of the combobox
	if ((LONG)lpDrawItemStruct->itemID < 0) {
		// Make sure the m_strText member is updated
		RecalcText();

		// Get the text
		strText = m_strText;

		// Don't draw any boxes on this item
		nCheck = 0;
	}

	// Otherwise it is one of the items
	else {
		GetLBText(lpDrawItemStruct->itemID, strText);
		nCheck = 1 + (GetItemData(lpDrawItemStruct->itemID) != 0);

		TEXTMETRIC metrics;
		GetTextMetrics(dc, &metrics);

		rcBitmap.left    = 0;
		rcBitmap.right   = rcBitmap.left + metrics.tmHeight + metrics.tmExternalLeading + 6;
		rcBitmap.top    += 1;
		rcBitmap.bottom -= 1;

		rcText.left = rcBitmap.right;
	}
	
	 

	if (nCheck > 0) {
		SetBkColor(dc, GetSysColor(COLOR_WINDOW));
		SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));

		UINT nState = DFCS_BUTTONCHECK;

		if (nCheck > 1)
			nState |= DFCS_CHECKED;

		// Draw the checkmark using DrawFrameControl
		DrawFrameControl(dc, rcBitmap, DFC_BUTTON, nState);
	}

	if (lpDrawItemStruct->itemState & ODS_SELECTED) {
		SetBkColor(dc, GetSysColor(COLOR_HIGHLIGHT));
		SetTextColor(dc, GetSysColor(COLOR_HIGHLIGHTTEXT));
	}
	else {
		SetBkColor(dc, GetSysColor(COLOR_WINDOW));
		SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
	}

	// Erase and draw
	ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rcText, 0, 0, 0);
	DrawText(dc, ' ' + strText, strText.GetLength() + 1, &rcText, DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS);

	if ((lpDrawItemStruct->itemState & (ODS_FOCUS|ODS_SELECTED)) == (ODS_FOCUS|ODS_SELECTED))
		DrawFocusRect(dc, &rcText);
	
}
Exemplo n.º 10
0
void CComboBox::GetLBText(int nIndex, CString& rString) const
{
	ASSERT(::IsWindow(m_hWnd));
	GetLBText(nIndex, rString.GetBufferSetLength(GetLBTextLen(nIndex)));
	rString.ReleaseBuffer();
}
Exemplo n.º 11
0
LONG CAdvComboBox::OnGetLBText( WPARAM wIndex, LPARAM lString )
{
	int nIndex = (int)wIndex;
	TCHAR* pOutStr = (TCHAR*)lString;
	return GetLBText( nIndex, pOutStr );
}
Exemplo n.º 12
0
void CKofBCGPFontComboBox::OnPaint()
{
	if ((GetStyle () & 0x0003L) == CBS_SIMPLE)
	{
		Default ();
		return;
	}

	if (!m_bVisualManagerStyle && !m_bOnGlass)
	{
		Default ();
		return;
	}

	CPaintDC dc(this); // device context for painting
	BYTE alpha = 0;
	if (m_bOnGlass)
	{
		alpha = 255;
	}
	CBCGPMemDC memDC (dc, this, alpha);
	CDC* pDC = &memDC.GetDC ();

	CRect rectClient;
	GetClientRect (rectClient);

	CBCGPDrawManager dm (*pDC);
	dm.DrawRect (rectClient, globalData.clrWindow, (COLORREF)-1);
//  得注释掉这句话
// 	SendMessage (WM_PRINTCLIENT, (WPARAM) pDC->GetSafeHdc (), (LPARAM) PRF_CLIENT);
	const int cxDropDown = ::GetSystemMetrics (SM_CXVSCROLL) + 4;

	int nCurSel = GetCurSel();
	if (CB_ERR != nCurSel)
	{
		if (m_Images.GetSafeHandle () == NULL)
		{
			CBCGPLocalResource locaRes;
			m_Images.Create (IDB_BCGBARRES_FONT, nImageWidth, 0, RGB (255, 255, 255));
		}

		CFont fontSelected;
		CFont* pOldFont = NULL;
		CRect rc(rectClient);		
		rc.right -= cxDropDown;

		CBCGPFontDesc* pDesc = (CBCGPFontDesc*)GetItemDataPtr(nCurSel);
		if (pDesc != NULL)
		{			
			if (pDesc->m_nType & (DEVICE_FONTTYPE | TRUETYPE_FONTTYPE))
			{
				CPoint ptImage (rc.left + 3, rc.top + (rc.Height () - nImageHeight) / 2);
				m_Images.Draw (pDC, pDesc->GetImageIndex (), ptImage, ILD_NORMAL);
			}

			rc.left += nImageWidth + 9;

			if (m_bDrawUsingFont && pDesc->m_nCharSet != SYMBOL_CHARSET)
			{
				LOGFONT lf;
				globalData.fontRegular.GetLogFont (&lf);

				lstrcpy (lf.lfFaceName, pDesc->m_strName);

				if (pDesc->m_nCharSet != DEFAULT_CHARSET)
				{
					lf.lfCharSet = pDesc->m_nCharSet;
				}

				if (lf.lfHeight < 0)
				{
					lf.lfHeight -= 4;
				}
				else
				{
					lf.lfHeight += 4;
				}

				fontSelected.CreateFontIndirect (&lf);
				pOldFont = pDC->SelectObject (&fontSelected);
			}
		}

		CString strText;
		GetLBText (nCurSel, strText);

		pDC->DrawText (strText, rc, DT_SINGLELINE | DT_VCENTER);

		if (pOldFont != NULL)
		{
			pDC->SelectObject (pOldFont);
		}
	}

	m_rectBtn = rectClient;
	m_rectBtn.left = m_rectBtn.right - cxDropDown;

	m_rectBtn.DeflateRect (2, 2);

	CBCGPDrawOnGlass dog (m_bOnGlass);

	CKofBCGPToolbarComboBoxButton buttonDummy;
#ifndef _BCGSUITE_
	buttonDummy.m_bIsCtrl = TRUE;

	CBCGPVisualManager::GetInstance ()->OnDrawComboDropButton (
		pDC, m_rectBtn, !IsWindowEnabled (), m_bIsDroppedDown,
		m_bIsButtonHighlighted,
		&buttonDummy);
#else
	CMFCVisualManager::GetInstance ()->OnDrawComboDropButton (
		pDC, m_rectBtn, !IsWindowEnabled (), m_bIsDroppedDown,
		m_bIsButtonHighlighted,
		&buttonDummy);
#endif

	dm.DrawRect (rectClient, (COLORREF)-1, globalData.clrBarShadow);
	rectClient.DeflateRect (1, 1);
	dm.DrawRect (rectClient, (COLORREF)-1, globalData.clrWindow);
}
void CBeautifulCanlendarYearCombox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	
	if (!IsWindowEnabled())
	{
        CBrush brDisabled(RGB(192,192,192)); // light gray
		CBrush* pOldBrush = pDC->SelectObject(&brDisabled);
		CPen penDisabled(PS_SOLID, 1, RGB(192,192,192));
        CPen* pOldPen = pDC->SelectObject(&penDisabled);

		
        //以下是绘制文本的部分
		CRect textRect = lpDrawItemStruct->rcItem;
        textRect.left = textRect.left + 6;  
		

		CString strText;
	    if(lpDrawItemStruct->itemID != LB_ERR)
		{
		   GetLBText( lpDrawItemStruct->itemID,strText);
        }

		pDC->SetTextColor(RGB(160,160,160));
    
		CFont newFont,*oldFont;
		newFont.CreatePointFont(90,"宋体");
		oldFont = (CFont *)pDC->SelectObject(&newFont);
		pDC->DrawText(strText,&textRect,DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS);
		pDC->SelectObject(oldFont); 
		pDC->SelectObject(pOldBrush);
		pDC->SelectObject(pOldPen);
		return;
	}


	CString strText;
	if(lpDrawItemStruct->itemID != LB_ERR)
	{
		   GetLBText( lpDrawItemStruct->itemID,strText);
    }


	if(strText == "-" || strText == "+")//如果文本是- 则表示要创建减少年数的按钮
	{
		 
		CBrush brHighlight(RGB(231,241,245)); 
		CBrush* pOldBrush = pDC->SelectObject(&brHighlight);
		CPen penHighlight(PS_SOLID, 1, RGB(107,141,162));
		CPen* pOldPen = pDC->SelectObject(&penHighlight);
		 
		CRect rcBackground;
        rcBackground.left = lpDrawItemStruct->rcItem.left + 2;
		rcBackground.right = lpDrawItemStruct->rcItem.right - 2;
		rcBackground.top = lpDrawItemStruct->rcItem.top + 2;
        rcBackground.bottom = lpDrawItemStruct->rcItem.bottom - 2;

	 	pDC->Rectangle(&rcBackground);
		pDC->SetBkMode(TRANSPARENT);
       	pDC->SetTextColor(RGB(255,0,0));
		
		//以下是绘制文本的部分


		pDC->SelectObject(pOldBrush);
		pDC->SelectObject(pOldPen);
		return;
    }


	// Selected
	if ((lpDrawItemStruct->itemState & ODS_SELECTED) 
		&& (lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE))) 
	{
		CBrush brHighlight(RGB(231,241,245)); 
		CBrush* pOldBrush = pDC->SelectObject(&brHighlight);
		CPen penHighlight(PS_SOLID, 1, RGB(107,141,162));
		CPen* pOldPen = pDC->SelectObject(&penHighlight);
		 
	 	pDC->Rectangle(&lpDrawItemStruct->rcItem);
		pDC->SetBkMode(TRANSPARENT);
       	pDC->SetTextColor(RGB(255,0,0));
		
		//以下是绘制文本的部分
		CRect textRect = lpDrawItemStruct->rcItem;
        textRect.left = textRect.left + 6;  
		
		CString strText;
	    if(lpDrawItemStruct->itemID != LB_ERR)
		{
		   GetLBText( lpDrawItemStruct->itemID,strText);
        }
    
		CFont newFont,*oldFont;
		newFont.CreatePointFont(90,"宋体");
		oldFont = (CFont *)pDC->SelectObject(&newFont);
		pDC->DrawText(strText,&textRect,DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS);
        pDC->SelectObject(oldFont);
		pDC->SelectObject(pOldBrush);
		pDC->SelectObject(pOldPen);
	}

	// De-Selected
	if (!(lpDrawItemStruct->itemState & ODS_SELECTED) 
		&& (lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE))) 
	{
		CBrush brWindow(::GetSysColor(COLOR_WINDOW)); 
		CBrush* pOldBrush = pDC->SelectObject(&brWindow);
		CPen penHighlight(PS_SOLID, 1, ::GetSysColor(COLOR_WINDOW));
		CPen* pOldPen = pDC->SelectObject(&penHighlight);
		pDC->Rectangle(&lpDrawItemStruct->rcItem);
		pDC->SetBkColor(::GetSysColor(COLOR_WINDOW));
       	pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));

		//以下是绘制文本的部分
		CRect textRect = lpDrawItemStruct->rcItem;
        textRect.left = textRect.left + 6;  
		
		CString strText;
	    if(lpDrawItemStruct->itemID != LB_ERR)
		{
		   GetLBText( lpDrawItemStruct->itemID,strText);
        }

		CFont newFont,*oldFont;
		newFont.CreatePointFont(90,"宋体");
		oldFont = (CFont *)pDC->SelectObject(&newFont);
		pDC->DrawText(strText,&textRect,DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS);
        pDC->SelectObject(oldFont);

		pDC->SelectObject(pOldBrush);
		pDC->SelectObject(pOldPen);
	}
	
}
Exemplo n.º 14
0
void color_combo_box::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	int m_cyText = 24, z;
	CString strText;
	char ship_name[256];

	// You must override DrawItem and MeasureItem for LBS_OWNERDRAWVARIABLE
	ASSERT((GetStyle() & (LBS_OWNERDRAWFIXED | CBS_HASSTRINGS)) ==
		(LBS_OWNERDRAWFIXED | CBS_HASSTRINGS));

	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

	// I think we need to do a lookup by ship name here	
	if(lpDrawItemStruct->itemID >= (uint)Num_ship_types){
		z = lpDrawItemStruct->itemID;
	} else {		
		memset(ship_name, 0, 256);
		GetLBText(lpDrawItemStruct->itemID, ship_name);
		z = ship_info_lookup(ship_name);
	}

	if ((z >= 0) && (lpDrawItemStruct->itemAction & (ODA_DRAWENTIRE | ODA_SELECT)))
	{
		int cyItem = GetItemHeight(z);
		BOOL fDisabled = !IsWindowEnabled();

		COLORREF newTextColor = RGB(0x80, 0x80, 0x80);  // light gray
		if (!fDisabled) {
			if (z >= Num_ship_types)
				newTextColor = RGB(0, 0, 0);
			else
				switch (Ship_info[z].species)	{
					case SPECIES_TERRAN:		newTextColor = RGB(0, 0, 192);	break;
					case SPECIES_VASUDAN:	newTextColor = RGB(0, 128, 0);	break;
					case SPECIES_SHIVAN:		newTextColor = RGB(192, 0, 0);	break;
					case SPECIES_NONE:		newTextColor = RGB(224, 128, 0);	break;
				}
		}

		COLORREF oldTextColor = pDC->SetTextColor(newTextColor);
		COLORREF newBkColor = GetSysColor(COLOR_WINDOW);
		COLORREF oldBkColor = pDC->SetBkColor(newBkColor);

		if (newTextColor == newBkColor)
			newTextColor = RGB(0xC0, 0xC0, 0xC0);   // dark gray

		if (!fDisabled && ((lpDrawItemStruct->itemState & ODS_SELECTED) != 0))
		{
			pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT));
			pDC->SetBkColor(GetSysColor(COLOR_HIGHLIGHT));
		}

		if (m_cyText == 0)
			VERIFY(cyItem >= CalcMinimumItemHeight());

		if (z == Id_select_type_jump_node)
			strText = _T("Jump Node");
		else if (z == Id_select_type_start)
			strText = _T("Player Start");
		else if (z == Id_select_type_waypoint)
			strText = _T("Waypoint");
		else
			strText = _T(Ship_info[z].name);
//		GetLBText(lpDrawItemStruct->itemID, strText);

		pDC->ExtTextOut(lpDrawItemStruct->rcItem.left,
			lpDrawItemStruct->rcItem.top + max(0, (cyItem - m_cyText) / 2),
			ETO_OPAQUE, &(lpDrawItemStruct->rcItem), strText, strText.GetLength(), NULL);

		pDC->SetTextColor(oldTextColor);
		pDC->SetBkColor(oldBkColor);
	}

	if ((lpDrawItemStruct->itemAction & ODA_FOCUS) != 0)
		pDC->DrawFocusRect(&(lpDrawItemStruct->rcItem));
}
Exemplo n.º 15
0
void CColorCombox::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
    //验证是否为组合框控件
    ASSERT( lpDrawItemStruct->CtlType == ODT_COMBOBOX );
    CDC dc ;
    dc.Attach( lpDrawItemStruct->hDC );

    //获取项目区域
    CRect itemRC ( lpDrawItemStruct->rcItem );
    //定义显示颜色的区域
    CRect clrRC = itemRC;
    //定义文本区域
    CRect textRC = itemRC;
    //获取系统文本颜色
    COLORREF clrText = GetSysColor( COLOR_WINDOWTEXT );
    //选中时的文本颜色
    COLORREF clrSelected = GetSysColor( COLOR_HIGHLIGHT );
    //获取窗口背景颜色
    COLORREF clrNormal = GetSysColor( COLOR_WINDOW );
    //获取当前项目索引
    int nIndex = lpDrawItemStruct->itemID;
    //判断项目状态
    int nState = lpDrawItemStruct->itemState;
    if( nState & ODS_SELECTED )	//处于选中状态
    {
        dc.SetTextColor( ( 0x00FFFFFF & ~( clrText ) ) );		//文本颜色取反
        dc.SetBkColor( clrSelected );						//设置文本背景颜色
        dc.FillSolidRect( &clrRC, clrSelected );			//填充项目区域为高亮效果
    }
    else
    {
        dc.SetTextColor( clrText );						//设置正常的文本颜色
        dc.SetBkColor( clrNormal );						//设置正常的文本背景颜色
        dc.FillSolidRect( &clrRC, clrNormal );
    }
    if( nState & ODS_FOCUS )								//如果项目获取焦点,绘制焦点区域
    {
        dc.DrawFocusRect( &itemRC );
    }

    //计算文本区域
    int nclrWidth = itemRC.Width() / 4;
    textRC.left = nclrWidth + 55;

    //计算颜色显示区域
    clrRC.DeflateRect( 2, 2 );
    clrRC.right = nclrWidth + 50;


    //绘制颜色文本并且填充颜色区域
    if ( nIndex != -1 )	//项目不为空
    {
        //获取项目颜色
        COLORREF clrItem = GetItemData( nIndex );
        dc.SetBkMode( TRANSPARENT );
        //获取文本
        CString szText;
        GetLBText( nIndex, szText );
        //输出文本
        dc.DrawText( szText, textRC, DT_LEFT | DT_VCENTER | DT_SINGLELINE );
        dc.FillSolidRect( &clrRC, clrItem );
        //输出颜色
        dc.FrameRect( &clrRC, &CBrush( RGB( 0, 0, 0 ) ) );
    }
    dc.Detach();
}