📄 dlgfileset.cpp
字号:
// DlgFileSet1.cpp : implementation file
//
#include "stdafx.h"
#include "CQuakeDemo.h"
#include "DlgFileSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgFileSet dialog
CDlgFileSet::CDlgFileSet(CWnd* pParent /*=NULL*/)
: CDialog(CDlgFileSet::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgFileSet)
//}}AFX_DATA_INIT
m_QFListSet.RemoveAll();
}
void CDlgFileSet::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgFileSet)
DDX_Control(pDX, IDC_EDIT_DATFPNAME, m_datfpname);
DDX_Control(pDX, IDC_EDIT_PICFPNAME, m_picfpname);
DDX_Control(pDX, IDC_STATIC_IMFORMATION, m_static_im);
DDX_Control(pDX, IDC_EDIT_FLOOR_SIZE, m_edit_floorsize);
DDX_Control(pDX, IDC_LIST_FLOOR, m_list_floor);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgFileSet, CDialog)
//{{AFX_MSG_MAP(CDlgFileSet)
ON_BN_CLICKED(IDC_BUTTON_SETFLOORSIZE, OnButtonSetfloorsize)
ON_NOTIFY(NM_CLICK, IDC_LIST_FLOOR, OnClickListFloor)
ON_BN_CLICKED(IDC_BUTTON_PICFPNAME, OnButtonPicfpname)
ON_BN_CLICKED(IDC_BUTTON_DATFPNAME, OnButtonDatfpname)
ON_EN_CHANGE(IDC_EDIT_PICFPNAME, OnChangeEditPicfpname)
ON_EN_CHANGE(IDC_EDIT_DATFPNAME, OnChangeEditDatfpname)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgFileSet message handlers
BOOL CDlgFileSet::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_edit_floorsize.SetLimitText(2);
m_edit_floorsize.SelectStockType(FDT_INTEGER);
//
CString str1, str2, str3;
str1.LoadString(IDS_STRING_DLGFILESET1);
str2.LoadString(IDS_STRING_DLGFILESET2);
str3.LoadString(IDS_STRING_DLGFILESET3);
m_list_floor.InsertColumn(0,str1,LVCFMT_LEFT,45);
m_list_floor.InsertColumn(1,str2,LVCFMT_LEFT,230);
m_list_floor.InsertColumn(2,str3,LVCFMT_LEFT,230);
m_list_floor.ModifyStyle(NULL,LVS_SHOWSELALWAYS);
m_list_floor.SetExtendedStyle(LVS_EX_FULLROWSELECT);
CString size;
size.Format(_T("%d"),m_QFListSet.GetSize());
m_edit_floorsize.SetWindowText(size);
FlashList();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgFileSet::FlashList()
{
m_list_floor.DeleteAllItems();
CString index;
for(int i = 0; i < m_QFListSet.GetSize(); i++)
{
index.Format(_T("%d"),m_QFListSet.GetSize()-i);
m_list_floor.InsertItem(i,_T(""));
for(int j = 0; j <3; j++)
{
switch(j)
{
case 0:m_list_floor.SetItemText(i,j,index);break;
case 1:m_list_floor.SetItemText(i,j,m_QFListSet.GetAt(i).PicFPName);break;
case 2:m_list_floor.SetItemText(i,j,m_QFListSet.GetAt(i).DataFPName);break;
}
}
}
}
void CDlgFileSet::OnButtonSetfloorsize()
{
CString title;
CString strTitle, strText;
strText.LoadString(IDS_STRING_DLGFILESET_1);
strTitle.LoadString(IDS_STRING_DLGFILESET_2);
m_edit_floorsize.GetWindowText(title);
int size = _ttol(title);
if(size <= 0 || size > 99)
{
MessageBox(strText,strTitle);
m_edit_floorsize.SetSel(0,-1);
return;
}
m_QFListSet.SetSize(size);
FlashList();
}
void CDlgFileSet::OnClickListFloor(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int index = m_list_floor.GetSelectionMark();
if(index == -1)return;
CString im;
CString strLoad;
strLoad.LoadString(IDS_STRING_DLGFILESET_PROMPT);
im.Format(strLoad,m_QFListSet.GetSize()-index);
m_static_im.SetWindowText(im);
//
m_picfpname.SetWindowText(m_QFListSet[index].PicFPName);
m_datfpname.SetWindowText(m_QFListSet[index].DataFPName);
*pResult = 0;
}
void CDlgFileSet::OnButtonPicfpname()
{
CString filepath;
// char szFileters[] = _T("图像文件(*.jpg) | *.jpg");
CString strLoad;
strLoad.LoadString(IDS_STRING_DLGFILESET_F1);
CFileDialog Select(true,_T(""),_T(""),OFN_FILEMUSTEXIST | OFN_LONGNAMES,strLoad,NULL);
if(Select.DoModal() == IDOK)
{
filepath = Select.GetPathName();
m_picfpname.SetWindowText(filepath);
}
}
void CDlgFileSet::OnButtonDatfpname()
{
CString filepath;
// char szFileters[] = _T("数据文件(*.dat) | *.dat");
CString strLoad;
strLoad.LoadString(IDS_STRING_DLGFILESET_F2);
CFileDialog Select(true,_T(""),_T(""),OFN_FILEMUSTEXIST | OFN_LONGNAMES,strLoad,NULL);
if(Select.DoModal() == IDOK)
{
filepath = Select.GetPathName();
m_datfpname.SetWindowText(filepath);
}
}
void CDlgFileSet::OnChangeEditPicfpname()
{
// 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.
int index = m_list_floor.GetSelectionMark();
if(index == -1)return;
m_picfpname.GetWindowText(m_QFListSet[index].PicFPName);
m_list_floor.SetItemText(index,1,m_QFListSet[index].PicFPName);
// TODO: Add your control notification handler code here
}
void CDlgFileSet::OnChangeEditDatfpname()
{
// 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.
int index = m_list_floor.GetSelectionMark();
if(index == -1)return;
m_datfpname.GetWindowText(m_QFListSet[index].DataFPName);
m_list_floor.SetItemText(index,2,m_QFListSet[index].DataFPName);
// TODO: Add your control notification handler code here
}
void CDlgFileSet::OnOK()
{
if(m_QFListSet.IsPNExist())
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -