本文整理汇总了C++中GetOpenFileNameA函数的典型用法代码示例。如果您正苦于以下问题:C++ GetOpenFileNameA函数的具体用法?C++ GetOpenFileNameA怎么用?C++ GetOpenFileNameA使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetOpenFileNameA函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetOpenFileNameA_fix
/* MAKE_EXPORT GetOpenFileNameA_fix=GetOpenFileNameA */
BOOL WINAPI GetOpenFileNameA_fix(LPOPENFILENAMEA lpofn)
{
BOOL ret = GetOpenFileNameA(lpofn);
if (!ret && CommDlgExtendedError() == CDERR_STRUCTSIZE && lpofn
&& lpofn->lStructSize == sizeof(OPENFILENAME))
{
lpofn->lStructSize = OPENFILENAME_SIZE_VERSION_400A;
ret = GetOpenFileNameA(lpofn);
lpofn->lStructSize = sizeof(OPENFILENAME);
}
return ret;
}
示例2: GetDlgItemTextA
void ProjectConfigDialog::onSelectScriptFile(void)
{
char buff[MAX_PATH + 1] = {0};
char projdir[MAX_PATH + 1] = {0};
GetDlgItemTextA(m_hwndDialog, IDC_EDIT_PROJECT_DIR, projdir, MAX_PATH);
OPENFILENAMEA ofn = {0};
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = m_hwndDialog;
ofn.lpstrFilter = "Lua Script File (*.lua)\0*.lua\0";
ofn.lpstrTitle = "Select Script File";
if (DirectoryExists(projdir))
{
ofn.lpstrInitialDir = projdir;
}
ofn.Flags = OFN_DONTADDTORECENT | OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
ofn.lpstrFile = buff;
ofn.nMaxFile = MAX_PATH;
if (GetOpenFileNameA(&ofn))
{
m_project.setScriptFile(buff);
updateScriptFile();
}
}
示例3: WinMain
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nShowCmd)
{
char szPathName[MAX_PATH];
OPENFILENAMEA ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szPathName;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = "Win32 executable files\0*.exe\0\0";
ofn.nFilterIndex = 1;
ofn.lpstrTitle = "Choose a file to protect";
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
int key_pressed = MessageBoxA(NULL, "CProtector - protector for executables\nWould you like to choose a file to protect?",
"CProtector", MB_OKCANCEL | MB_ICONQUESTION);
if (key_pressed == IDCANCEL)
{
ExitProcess(0);
}
if(!GetOpenFileNameA(&ofn)) ExitProcess(0);
if(!ProtectFile(ofn.lpstrFile))
{
MessageBoxA(NULL, "Error occured : file is busy or error unknown","CProtector", MB_ICONERROR);
} else
{
MessageBoxA(NULL, "Protection installed","CProtector", MB_ICONINFORMATION);
}
ExitProcess(0);
}
示例4: OpenFileDialog
BOOL OpenFileDialog(HWND hwndDlg, OPENFILENAMEA*ofn, char*exe) {
//pointer zum exenamen
char* exename = NULL;
//buffer vom pfad
static char szFile[260] = ""; //static damit noch nach dem aufruf lesbar bleibt
//buffer vom filter
char szFilter[260] = "";
//backslash suchen
exename = strrchr(exe, '\\') + 1;
//kein backslash dann normal ret als exenamen verwenden
if ((int)exename == 1) exename = exe;
//filterstring aufbauen
mir_snprintf(szFilter, SIZEOF(szFilter), "%s|%s|%s|*.*|", exename, exename, Translate("All Files"));
//umbruch in 0 wandeln
unsigned int sizeFilter = strlen(szFilter);
for (unsigned int i = 0; i < sizeFilter; i++)
if (szFilter[i] == '|') szFilter[i] = 0;
//openfiledia vorbereiten
memset(ofn, 0, sizeof(OPENFILENAMEA));
ofn->lStructSize = sizeof(OPENFILENAMEA);
ofn->hwndOwner = hwndDlg;
ofn->lpstrFile = szFile;
ofn->nMaxFile = SIZEOF(szFile);
ofn->lpstrFilter = szFilter;
ofn->nFilterIndex = 1;
ofn->lpstrFileTitle = exe;
ofn->nMaxFileTitle = 0;
ofn->lpstrInitialDir = NULL;
ofn->Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
return GetOpenFileNameA(ofn);
}
示例5: sizeof
char* Platform::OpenFileDialog()
{
const int32 FileNameSize = MAX_PATH;
char* FileName = (char*)malloc(FileNameSize);
OPENFILENAME DialogParams = {};
DialogParams.lStructSize = sizeof(OPENFILENAME);
DialogParams.hwndOwner = GetActiveWindow();
DialogParams.lpstrFilter = "JPEG\0*.jpg;*.jpeg\0PNG\0*.png\0";
DialogParams.nFilterIndex = 2;
DialogParams.lpstrFile = FileName;
DialogParams.lpstrFile[0] = '\0';
DialogParams.nMaxFile = FileNameSize;
DialogParams.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
BOOL Result = GetOpenFileNameA(&DialogParams); // TODO: Unicode support?
if (Result)
{
return FileName;
}
else
{
free(FileName);
return 0;
}
}
示例6: ShowOpenFileDialog
bool ShowOpenFileDialog(char* FileName, int FileNameLength, char* filter)
// Open a dialog for selecting a file and returns true if succeeded with the name of the file in the preallocated buffer <FileName>
{
OPENFILENAMEA ofn ;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = GetActiveWindow();
ofn.lpstrDefExt = 0;
FileName[0] = '\0';
ofn.lpstrFile = FileName;
ofn.nMaxFile = FileNameLength;
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
char strAux[MAX_PATH];
GetCurrentDirectoryA(MAX_PATH, strAux);
ofn.lpstrInitialDir = strAux;
ofn.lpstrTitle = LPSTR("Open File");
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_ENABLESIZING;
GetOpenFileNameA(&ofn);
if (strlen(ofn.lpstrFile) == 0) return false;
return true;
} // ShowOpenFileDialog
示例7: memset
void
CTextureAtlasCreatorContext::Load()
{
CHAR8 strOpenName[512] = "";
OPENFILENAMEA FileName;
memset(&FileName, 0, sizeof(OPENFILENAMEA));
FileName.lStructSize = sizeof(OPENFILENAMEA);
FileName.hwndOwner = reinterpret_cast<HWND>(Ascension::Renderer().GetWindowHandle());
FileName.hInstance = reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL));
FileName.lpstrFilter = NULL;
FileName.lpstrCustomFilter = NULL;
FileName.nMaxCustFilter = NULL;
FileName.lpstrFilter = "Ascension Atlas Files\0*.ascatl;*.ascatledt*\0\0";
FileName.nFilterIndex = 2;
FileName.lpstrFile = strOpenName;
FileName.nMaxFile = 512;
FileName.lpstrFileTitle = NULL;
FileName.lpstrTitle = "Open Atlas";
FileName.Flags = OFN_EXPLORER;
if(TRUE == GetOpenFileNameA(&FileName))
{
LoadAtlas(strOpenName);
}
}
示例8: OnCompressOrDecompress
// TODO: fix alternate cohesion crap
void OnCompressOrDecompress(HWND sheet, bool compress)
{
int size, ret;
char path[_MAX_PATH];
if (!GetOpenFileNameA(sheet, path, sizeof(path)))
return;
size = fsize(path);
std::vector<unsigned char> buffer(size);
AutoFile fIn(path, "rb");
fread(&buffer[0], sizeof(char), size, fIn.get()); // contiguous
fIn.close();
path[0] = '\0'; // don't pre-fill path
if (!GetSaveFileNameA(sheet, path, sizeof(path)))
return;
AutoFile fOut(path, "wb");
if (compress)
ret = deflate_file(&buffer[0], size, fOut.get());
else
ret = inflate_file(&buffer[0], size, fOut.get());
fOut.close();
if (ret >= 0)
MessageBox(sheet, "Operation completed successfully.",
"Raw Compression/Decompression", MB_OK);
else
MessageBox(sheet, "Operation failed.",
"Raw Compression/Decompression", MB_ICONWARNING);
}
示例9: OpenFileDialog
// ^<見出し> '|' <拡張子パターン> ( ';' <拡張子パターン> )* '\n'
string_t OpenFileDialog(const char *title, const char *filter) {
OPENFILENAMEA ofn;
char szPath[MAX_PATH];
char szFile[MAX_PATH];
memset(&ofn, 0, sizeof(ofn));
memset(szPath, 0, sizeof(szPath));
memset(szFile, 0, sizeof(szFile));
GetCurrentDirectoryA(MAX_PATH, szPath);
char *fixuped_filter = fixup_filter(filter);
ofn.lStructSize = sizeof(OPENFILENAMEA);
ofn.hwndOwner = NULL;
ofn.lpstrInitialDir = szPath; // 初期フォルダを
ofn.lpstrFile = szFile; // 選択ファイルを入れるバッファ
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = fixuped_filter;
ofn.lpstrTitle = title;
ofn.Flags = OFN_EXPLORER|OFN_FILEMUSTEXIST;
if (GetOpenFileNameA(&ofn)) {
free(fixuped_filter);
return String.Create(szFile);
} else {
free(fixuped_filter);
return String.Create(NULL);
}
}
示例10: GetFile
int GetFile(char *szFileName, char *szParse=0,u32 flags=0)
{
cfgLoadStr("config","image",szFileName,"null");
if (strcmp(szFileName,"null")==0)
{
#if HOST_OS==OS_WINDOWS
OPENFILENAME ofn;
ZeroMemory( &ofn , sizeof( ofn));
ofn.lStructSize = sizeof ( ofn );
ofn.hwndOwner = NULL ;
ofn.lpstrFile = szFileName ;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = "All\0*.*\0\0";
ofn.nFilterIndex =1;
ofn.lpstrFileTitle = NULL ;
ofn.nMaxFileTitle = 0 ;
ofn.lpstrInitialDir=NULL ;
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ;
if (GetOpenFileNameA(&ofn))
{
//already there
//strcpy(szFileName,ofn.lpstrFile);
}
#endif
}
return 1;
}
示例11: GetOpenFileNameUTF8
BOOL GetOpenFileNameUTF8(LPOPENFILENAME lpofn)
{
#ifdef WDL_SUPPORT_WIN9X
if (GetVersion()&0x80000000) return GetOpenFileNameA(lpofn);
#endif
return GetOpenSaveFileNameUTF8(lpofn,FALSE);
}
示例12: sizeof
bool Window::open( char* dlgTitle, char* initDir, char* filterStr, char * resultFile )
{
OPENFILENAMEA ofn = { 0 };
ofn.Flags = OFN_FILEMUSTEXIST | // file user picks must exist, else dialog box won't return
OFN_PATHMUSTEXIST; // path must exist, else dialog box won't return
ofn.hInstance = hInstance ;
ofn.hwndOwner = hwnd;
ofn.lStructSize = sizeof(OPENFILENAMEA);
ofn.lpstrTitle = dlgTitle ;
ofn.lpstrInitialDir = initDir;
ofn.lpstrFilter = filterStr; //"md2 files (*.md2)\0*.md2\0All files (*.*)\0*.*\0\0";
ofn.lpstrFile = resultFile; // ptr to string that will contain
// FILE USER CHOSE when call to
// GetOpenFileNameA( &ofn ) returns.
ofn.nMaxFile = MAX_PATH; // length of the resultFile string
return (GetOpenFileNameA( &ofn )); // GetOpenFileName returns false
// when user clicks cancel, or if err
}
示例13: chooseFileName
std::string chooseFileName()
{
#ifdef _WINDOWS
OPENFILENAMEA ofn ;
static char szFile[_MAX_PATH] ;
ZeroMemory( &ofn , sizeof( ofn) );
ofn.lStructSize = sizeof ( ofn );
ofn.hwndOwner = NULL ;
ofn.lpstrFile = szFile ;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof( szFile );
ofn.lpstrFilter = "All\0*.*\0Images\0*.jpg;*.png\0";
ofn.nFilterIndex =1;
ofn.lpstrFileTitle = NULL ;
ofn.nMaxFileTitle = 0 ;
ofn.lpstrInitialDir=NULL ;
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ;
GetOpenFileNameA( &ofn );
return ofn.lpstrFile;
#else
return "";
#endif
}
示例14: showOpenDialog
std::string showOpenDialog(const std::string& caption, const FileTypes& extensions, const std::string& defaultFilename)
{
auto windowHandle = oWindow->getHandle();
char szFileName[MAX_PATH] = {0};
memcpy(szFileName, defaultFilename.c_str(), std::min(defaultFilename.size(), static_cast<size_t>(MAX_PATH - 1)));
OPENFILENAMEA ofn = {0};
ofn.lStructSize = sizeof(OPENFILENAMEA);
ofn.hwndOwner = windowHandle;
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR;
size_t totalCount = 0;
for (auto& fileType : extensions)
{
totalCount += fileType.typeName.size();
totalCount += fileType.extension.size();
}
char* szFilters = new char[21 + totalCount * 3 + 9 * extensions.size()];
size_t currentOffset = 0;
for (auto& fileType : extensions)
{
memcpy(szFilters + currentOffset, fileType.typeName.c_str(), fileType.typeName.size());
currentOffset += fileType.typeName.size();
memcpy(szFilters + currentOffset, " (*.", 4);
currentOffset += 4;
memcpy(szFilters + currentOffset, fileType.extension.c_str(), fileType.extension.size());
currentOffset += fileType.extension.size();
memcpy(szFilters + currentOffset, ")\0*.", 4);
currentOffset += 4;
memcpy(szFilters + currentOffset, fileType.extension.c_str(), fileType.extension.size());
currentOffset += fileType.extension.size();
memcpy(szFilters + currentOffset, "\0", 1);
currentOffset += 1;
}
memcpy(szFilters + currentOffset, "All Files (*.*)\0*.*\0\0", 21);
ofn.lpstrFilter = szFilters;
std::string defaultExtension = extensions[0].extension;
ofn.lpstrDefExt = defaultExtension.c_str();
ofn.lpstrTitle = caption.c_str();
// PNG Files (*.PNG)\0*.PNG\0All Files (*.*)\0*.*\0
GetOpenFileNameA(&ofn);
delete[] szFilters;
return ofn.lpstrFile;
}
示例15: OnFileTrigRead
/**
* Handles a user request to read triggers from above textual format.
*/
void OnFileTrigRead(HWND dialog)
{
char path[MAX_PATH] = "";
if (!GetOpenFileNameA(dialog, path, MAX_PATH))
return;
std::ifstream textin(path, std::ios_base::in);
TrigXmlReader reader;
reader.read(textin);
}