mydialog.cpp

来自「A*算法」· C++ 代码 · 共 80 行

CPP
80
字号
// MyDialog.cpp: implementation of the CMyDialog class.
//
//////////////////////////////////////////////////////////////////////

#include "MyDialog.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMyDialog::CMyDialog(HWND hWnd,HINSTANCE hInstance)
{
	strcpy(szFilter,"所有文件\0");
	strcpy(szFile,"*.*\0");
	strcpy(szFileTitle,"\0");
	strcpy(szFileExt,"\0");
	strcpy(szInitDir,"\0");
    ofn.lStructSize       = sizeof(OPENFILENAME); 
    ofn.hwndOwner         = hWnd; 
    ofn.hInstance         = hInstance; 
    ofn.lpstrFilter       = szFilter; 
    ofn.lpstrCustomFilter = NULL; 
    ofn.nMaxCustFilter    = 0L; 
    ofn.nFilterIndex      = 1L; 
    ofn.lpstrFile         = szFile; 
    ofn.nMaxFile          = sizeof(szFile); 
    ofn.lpstrFileTitle    = szFileTitle; 
    ofn.nMaxFileTitle     = sizeof(szFileTitle); 
    ofn.lpstrInitialDir   = szInitDir; 
    ofn.lpstrTitle        =szFileTitle;
	ofn.Flags = OFN_OVERWRITEPROMPT|OFN_EXTENSIONDIFFERENT ;
    ofn.nFileOffset       = 0; 
    ofn.nFileExtension    = 3; 
    ofn.lpstrDefExt       =szFileExt; 
    ofn.lCustData         = 0; 
    ofn.lpfnHook          = NULL; 
    ofn.lpTemplateName    = NULL;
}

void CMyDialog::SetFilter(const char* filterString)
{
	strcpy(szFilter,filterString);
}

void CMyDialog::SetFileName(const char *fileNameString)
{
	strcpy(szFile,fileNameString);
}

void CMyDialog::SetInitDir(const char *dirString)
{
	strcpy(szInitDir,dirString);
}

bool CMyDialog::ShowSave()
{
	return GetSaveFileName(&ofn)!=0;
}

bool CMyDialog::ShowOpen()
{
	return GetOpenFileName(&ofn)!=0;
}

void CMyDialog::GetFileName(char *fileNameString)
{
	strcpy(fileNameString,szFileTitle);
}

void CMyDialog::GetFile(char *fileString)
{
	strcpy(fileString,szFile);
}


CMyDialog::~CMyDialog()
{

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?