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

📄 infodlg.cpp

📁 一个源代码管理工具,支持悬浮框拖曳,后台数据库管理,代码高亮显示灯功能
💻 CPP
字号:
// InfoDlg.cpp : implementation file
//

#include "stdafx.h"
#include "CodeManager.h"
#include "InfoDlg.h"
#include "MainFrm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CInfoDlg dialog
IMPLEMENT_DYNCREATE(CInfoDlg, CDialog)

CInfoDlg::CInfoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CInfoDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CInfoDlg)
	m_strAuthor = _T("");
	m_strCategory = _T("");
	m_strKey = _T("");
	m_strRemark = _T("");
	m_strTime = _T("");
	//}}AFX_DATA_INIT
}


void CInfoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CInfoDlg)
	DDX_Control(pDX, IDC_REMARK, m_ctrlRemark);
	DDX_Control(pDX, IDC_TIME, m_ctrlTime);
	DDX_Control(pDX, IDC_KEY, m_ctrlKey);
	DDX_Control(pDX, IDC_AUTHOR, m_ctrlAuthor);
	DDX_Control(pDX, IDC_CATEGORY, m_ctrlCategory);
	DDX_Text(pDX, IDC_AUTHOR, m_strAuthor);
	DDX_CBString(pDX, IDC_CATEGORY, m_strCategory);
	DDX_Text(pDX, IDC_KEY, m_strKey);
	DDX_Text(pDX, IDC_REMARK, m_strRemark);
	DDX_Text(pDX, IDC_TIME, m_strTime);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CInfoDlg, CDialog)
	//{{AFX_MSG_MAP(CInfoDlg)
	ON_EN_CHANGE(IDC_AUTHOR, OnChangeAuthor)
	ON_EN_CHANGE(IDC_TIME, OnChangeTime)
	ON_EN_CHANGE(IDC_KEY, OnChangeKey)
	ON_EN_CHANGE(IDC_REMARK, OnChangeRemark)
	ON_CBN_SELCHANGE(IDC_CATEGORY, OnSelchangeCategory)
	ON_WM_PAINT()
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CInfoDlg message handlers



void CInfoDlg::OnChangeAuthor() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd();
	UpdateData();
	if(!GetRecord())
	{
		pFrame->m_DbObject.SetData("Author", m_strAuthor);
		pFrame->m_DbObject.Update();
	}
	
}

void CInfoDlg::OnChangeTime() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd();
	pFrame->m_bChange = TRUE;
}

void CInfoDlg::OnChangeKey() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd();
	UpdateData();
	if(!GetRecord())
	{
		pFrame->m_DbObject.SetData("IndexWord", m_strKey);
		pFrame->m_DbObject.Update();
	}
	
}

void CInfoDlg::OnChangeRemark() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd();
	UpdateData();
	if(!GetRecord())
	{
		pFrame->m_DbObject.SetData("Remark", m_strRemark);
		pFrame->m_DbObject.Update();
	}
}


int CInfoDlg::GetRecord()
{
	CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd();
	HTREEITEM hs = pFrame->m_wndTree.GetSelectedItem();
	if(hs != NULL)
	{
		CString strvalue = "select * from CodeTable where CodeID = ", strdata;
		long lvalue = pFrame->m_wndTree.GetItemData(hs);
		strdata.Format("%ld", lvalue);
		strvalue = strvalue + "" + strdata + "";

		pFrame->m_DbObject.GetValue(strvalue);
	}
	else
		return 1;
	return 0;
}

void CInfoDlg::OnSelchangeCategory() 
{
	// TODO: Add your control notification handler code here
	CString str;
	UpdateData();
	CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd();
	
	if(!GetRecord())
	{
		m_ctrlCategory.GetLBText(m_ctrlCategory.GetCurSel(), str);
		pFrame->m_DbObject.SetData("Category", str);
		pFrame->m_DbObject.Update();
	}
}



void CInfoDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	//读取数据库中属性内容
	CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd();
	HTREEITEM hs = pFrame->m_wndTree.GetSelectedItem();
	if(hs != NULL)
	{
		GetRecord();
	//	CString str;
		_variant_t vstring;
		vstring = pFrame->m_DbObject.m_pRecordset->GetCollect("Author");
		if( vstring.vt != VT_NULL&& vstring.vt != VT_EMPTY)
			m_strAuthor = (LPCTSTR)(_bstr_t)vstring;
		else
			m_strAuthor = "";
		vstring = pFrame->m_DbObject.m_pRecordset->GetCollect("IndexWord");
		if( vstring.vt != VT_NULL&& vstring.vt != VT_EMPTY)
			m_strKey = (LPCTSTR)(_bstr_t)vstring;
		else
			m_strKey = "";
		vstring = pFrame->m_DbObject.m_pRecordset->GetCollect("Remark");
		if( vstring.vt != VT_NULL&& vstring.vt != VT_EMPTY)
			m_strRemark = (LPCTSTR)(_bstr_t)vstring;
		else
			m_strRemark = "";

		vstring = pFrame->m_DbObject.m_pRecordset->GetCollect("CollectTime");
		if( vstring.vt != VT_NULL&& vstring.vt != VT_EMPTY)
			m_strTime = (LPCTSTR)(_bstr_t)vstring;
		else
			m_strTime = "";
		UpdateData(FALSE);

		vstring = pFrame->m_DbObject.m_pRecordset->GetCollect("Category");
		if( vstring.vt != VT_NULL)
		{		
			m_ctrlCategory.SelectString(-1, (LPCTSTR)(_bstr_t)vstring);
		}
		else
			m_ctrlCategory.SetCurSel(2);
	}
	// Do not call CDialog::OnPaint() for painting messages
}

void CInfoDlg::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	CRect rect,tr;
	GetWindowRect(&rect);
	if(m_ctrlAuthor.m_hWnd != NULL)
	{
		m_ctrlAuthor.GetWindowRect(&tr);
		m_ctrlAuthor.MoveWindow(tr.left - rect.left, tr.top - rect.top, rect.Width() - 72, tr.Height());
	}

	if(m_ctrlCategory.m_hWnd != NULL)
	{
		m_ctrlCategory.GetWindowRect(&tr);
		m_ctrlCategory.MoveWindow(tr.left - rect.left, tr.top - rect.top, rect.Width() - 72, tr.Height());
	}

	if(m_ctrlTime.m_hWnd != NULL)
	{
		m_ctrlTime.GetWindowRect(&tr);
		m_ctrlTime.MoveWindow(tr.left - rect.left, tr.top - rect.top, rect.Width() - 72, tr.Height());
	}

	if(m_ctrlKey.m_hWnd != NULL)
	{
		m_ctrlKey.GetWindowRect(&tr);
		m_ctrlKey.MoveWindow(tr.left - rect.left, tr.top - rect.top, rect.Width() - 9, tr.Height());
	}

	if(m_ctrlRemark.m_hWnd != NULL)
	{
		m_ctrlRemark.GetWindowRect(&tr);
		m_ctrlRemark.MoveWindow(tr.left - rect.left, tr.top - rect.top, rect.Width() - 9, tr.Height() + rect.bottom - tr.bottom);
	}	
}

⌨️ 快捷键说明

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