📄 maindialog.cpp
字号:
// MainDialog.cpp : implementation file
//
#include "stdafx.h"
#include "ADOConn.h"
#include "MKJC.h"
#include "MainDialog.h"
#include "MainFrm.h"
#include "MKJC.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define MAX_LIST_DISP 10
struct List_Col_Prop
{
TCHAR szTitle[16];
DWORD dwStyle;
LONG Width;
TCHAR szKey[16];
}List_Col_Disp[] = {
{ _T("ID"), LVCFMT_LEFT, 60, _T("YDID")},
{ _T("姓名"), LVCFMT_LEFT, 80, _T("YDXM")},
{ _T("体温"), LVCFMT_LEFT, 60, _T("YDTW")},
{ _T("脉搏"), LVCFMT_LEFT, 60, _T("YDMB")},
{ _T("位置"), LVCFMT_LEFT, 80, _T("YDWZ")},
{ _T("x坐标"), LVCFMT_LEFT, 60, _T("YDWZ_X")},
{ _T("y坐标"), LVCFMT_LEFT, 60, _T("YDWZ_Y")}
};
const INT List_Col_Cnt = sizeof(List_Col_Disp) / sizeof(List_Col_Prop);
/////////////////////////////////////////////////////////////////////////////
// CMainDialog dialog
IMPLEMENT_DYNCREATE(CMainDialog, CDialog)
CMainDialog::CMainDialog(CWnd* pParent /*=NULL*/)
: CDialog(CMainDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CMainDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CMainDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMainDialog)
DDX_Control(pDX, IDC_LIST, m_list);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMainDialog, CDialog)
//{{AFX_MSG_MAP(CMainDialog)
ON_WM_TIMER()
ON_NOTIFY(NM_CLICK, IDC_LIST, OnClickList)
ON_NOTIFY(NM_DBLCLK, IDC_LIST, OnDblclkList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainDialog message handlers
BOOL CMainDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_list.SetExtendedStyle(LVS_EX_FLATSB|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
for( int i=0; i<List_Col_Cnt; i++)
{
m_list.InsertColumn( i,
List_Col_Disp[i].szTitle,
List_Col_Disp[i].dwStyle,
List_Col_Disp[i].Width);
}
// List Ctrl Refresh
OnRefreshList();
SetTimer( 1, 5000, NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMainDialog::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnTimer(nIDEvent);
// List Ctrl Refresh
OnRefreshList();
}
void CMainDialog::OnClickList(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
*pResult = 0;
}
BOOL CMainDialog::OnRefreshList()
{
// ADO Obj
ADOConn m_AdoConn;
if ( !m_AdoConn.OnInitADOConn())
{
return FALSE;
}
m_list.DeleteAllItems();
for ( int m=MAX_LIST_DISP; m>=1; m--)
{
CString sql;
// Why DESC??
sql.Format("select* from YDJD where YDID='%d' order by YDSJ desc",m);
m_AdoConn.GetRecordSet((_bstr_t)sql);
for( int n=0; n<List_Col_Cnt; n++)
{
if ( 0 == n)
{
m_list.InsertItem( 0,"");
}
m_list.SetItemText( 0, n, (char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect(List_Col_Disp[n].szKey));
}
}
m_AdoConn.ExitConnect();
}
void CMainDialog::OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
AfxMessageBox( _T("double Clicked!"));
// Get the Mainframe Handle
CMKJCApp* pApp = (CMKJCApp*)AfxGetApp();
pApp->m_pMainWnd->PostMessage( WM_REDRAW, 0, 0);
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -