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

📄 inplacelist.cpp

📁 连接MYSQL数据库
💻 CPP
字号:
//author : Jarry
//E-mail : lansingk@online.sh.cn
// InplaceList.cpp : implementation file
//

#include "stdafx.h"
#include "InplaceList.h"

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

/////////////////////////////////////////////////////////////////////////////
// CInplaceList

CInplaceList::CInplaceList()
{
}

CInplaceList::CInplaceList(int iItem, int iSubitem)
{
	m_iItem = iItem;
	m_iSubitem = iSubitem;
	m_bEsc = false;
}

CInplaceList::~CInplaceList()
{
}


BEGIN_MESSAGE_MAP(CInplaceList, CComboBox)
	//{{AFX_MSG_MAP(CInplaceList)
	ON_WM_NCDESTROY()
	ON_WM_KILLFOCUS()
	ON_WM_SHOWWINDOW()
	ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
	ON_WM_CHAR()
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CInplaceList message handlers



void CInplaceList::OnNcDestroy() 
{
	CComboBox::OnNcDestroy();
	
	delete this;
}

void CInplaceList::OnKillFocus(CWnd* pNewWnd) 
{
	CComboBox::OnKillFocus(pNewWnd);

	CString str;
	GetWindowText(str);

	// send notification to parent of listview ctrl
	LV_DISPINFO dispinfo;
	dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
	dispinfo.hdr.idFrom = GetDlgCtrlID();
	dispinfo.hdr.code = LVN_ENDLABELEDIT;

	dispinfo.item.mask = LVIF_TEXT;
	dispinfo.item.iItem = m_iItem;
	dispinfo.item.iSubItem = m_iSubitem;
	dispinfo.item.pszText = m_bEsc ? NULL : LPTSTR((LPCTSTR)str);
	dispinfo.item.cchTextMax = str.GetLength();

	GetParent()->GetParent()->SendMessage( WM_NOTIFY, GetParent()->GetDlgCtrlID(), 
					(LPARAM)&dispinfo );

	PostMessage( WM_CLOSE );
}

void CInplaceList::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CComboBox::OnShowWindow(bShow, nStatus);

	AddString("char");
	AddString("varchar");
	AddString("tinyint");
	AddString("smallint");
	AddString("integer");
	AddString("mediumint");
	AddString("bigint");
	AddString("decimal");
	AddString("numeric");
	AddString("float");
	AddString("double");
	AddString("real");
	AddString("timestamp");
	AddString("date");
	AddString("time");
	AddString("datetime");
	AddString("year");
	AddString("blob");
	AddString("text");
//	AddString("set");
//	AddString("enum");

	SetCurSel(2);  //point to char
}

BOOL CInplaceList::PreCreateWindow(CREATESTRUCT& cs) 
{
	cs.style |= WS_VSCROLL | CBS_DROPDOWNLIST | CBS_SORT;
	
	return CComboBox::PreCreateWindow(cs);
}

void CInplaceList::OnCloseup() 
{
	GetParent()->SetFocus();	
}

void CInplaceList::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	if( nChar == VK_ESCAPE || nChar == VK_RETURN)
	{
		if( nChar == VK_ESCAPE )
			m_bEsc = true;
		GetParent()->SetFocus();
		return;
	}
	
	CComboBox::OnChar(nChar, nRepCnt, nFlags);
}

BOOL CInplaceList::PreTranslateMessage(MSG* pMsg) 
{
	if( pMsg->message == WM_KEYDOWN )
	{
		if(pMsg->wParam == VK_RETURN
				|| pMsg->wParam == VK_ESCAPE
				)
		{
			::TranslateMessage(pMsg);
			::DispatchMessage(pMsg);
			return true;				// do not process further
		}
	}
	
	return CComboBox::PreTranslateMessage(pMsg);
}

int CInplaceList::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CComboBox::OnCreate(lpCreateStruct) == -1)
		return -1;

	CFont *pFont = GetParent()->GetFont();
	SetFont(pFont);
	SetFocus();

	return 0;
}

⌨️ 快捷键说明

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