📄 dataputout.cpp
字号:
// DataPutOut.cpp : implementation file
//
#include "stdafx.h"
#include "Measure.h"
#include "DataPutOut.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// DataPutOut dialog
DataPutOut::DataPutOut(CWnd* pParent /*=NULL*/)
: CBDialog(DataPutOut::IDD, pParent)
{
//{{AFX_DATA_INIT(DataPutOut)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void DataPutOut::DoDataExchange(CDataExchange* pDX)
{
CBDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DataPutOut)
DDX_Control(pDX, IDC_daochu3, m_quanxuan);
DDX_Control(pDX, IDC_daochu2, m_fanxuan);
DDX_Control(pDX, IDCANCEL, m_cancel);
DDX_Control(pDX, IDC_daochu, m_daochu);
DDX_Control(pDX, IDC_LIST1, m_list1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(DataPutOut, CBDialog)
//{{AFX_MSG_MAP(DataPutOut)
ON_BN_CLICKED(IDC_daochu, Ondaochu)
ON_BN_CLICKED(IDC_daochu2, Ondaochu2)
ON_BN_CLICKED(IDC_daochu3, Ondaochu3)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DataPutOut message handlers
BOOL DataPutOut::OnInitDialog()
{
CBDialog::OnInitDialog();
// TODO: Add extra initialization here
SetBitmapStyle(StyleStretch);
SetBitmap(IDB_BITMAP1);
m_brush.CreateSolidBrush(RGB(255,218,185));
m_fanxuan.LoadBitmaps(IDB_FANXUANNORMAL,IDB_FANXUANDOWN,IDB_FANXUANUP,IDB_PDISABLE);
m_fanxuan.SetToolTipText("反选列表中的数据");
m_quanxuan.LoadBitmaps(IDB_ALLNORMAL,IDB_ALLDOWN,IDB_ALLUP,IDB_PDISABLE);
m_quanxuan.SetToolTipText("全选列表中的数据");
m_cancel.LoadBitmaps(IDB_TUICHUNORMAL,IDB_TUICHUDOWN,IDB_TUICHUUP,IDB_PDISABLE);
m_cancel.SetToolTipText("退出");
m_daochu.LoadBitmaps(IDB_PUTOUTNORMAL,IDB_PUTOUTDOWN,IDB_PUTOUTUP,IDB_PDISABLE);
m_daochu.SetToolTipText("将列表中的数据导出到本地磁盘");
CString strValidChars = "0123456789.";
DWORD dw;
dw=m_list1.GetExtendedStyle();
dw|=LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT |LVS_EX_GRIDLINES;
m_list1.SetExtendedStyle(dw);
m_list1.SetBkColor(RGB(0xec,0xf1,0xfd));
m_list1.SetTextBkColor(RGB(0xfe,0xFF,0xc6));
// m_list1.SetValidEditCtrlCharacters(strValidChars);
// m_list1.SetReadOnlyColumns(0);
// m_list1.EnableVScroll();
m_list1.InsertColumn(0,"序号",LVCFMT_LEFT,50,100);
m_list1.InsertColumn(1,"长度值",LVCFMT_LEFT,200,100);
//m_daochu.SetBitmap(LoadBitmap(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDB_BITMAP6)));
CString nItem,No;
double Data;
long Numb;
LPCCellBase PB;
CLength* PL;
CCellArray* PCellArray=g_SysApp.GetCellArray();
long max;
max=PCellArray->GetCount();
for(int i=0;i<max;i++)
{
PB=PCellArray->GetArrayItem(i);
PL=(CLength*)PB;
Numb=PL->GetNo();
Data=PL->GetLen();
nItem.Format("%.4lf",Data);
Numb=PB->GetNo();
No.Format("%ld",Numb);
nItem.Format("%.4lf",Data);
m_list1.InsertItem(i,No);
m_list1.SetItemText(i,1,nItem);
m_list1.SetCheck(i,true);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void DataPutOut::Ondaochu()
{
// TODO: Add your control notification handler code here
CString fl1,s1,s2,str,strl;
fl1="my data.txt";
CString A=',';
CString B='\r';
CString C='\n';
CString D=';';
int t;
CCellArray* PCellArray=g_SysApp.GetCellArray();
long max;
max=PCellArray->GetCount();
CFileDialog dlg(false,NULL, fl1,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,NULL, NULL);
char cf[]="文本文件(*.txt)"; //过滤文件
dlg.m_ofn.lpstrFilter=cf; //在对话框中显示过滤的类型
int ir=dlg.DoModal(); //模态显示另存对话框
CString wjm=dlg.GetPathName(); //获取文件路径文件名全称
CFile fil; //声明一个文件类对象
if(ir=IDOK) //如果单击另存对话框打开
{
fil.Open(wjm,CFile::modeCreate|CFile::modeWrite);//打开文件
//用指向fil的指针创建
for(int i=0;i<max;i++)
{ t=m_list1.GetCheck(i);
if(t)
{
str=m_list1.GetItemText(i,0);
strl=m_list1.GetItemText(i,1);
fil.Write(str,str.GetLength());
fil.Write(A,1);
fil.Write(strl,strl.GetLength());
fil.Write(D,1);
fil.Write(B,1);
fil.Write(C,1);
}
}
}
fil.Close();
}
void DataPutOut::Ondaochu2()
{
// TODO: Add your control notification handler code here
long max;
int t;
max=m_list1.GetItemCount();
for(long i=0;i<max;i++)
{
t=m_list1.GetCheck(i);
if(t)
{
m_list1.SetCheck(i,false);
}
else
{
m_list1.SetCheck(i,true);
}
}
}
void DataPutOut::Ondaochu3()
{
// TODO: Add your control notification handler code here
long max;
max=m_list1.GetItemCount();
for(long i=0;i<max;i++)
{
m_list1.SetCheck(i,true);
}
}
HBRUSH DataPutOut::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return m_brush;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -