MCPcopy Create free account
hub / github.com/NtQuery/Scylla / showFileDialog

Method showFileDialog

Scylla/MainGui.cpp:471–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469}
470
471bool MainGui::showFileDialog(WCHAR * selectedFile, bool save, const WCHAR * defFileName, const WCHAR * filter, const WCHAR * defExtension, const WCHAR * directory)
472{
473OPENFILENAME ofn = {0};
474
475 // WTL doesn't support new explorer styles on Vista and up
476 // This is because it uses a custom hook, we could remove it or derive
477 // from CFileDialog but this solution is easier and allows more control anyway (e.g. initial dir)
478
479 if(defFileName)
480 {
481 wcscpy_s(selectedFile, MAX_PATH, defFileName);
482 }
483 else
484 {
485 selectedFile[0] = L'\0';
486 }
487
488 ofn.lStructSize = sizeof(ofn);
489 ofn.hwndOwner = m_hWnd;
490 ofn.lpstrFilter = filter;
491 ofn.lpstrDefExt = defExtension; // only first 3 chars are used, no dots!
492 ofn.lpstrFile = selectedFile;
493 ofn.lpstrInitialDir = directory;
494 ofn.nMaxFile = MAX_PATH;
495 ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
496
497 /*
498 *OFN_EXPLORER is automatically used, it only has to be specified
499 *if using a custom hook
500 *OFN_LONGNAMES is automatically used by explorer-style dialogs
501 */
502
503 if(save)
504 ofn.Flags |= OFN_OVERWRITEPROMPT;
505 else
506 ofn.Flags |= OFN_FILEMUSTEXIST;
507
508 if(save)
509 return 0 != GetSaveFileName(&ofn);
510 else
511 return 0 != GetOpenFileName(&ofn);
512}
513
514void MainGui::setIconAndDialogCaption()
515{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected