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

📄 formitemlookup.cpp

📁 基于WINDOWS mobile 的用于创建一个窗体和自定义试图的工程
💻 CPP
字号:
// FormItemLookup.cpp: implementation of the CFormItemLookup class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "FormItemLookup.h"
#include "FormListCtrl.h"
#include "DrawTextEx.h"

#include "UdfDlg.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CFormItemLookup::CFormItemLookup()
:	m_bSelected	(FALSE)
{

}


CFormItemLookup::~CFormItemLookup()
{

}


// CFormItemLookup::RenderData
//
//		Data rendering for strings
//
LPCTSTR CFormItemLookup::RenderData(LV_DISPINFO *pDispInfo)
{
	LPCTSTR	pszData = _T("");
	int		iSubItem;

	if(!pDispInfo)		// If pointer is NULL
		iSubItem = 1;	// Assume rendering data
	else
		iSubItem = pDispInfo->item.iSubItem;

	if(iSubItem == 1)
	{
		//
		// Render the data
		//
		pszData = m_strData;
	}
	else
	{
		//
		// Render the caption
		//
		pszData = CFormItem::RenderData(pDispInfo);
	}

	return pszData;
}


// CFormItemLookup::ShowEditor
//
//		Shows the editor
//
BOOL CFormItemLookup::ShowEditor(CFormListCtrl* pForm, BOOL bShow, int iItem, int iSubItem)
{
/*	CUdfDlg	dlg(&g_oleDbSession, m_nUdfID);

	ASSERT(pForm);

	m_bSelected = TRUE;
	pForm->RedrawItems(nItem, nItem);
	
	dlg.SetValue(m_strData);
	if(dlg.DoModal() == IDOK)
		m_strData = dlg.GetValue();

	m_bSelected = FALSE;
*/
	return FALSE;
}


// CFormItemLookup::CustomDraw
//
//		Default behaviour for custom draw
//
LRESULT CFormItemLookup::CustomDraw(CFormListCtrl* pForm, NMLVCUSTOMDRAW *pLVCD)
{
	DWORD	dwDrawStage = pLVCD->nmcd.dwDrawStage;
	LRESULT	lRet		= CDRF_DODEFAULT;

	if(dwDrawStage == (CDDS_ITEMPREPAINT | CDDS_SUBITEM))
	{
		HDC			hDC		= pLVCD->nmcd.hdc;	// Display context
		CRect		rc		= pLVCD->nmcd.rc;	// Item rect

		if(pLVCD->iSubItem == 1)
		{
			//
			// Write the content string
			//
			CString		strText = RenderData(NULL);
			HFONT		hFontOld= NULL;
			CFont*		pFont	= pForm->GetContentFont();
			COLORREF	rgbTxt,						// Text RGB
						rgbOld;						// Old RGB

			//
			// Prepare the gray text RGB for disabled items
			//
			if(IsEnabled())
				rgbTxt = RGB(  0,   0,   0);		// Black
			else 
				rgbTxt = RGB(128, 128, 128);		// Grey
			rgbOld = ::SetTextColor(hDC, rgbTxt);

			rc.left		+= 6;
			rc.top		+= 1;
			rc.right	-= rc.Height();

			if(pFont)
				hFontOld = (HFONT) ::SelectObject(hDC, *pFont);

			::DrawTextEx(hDC, strText, -1, &rc, 
				DT_LEFT | DT_SINGLELINE | DT_TOP | DT_END_ELLIPSIS | DT_MODIFYSTRING);

			if(hFontOld)
				::SelectObject(hDC, hFontOld);

			if(m_dwFlags & FIF_LINE)
				DrawBottomLine(pLVCD);

			::SetTextColor(hDC, rgbOld);

			//
			// Draw the combo arrow
			//
			rc			= pLVCD->nmcd.rc;
			rc.top		+= 1;
			rc.left		+= rc.Width() - rc.Height() + 2;
			rc.bottom	-= 1;
			DrawArrow(hDC, rc, m_bSelected);

			lRet = CDRF_SKIPDEFAULT;
		}
		else
		{
			lRet = CFormItem::CustomDraw(pForm, pLVCD);
		}
	}

	return lRet;
}

⌨️ 快捷键说明

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