📄 dialog1.cpp
字号:
// dialog1.cpp : implementation file
//
#include "stdafx.h"
#include "ScreenCopyV1.h"
#include "dialog1.h"
#include "fstream.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Cdialog1 dialog
Cdialog1::Cdialog1(CWnd* pParent /*=NULL*/)
: CDialog(Cdialog1::IDD, pParent)
{
str="配置.ini";
//{{AFX_DATA_INIT(Cdialog1)
m_Time = _T("");
// m_Time = _T(logdata.timer);
// MessageBox(logdata.timer);
//}}AFX_DATA_INIT
// m_Time=logdata.timer;
//UpdateData(false);
// MessageBox("logdata.timer");
bl=false;
}
void Cdialog1::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Cdialog1)
DDX_Text(pDX, IDC_EDIT1, m_Time);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Cdialog1, CDialog)
//{{AFX_MSG_MAP(Cdialog1)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_WM_CREATE()
ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Cdialog1 message handlers
void Cdialog1::OnButton1()
{
// TODO: Add your control notification handler code here
//更新数据
UpdateData(TRUE);
m_Time.TrimLeft();//简单的数据检验 (删除字符串左边开头的空白字符)
if(m_Time.Compare("")==0)
{
MessageBox("请输入时间","输入提示",MB_OK|MB_ICONSTOP);
}
else
{
logdata.timer=m_Time;
WriteFile(str,logdata);
}
}
//********************************************************************************
// 名称:WriteFile
//功能: 将类Data对象data中的信息写入文件str中
///********************************************************************************
void Cdialog1::WriteFile(CString str, Data &data)
{
fstream Wfile(str,ios::trunc|ios::out); //以写的方式打开文件并且把它清空为0
Wfile<<
data.filename<<endl<<
data.timer<<endl<<
data.bl<<endl;
/* data.rect.left<<endl<<
data.rect.right<<endl<<
data.rect.bottom<<endl<<
data.rect.top<<endl*/
Wfile.close();
}
//****************************
//下面的代码功能是文件夹浏览,并且把选择的文件路径存放在CString strPath中
//**********************************
void Cdialog1::OnButton3()
{
CString strPath;
BROWSEINFO bInfo;
LPITEMIDLIST pidl;
ZeroMemory ( (PVOID) &bInfo,sizeof (BROWSEINFO));
bInfo.hwndOwner = this->m_hWnd;
bInfo.pszDisplayName = strPath.GetBuffer (MAX_PATH);
bInfo.lpszTitle = "";
bInfo.ulFlags = BIF_RETURNFSANCESTORS|BIF_RETURNONLYFSDIRS;
bInfo.lpfn = NULL;
bInfo.lParam = 0;
// MessageBox(strPath);
if ((pidl = ::SHBrowseForFolder(&bInfo)) == NULL||(::SHGetPathFromIDList(pidl,strPath.GetBuffer(MAX_PATH)) == FALSE))
{
// MessageBox(strPath);
return;
}
else
{
logdata.filename=strPath;
}
// if (::SHGetPathFromIDList(pidl,strPath.GetBuffer(MAX_PATH)) == FALSE)
//{
// MessageBox(bInfo.pszDisplayName);
// return;
// }
//*****************************
//* 下面的代码是 建立一个保存或者打开文件对话框;
//* 拔除或者打开由第一个参数FALSE和TRUE决定
//*****************************
/*CFileDialog dlg(FALSE,NULL,NULL,OFN_FILEMUSTEXIST,"压缩图像(*.raw)|*.raw||",this);
if (IDOK!=dlg.DoModal())
{
return;
}
// CString m_sPathName=dlg.GetPathName();
*/}
int Cdialog1::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
//m_Time的赋值要在Cdialog1建立完成之后赋值,所以只能
//添加WM_CREATE消息 在它的消息处理函数里赋值
//或者在OnInitialUpdate()中
m_Time = _T(logdata.timer);
logdata.bl="0";
return 0;
}
//DEL void Cdialog1::OnRadio1()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL logdata.bl="1";
//DEL }
void Cdialog1::OnCheck1()
{
bl=!bl;
// TODO: Add your control notification handler code here
if(bl)
logdata.bl="1";
else
logdata.bl="0";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -