📄 saverestore.cpp
字号:
// SaveRestore.cpp : implementation file
//
#include "stdafx.h"
#include "SaveRestore.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static OPENFILENAME ofn; // Used for file dialog boxes
CSaveRestore::CSaveRestore(void)
{
// your ad here
}
CSaveRestore::~CSaveRestore()
{
// your ad here
}
void CSaveRestore::WIN_popFileInitializeHEX( void )
{
static char szFilter[] = "HEX Files (*.hex)\0*.hex\0";
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = NULL;
ofn.hInstance = NULL;
ofn.lpstrFilter = szFilter;
ofn.lpstrDefExt = "hex";
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.lpstrFile = NULL; // Set in Open and Close functions
ofn.nMaxFile = _MAX_PATH;
ofn.lpstrFileTitle = NULL; // Set in Open and Close functions
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = NULL;
ofn.Flags = 0; // Set in Open and Close functions
ofn.nFileOffset = 0;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lCustData = 0L;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
}
void CSaveRestore::WIN_popFileInitializeBIN( void )
{
static char szFilter[] = "BIN Files (*.bin)\0*.bin\0";
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = NULL;
ofn.hInstance = NULL;
ofn.lpstrFilter = szFilter;
ofn.lpstrDefExt = "bin";
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.lpstrFile = NULL; // Set in Open and Close functions
ofn.nMaxFile = _MAX_PATH;
ofn.lpstrFileTitle = NULL; // Set in Open and Close functions
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = NULL;
ofn.Flags = 0; // Set in Open and Close functions
ofn.nFileOffset = 0;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lCustData = 0L;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
}
//-----------------------------------------------------------------
// WIN_Load_INI_File
//
// This function will execute the Load INI file.
//-----------------------------------------------------------------
//bool CSaveRestore::WIN_Load_INI_File(bool browse_flag, char *section, char *heading, char *datastr, int max_char )
//{
//
// bool result;
//
// if( browse_flag ) {
// WIN_popFileInitialize();
// if( WIN_GetBrowseFileName(szFileName, 1, 0) == TRUE ) {
// result = WIN_LoadIniFile( section, heading, datastr, max_char );
// }
// else
// result = FALSE;
// }
// else {
// result = WIN_LoadIniFile( section, heading, datastr, max_char );
// }
//
// return result;
//
//}
//-----------------------------------------------------------------
// WIN_Load_INI_File
//
// This function will execute the Load INI file.
//-----------------------------------------------------------------
//bool CSaveRestore::WIN_Save_INI_File(bool browse_flag, char *section, char *heading, char *datastr )
//{
//
// bool result;
//
// if( browse_flag ) {
// WIN_popFileInitialize();
// if( WIN_GetBrowseFileName(szFileName, 1, 1) == TRUE ) {
// result = WIN_SaveIniData( section, heading, datastr );
// }
// else
// result = FALSE;
// }
// else {
// result = WIN_SaveIniData( section, heading, datastr );
// }
//
// return result;
//
//}
//-----------------------------------------------------------------
// WIN_GetBrowseFileNameHEX
//
// This function will return a file name after a browse is completed.
//-----------------------------------------------------------------
bool CSaveRestore::WIN_GetBrowseFileName(char *szFileName, int id, int func )
{
bool bResults;
char szTemp[256];
if( id )
WIN_popFileInitializeHEX();
else
WIN_popFileInitializeBIN();
strcpy(szTemp, ""); // Must be initialized
switch( func ) {
default:
case 0:
bResults = WIN_PopFileOpenDlg(szTemp);
break;
case 1:
bResults = WIN_PopFileSaveDlg(szTemp);
if( bResults == TRUE )
unlink( szFileName );
break;
}
if(bResults == FALSE)
{
return(bResults);
}
strcpy( szFileName, szTemp );
return TRUE;
}
//-----------------------------------------------------------------
// WIN_PopFileOpenDlg
//
// This function will open the File Open dialog box.
//-----------------------------------------------------------------
bool CSaveRestore::WIN_PopFileOpenDlg(PSTR pstrFileName)
{
ofn.lpstrFile = pstrFileName;
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
return(GetOpenFileName(&ofn));
}
//-----------------------------------------------------------------
// WIN_PopFileSaveDlg
//
// This function will open the File Open dialog box.
//-----------------------------------------------------------------
bool CSaveRestore::WIN_PopFileSaveDlg(PSTR pstrFileName)
{
ofn.lpstrFile = pstrFileName;
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
return(GetSaveFileName(&ofn));
}
//bool CSaveRestore::WIN_LoadIniFile(char *section, char *heading, char *datastr, int max_char )
//{
//
// bool result;
//
// // Add your data to restore here
// GetPrivateProfileString( section, heading, "Not_Found", datastr, max_char, (char *)&szFileName );
//
// result = TRUE;
//
// return result;
//}
//bool CSaveRestore::WIN_SaveIniData( char *section, char *heading, char *datastr )
//{
// bool result;
//
// // Add your data to store here
// WritePrivateProfileString( section, heading, datastr, (char *)&szFileName );
//
// result = TRUE;
//
// return result;
//
//}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -