// ListTestDlg.h : header file
//
#if !defined(AFX_LISTTESTDLG_H__FFD2EAE7_77CF_4E65_BF32_570B4565E0CB__INCLUDED_)
#define AFX_LISTTESTDLG_H__FFD2EAE7_77CF_4E65_BF32_570B4565E0CB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/
// CListTestDlg dialog
class CListTestDlg : public CDialog
{
// Construction
public:
CListTestDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CListTestDlg)
enum { IDD = IDD_LISTTEST_DIALOG };
CListCtrl m_listshowctrl;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CListTestDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CListTestDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg void OnButtonTest( NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnButton2();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the
previous line.
#endif // !defined
(AFX_LISTTESTDLG_H__FFD2EAE7_77CF_4E65_BF32_570B4565E0CB__INCLUDED_)
/
// ListTestDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ListTest.h"
#include "ListTestDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/
// CListTestDlg dialog
CListTestDlg::CListTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CListTestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CListTestDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CListTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CListTestDlg)
DDX_Control(pDX, IDC_LIST_SHOW, m_listshowctrl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CListTestDlg, CDialog)
//{{AFX_MSG_MAP(CListTestDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_BN_CLICKED(IDC_BUTTON_TEST, OnButtonTest)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
ON_NOTIFY (NM_CUSTOMDRAW, IDC_LIST_SHOW, OnButtonTest)
END_MESSAGE_MAP()
/
// CListTestDlg message handlers
BOOL CListTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_listshowctrl.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
m_listshowctrl.InsertColumn(0,"",LVCFMT_LEFT,100);
m_listshowctrl.InsertColumn(1,"1通道",LVCFMT_CENTER,100);
m_listshowctrl.InsertColumn(2,"2通道",LVCFMT_CENTER,100);
m_listshowctrl.InsertColumn(3,"3通道",LVCFMT_CENTER,100);
m_listshowctrl.InsertColumn(4,"4通道",LVCFMT_CENTER,100);
m_listshowctrl.InsertColumn(5,"5通道",LVCFMT_CENTER,100);
m_listshowctrl.InsertColumn(6,"6通道",LVCFMT_CENTER,100);
m_listshowctrl.InsertItem(0,"XX");
m_listshowctrl.InsertItem(1,"1X");
m_listshowctrl.InsertItem(2,"2X");
m_listshowctrl.InsertItem(3,"3X");
m_listshowctrl.SetItemText(0,1,"YY");
m_listshowctrl.SetItemText(0,2,"ZZ");
m_listshowctrl.SetItemText(0,3,"WW");
m_listshowctrl.SetItemText(0,4,"RR");
m_listshowctrl.SetItemText(1,1,"ee");
m_listshowctrl.SetItemText(1,2,"pp");
m_listshowctrl.SetItemText(1,3,"ff");
m_listshowctrl.SetItemText(1,4,"gg");
m_listshowctrl.SetItemText(2,1,"11");
m_listshowctrl.SetItemText(2,2,"33");
m_listshowctrl.SetItemText(2,3,"22");
m_listshowctrl.SetItemText(2,4,"44");
return TRUE; // return TRUE unless you set the focus to a control
}
void CListTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CListTestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
//DEL HCURSOR CListTestDlg::OnQueryDragIcon()
//DEL {
//DEL return (HCURSOR) m_hIcon;
//DEL }
int i = 0;
void CListTestDlg::OnButtonTest( NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = CDRF_DODEFAULT;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
COLORREF clrNewTextColor, clrNewBkColor;
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
//修改的行号
CString strTemp = m_listshowctrl.GetItemText(nItem,pLVCD->iSubItem);
//修改的文本、字符
if(strTemp == ""||strTemp=="YY"||strTemp=="pp")
{
clrNewTextColor = RGB(0,255,0);
clrNewBkColor = RGB(255,0,0);
}
else
{
clrNewTextColor = RGB(0,0,0);
clrNewBkColor = RGB(255,255,255);
}
pLVCD->clrText = clrNewTextColor;
pLVCD->clrTextBk = clrNewBkColor;
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
}
void CListTestDlg::OnButton2()
{
// TODO: Add your control notification handler code here
m_listshowctrl.SetItemText(3,1,"pp");
m_listshowctrl.SetItemText(3,2,"YY");
m_listshowctrl.SetItemText(3,3,"55");
Sleep(1000);
}
///
m_listctrl.SetExtendedStyle(m_listctrl.GetExtendedStyle()
|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES);
m_listctrl.InsertColumn(0,"FAIL_ODUINFO",LVCFMT_LEFT,100);
m_listctrl.InsertColumn(01,"CASE",LVCFMT_LEFT,300);
// UpdateData();
// int n = m_listInfo.GetItemCount();
m_listctrl.InsertItem(0,"df");
m_listctrl.SetItemText(0,1,"fdf");
m_listctrl.SetItemText(0,2,"dff");
m_listctrl.InsertItem(1,"d22f");
m_listctrl.SetItemText(1,1,"fd332f");
m_listctrl.SetItemText(1,2,"d22ff");
// int count = m_List.GetItemCount();
// for(int i = 0;i<count;i++)
// {
// if(m_List.GetCheck(i))
// {
/i被选重
// }
// }
// GetDlgItem(IDC_ID)->GetCheck();
// 或者映射一个变量,UpdateData之后去值就可以