Advertisement
Khalibloo

UE4 Windows Show Open File Dialog (FileDialog.cpp)

Jul 22nd, 2018
888
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. #include "FileDialog.h"
  2.  
  3.  
  4. FileDialog::FileDialog(void){
  5.     this->DefaultExtension = 0;
  6.     this->FileName = new TCHAR[MAX_PATH];
  7.     this->Filter = 0;
  8.     this->FilterIndex = 0;
  9.     this->Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
  10.     this->InitialDir = 0;
  11.     this->Owner = 0;
  12.     this->Title = 0;
  13. }
  14.  
  15. bool FileDialog::ShowOpenFileDialog(){
  16.     OPENFILENAME ofn;
  17.     ZeroMemory(&ofn, sizeof(ofn));
  18.  
  19.     ofn.lStructSize = sizeof(ofn);
  20.     ofn.hwndOwner = this->Owner;
  21.     ofn.lpstrDefExt = this->DefaultExtension;
  22.     ofn.lpstrFile = this->FileName;
  23.     ofn.lpstrFile[0] = '\0';
  24.     ofn.nMaxFile = MAX_PATH;
  25.     ofn.lpstrFilter = this->Filter;
  26.     ofn.nFilterIndex = this->FilterIndex;
  27.     ofn.lpstrInitialDir = this->InitialDir;
  28.     ofn.lpstrTitle = this->Title;
  29.     ofn.Flags = this->Flags;
  30.  
  31.     GetOpenFileName(&ofn);
  32.     if (_tcslen(this->FileName) == 0) return false;
  33.  
  34.     return true;
  35. }
  36.  
  37. bool FileDialog::ShowSaveFileDialog() {
  38.     OPENFILENAME ofn;
  39.     ZeroMemory(&ofn, sizeof(ofn));
  40.  
  41.     ofn.lStructSize = sizeof(ofn);
  42.     ofn.hwndOwner = this->Owner;
  43.     ofn.lpstrDefExt = this->DefaultExtension;
  44.     ofn.lpstrFile = this->FileName;
  45.     ofn.lpstrFile[0] = '\0';
  46.     ofn.nMaxFile = MAX_PATH;
  47.     ofn.lpstrFilter = this->Filter;
  48.     ofn.nFilterIndex = this->FilterIndex;
  49.     ofn.lpstrInitialDir = this->InitialDir;
  50.     ofn.lpstrTitle = this->Title;
  51.     ofn.Flags = this->Flags;
  52.  
  53.     GetSaveFileName(&ofn);
  54.     if (_tcslen(this->FileName) == 0) return false;
  55.  
  56.     return true;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement