⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlcombobox.cpp

📁 Xerces-C++应用实例
💻 CPP
字号:
// ================================================================================
//
//    author:         Rainer Schuster
//
//    created:        09.03.2005 10:20:32
//
//    filename:       xmlcombobox.cpp    IMPLEMENTATION
//
//    This code is as it is. You are allowed to use, modify and/or redistribute it freely.
//    I'm not responsible for any errors or damage. Use it at your own risk.
//
// ================================================================================



//

#include "stdafx.h"
#include "xml_test.h"
#include "XMLComboBox.h"
#include <MemDC.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CXMLComboBox

CXMLComboBox::CXMLComboBox()
{
}

CXMLComboBox::~CXMLComboBox()
{
}


BEGIN_MESSAGE_MAP(CXMLComboBox, CComboBox)
	//{{AFX_MSG_MAP(CXMLComboBox)
		// HINWEIS - Der Klassen-Assistent f黦t hier Zuordnungsmakros ein und entfernt diese.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen f黵 Nachrichten CXMLComboBox 

void CXMLComboBox::Parse( DOMDocument *doc, const char* lpcszID)
{
	CXMLGrid::Parse( doc, lpcszID);

//	int i = m_rows.size() ;
//	::SendMessage( m_hWnd, LB_SETCOUNT, m_rows.size() , 0);
};

void CXMLComboBox::ParseRow( DOMNode *row)
{
	CXMLGrid::ParseRow( row);
	AddString("");
}


void CXMLComboBox::DrawItem(LPDRAWITEMSTRUCT lpdis) 
{
	ASSERT(lpdis->CtlType == ODT_COMBOBOX);
	
	if( lpdis->itemID == LB_ERR)
		return;
	

	CDC			dc;
	CString		*pstrText;
	CColsMap	*pData ;
	COLORREF	crOldTextColor;
	COLORREF	crOldBkColor;

	pData = m_rows[lpdis->itemID].m_pCols;
	pstrText = &((*pData)[XCB_COL_STRING]);

	dc.Attach(lpdis->hDC);

	lpdis->rcItem.left += 2;

	if( strlen( (*pData)[XCB_COL_ICON]) )
	{
		CPictureMap::iterator bmp = m_bmps.find( (*pData)[XCB_COL_ICON] );
		
		if( bmp == m_bmps.end() )
		{
			LoadIcon( (*pData)[XCB_COL_ICON], m_strIcons, &m_bmps );
			bmp = m_bmps.find( (*pData)[XCB_COL_ICON] );
		}

		if( bmp != m_bmps.end() )
		{

			UINT nStyle = ILD_TRANSPARENT;

			if(		(lpdis->itemAction | ODA_SELECT)
				&&	(lpdis->itemState & ODS_SELECTED)
			  )
			{
				nStyle = ILD_SELECTED;
			}

			RECT		rc;
			long		hmWidth		= 0;
			long		hmHeight	= 0;
			LPPICTURE	pPict		= ((*bmp).second);

			GetClientRect(&rc);
			pPict->get_Width (&hmWidth);
			pPict->get_Height(&hmHeight);

			pPict->Render(	lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, 16, 16,
								0, hmHeight, hmWidth, -hmHeight, &rc);
		
			lpdis->rcItem.left += 16 +2;
		}
	}


	if ((lpdis->itemAction | ODA_SELECT) &&
	  (lpdis->itemState & ODS_SELECTED))
	{
		m_clrSelected	= GetSysColor(COLOR_HIGHLIGHT);
		crOldBkColor	= dc.SetBkColor( m_clrSelected );
		crOldTextColor	= dc.SetTextColor( GetSysColor( COLOR_HIGHLIGHTTEXT));
		dc.FillSolidRect(&lpdis->rcItem,  m_clrSelected);
	}
	else
	{
		crOldTextColor	= GetSysColor( COLOR_WINDOWTEXT);
		crOldBkColor	= dc.GetBkColor();
		dc.FillSolidRect(&lpdis->rcItem,  crOldBkColor);
	}



	lpdis->rcItem.left += 5;
	
	// Draw the text.
	dc.DrawText(  *pstrText,
				  pstrText->GetLength(),
				  &lpdis->rcItem,
				  DT_LEFT|DT_SINGLELINE|DT_VCENTER);

	// Reset the background color and the text color back to their
	// original values.
	dc.SetTextColor(crOldTextColor);
	dc.SetBkColor(crOldBkColor);

	dc.Detach();	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -