예제 #1
0
/* MAKE_EXPORT GetSaveFileNameA_fix=GetSaveFileNameA */
BOOL WINAPI GetSaveFileNameA_fix(LPOPENFILENAMEA lpofn)
{
	BOOL ret = GetSaveFileNameA(lpofn);
	if (!ret && CommDlgExtendedError() == CDERR_STRUCTSIZE && lpofn 
		&& lpofn->lStructSize == sizeof(OPENFILENAME))
	{
		lpofn->lStructSize = OPENFILENAME_SIZE_VERSION_400A;
		ret = GetSaveFileNameA(lpofn);
		lpofn->lStructSize = sizeof(OPENFILENAME);
	}
	return ret;
}
예제 #2
0
void BotCfg_OnSave( HWND hDlg, BotCfgDlgSt *st )
{
    // change subdir to '.\configs'
    char curDir[256] = {0};
    char newDir[256] = {0};
    GetCurrentDirectoryA( 200, curDir );
    wsprintfA( newDir, "%s\\configs", curDir );
    SetCurrentDirectoryA( newDir );
    //
    char fileName[256] = {0};
    OPENFILENAMEA ofn;
    memset( &ofn, 0, sizeof(ofn) );
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = hDlg;
    ofn.hInstance = g_hInst;
    ofn.lpstrFilter = "Config files\0*.config\0All files\0*.*\0\0";
    ofn.lpstrFile = fileName;
    ofn.nMaxFile = 255;
    ofn.lpstrTitle = "Куда сохранять?";
    ofn.lpstrInitialDir = newDir;
    ofn.Flags = OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
    if( GetSaveFileNameA( &ofn ) )
    {
        if( strstr( fileName, ".config" ) == NULL ) strcat( fileName, ".config" );
        if( !st->myCfg.saveConfig( fileName ) )
        {
            MessageBox( hDlg, TEXT("Конфиг не сохранился!"), TEXT("Ашыпка!"), MB_ICONSTOP );
        }
    }
    // restore cur dir (required to load maps, for example)
    SetCurrentDirectoryA( curDir );
}
void 
CTextureAtlasCreatorContext::Save()
{
	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*\0\0";
	FileName.nFilterIndex = 1;
	FileName.lpstrFile = strOpenName;
	FileName.nMaxFile = 512;
	FileName.lpstrFileTitle = NULL;
	FileName.lpstrTitle = "Save File";
	FileName.Flags = OFN_EXPLORER;

	if(TRUE == GetSaveFileNameA(&FileName))
	{
		SaveAtlas(strOpenName);
	}
}
예제 #4
0
파일: win32_utf8.c 프로젝트: Artogn/licecap
BOOL GetSaveFileNameUTF8(LPOPENFILENAME lpofn)
{
#ifdef WDL_SUPPORT_WIN9X
  if (GetVersion()&0x80000000) return GetSaveFileNameA(lpofn);
#endif
  return GetOpenSaveFileNameUTF8(lpofn,TRUE);
}
예제 #5
0
int wingetsavepath(pdfapp_t *app, char *buf, int len)
{
	OPENFILENAMEA ofn;
	buf[0] = 0;
	if (strlen(filename) < (unsigned int)len)
		strcpy(buf, filename);
	memset(&ofn, 0, sizeof(OPENFILENAME));
	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hwndOwner = hwndframe;
	ofn.lpstrFile = buf;
	ofn.nMaxFile = len;
	ofn.lpstrInitialDir = NULL;
	ofn.lpstrTitle = "MuPDF: Save PDF file";
	ofn.lpstrFilter = "Documents (*.pdf;*.xps;*.cbz;*.zip)\0*.zip;*.cbz;*.xps;*.pdf\0PDF Files (*.pdf)\0*.pdf\0XPS Files (*.xps)\0*.xps\0CBZ Files (*.cbz;*.zip)\0*.zip;*.cbz\0All Files\0*\0\0";
	ofn.Flags = OFN_HIDEREADONLY;
	if (GetSaveFileNameA(&ofn))
	{
		if (strlen(buf) < sizeof(filename))
			strcpy(filename, buf);

		return 1;
	}
	else
	{
		return 0;
	}
}
string_t SaveFileDialog(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_OVERWRITEPROMPT;

	if (GetSaveFileNameA(&ofn)) {
		free(fixuped_filter);
		return String.Create(szFile);
	} else {
		free(fixuped_filter);
		return String.Create(NULL);
	}
}
예제 #7
0
	static String savefilename() {
		#ifdef _WIN32
		char *filter = "All Files (*.*)\0*.*\0";
		HWND owner = NULL;
		OPENFILENAME ofn;
		char fileName[MAX_PATH] = "";
		ZeroMemory(&ofn, sizeof(ofn));

		ofn.lStructSize = sizeof(OPENFILENAME);
		ofn.hwndOwner = owner;
		ofn.lpstrFilter = filter;
		ofn.lpstrFile = fileName;
		ofn.nMaxFile = MAX_PATH;
		ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
		ofn.lpstrDefExt = "";

		String fileNameStr;

		if ( GetSaveFileNameA(&ofn) )
			fileNameStr = fileName;

		return fileNameStr;
		#endif
		#ifdef linux
		return "";
		#endif
	}
예제 #8
0
파일: WindowClass.cpp 프로젝트: sdp0et/gtp
bool Window::savefile( char* dlgTitle, char* initDir, char* filterStr, char* resultFile )
{
  OPENFILENAMEA ofn = { 0 };
    
  ofn.Flags = OFN_OVERWRITEPROMPT |  // prompts in case selects file that exists
              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 (GetSaveFileNameA( &ofn ));   // GetOpenFileName returns false
                                       // when user clicks cancel, or if err
}
예제 #9
0
// 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);
}
예제 #10
0
파일: Files.cpp 프로젝트: Daivuk/onut
    std::string showSaveAsDialog(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

        GetSaveFileNameA(&ofn);

        delete[] szFilters;

        return ofn.lpstrFile;
    }
예제 #11
0
/**
 * Handles a user request to dump triggers to textual format.
 */
void OnFileTrigWrite(HWND dialog)
{
	char path[MAX_PATH] = "trigs.xml";

	// TODO: set the path to aokts directory.
	if (!GetSaveFileNameA(dialog, path, MAX_PATH))
		return;

	AutoFile textout(path, "w");
    std::ostringstream ss;
	scen.accept(TrigXmlVisitor(ss));
	fputs(ss.str().c_str(), textout.get());
}
/**
 * name:		DlgExIm_SaveFileName
 * desc:		displayes a slightly modified SaveFileName DialogBox
 * params:		hWndParent		- parent window
 *				pszTitle		- title for the dialog
 *				pszFilter		- the filters to offer
 *				pszFile			- this is the buffer to store the file to (size must be MAX_PATH)
 * return:		-1 on error/abort or filter index otherwise
 **/
int DlgExIm_SaveFileName(HWND hWndParent, LPCSTR pszTitle, LPCSTR pszFilter, LPSTR pszFile)
{
	OPENFILENAMEA ofn;
	CHAR szInitialDir[MAX_PATH];

	InitOpenFileNameStruct(&ofn, hWndParent, pszTitle, pszFilter, szInitialDir, pszFile);
	ofn.Flags |= OFN_OVERWRITEPROMPT;

	if (!GetSaveFileNameA(&ofn)) {
		DWORD dwError = CommDlgExtendedError();

		if (dwError) MsgErr(ofn.hwndOwner, LPGENT("The SaveFileDialog returned an error: %d!"), dwError);
		return -1;
	}
	SaveInitialDir(pszFile);
	return ofn.nFilterIndex;
}
예제 #13
0
BOOL SaveAEArtFile( const char *path, OPENFILENAMEA *ofn )
{
  memset( ofn, 0, sizeof(*ofn));
  ofn->lStructSize     = sizeof( OPENFILENAME );
  ofn->hwndOwner       = NULL;
  ofn->hInstance       = NULL;
  ofn->lpstrFilter     = (LPCSTR)"AsciiEngine Art Files\0*.AEArt\0\0";    
  (const char *)ofn->lpstrFile       = path;
  ofn->lpstrFile[0]    = '\0';
  ofn->nMaxFile        = MAX_PATH;
  ofn->lpstrTitle      = (LPCSTR)"Select A Location To Save To";
  ofn->Flags           = OFN_NONETWORKBUTTON |
                      OFN_PATHMUSTEXIST |
                      OFN_HIDEREADONLY;
  if (GetSaveFileNameA( ofn ))
    return( TRUE );
  return FALSE;
}
예제 #14
0
string savefilename(char *filter, HWND owner) 
{
	OPENFILENAMEA ofn;
	char fileName[MAX_PATH] = "";
	ZeroMemory(&ofn, sizeof(ofn));
	ofn.lStructSize   = sizeof(ofn);
	ofn.hwndOwner = owner;
	ofn.lpstrFile = fileName;
	ofn.nMaxFile = MAX_PATH;
	ofn.lpstrFilter = "Agile (*.agl)\0*.agl\0";   
	ofn.lpstrTitle = "Save File As";
	ofn.Flags = OFN_HIDEREADONLY; 
	ofn.lpstrDefExt = "txt";
	string fileNameStr;
	if ( GetSaveFileNameA(&ofn) )
	fileNameStr = fileName;
	return fileNameStr;
}
예제 #15
0
char* Platform::SaveFileDialog()
{
    const int32 FileNameSize = MAX_PATH;
    char* FileName = (char*)malloc(FileNameSize);

    OPENFILENAME DialogParams = {};
    DialogParams.lStructSize = sizeof(OPENFILENAME);
    DialogParams.hwndOwner = GetActiveWindow();
    DialogParams.lpstrFilter = "PNG\0*.png\0";
    DialogParams.nFilterIndex = 2;
    DialogParams.lpstrFile = FileName;
    DialogParams.lpstrFile[0] = '\0';
    DialogParams.nMaxFile = FileNameSize;
    DialogParams.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT;

    BOOL Result = GetSaveFileNameA(&DialogParams); // TODO: Unicode support?

    // Suffix .png if required
    {
        size_t L = strlen(FileName);
        if (L <= FileNameSize - 4 &&                                //
            !((FileName[L-4] == '.') &&                             // Ugh.
              (FileName[L-3] == 'p' || FileName[L-3] == 'P') &&     // TODO: Write some string utility functions
              (FileName[L-2] == 'n' || FileName[L-2] == 'N') &&     //       and clean this up.
              (FileName[L-1] == 'g' || FileName[L-1] == 'G')))      //       Also, support for more than just PNGs.
        {
            strcat(FileName, ".png");
        }
    }

    char Buffer[256];
    sprintf(Buffer, "%s\n", FileName);
    OutputDebugStringA(Buffer);

    if (Result)
    {
        return FileName;
    }
    else
    {
        free(FileName);
        return 0;
    }
}
예제 #16
0
파일: daf.cpp 프로젝트: philicious/hacnpx
VOID DumpFile(HWND hwndDlg)
{
	OPENFILENAMEA ofn;
	char DumpFileName[MAX_PATH];
	
	memset(&ofn, 0, sizeof(OPENFILENAME));
	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.lpstrFilter = "Executable files\0*.exe\0\0";
	ofn.lpstrFile = DumpFileName;
	ofn.nMaxFile = MAX_PATH;
	ofn.hwndOwner = hwndDlg;
	strcpy_s(DumpFileName, MAX_PATH, "dumped.exe");
	if (GetSaveFileNameA(&ofn))
	{
		//::memset(&text, 0, 1024);
		//GetDlgItemTextA(hDlg, IDC_OEPRVA, (LPSTR)&text, 8);
		//::DumpAndFixOep(g_pid, htodw((LPSTR)&text), dumpFileName);
		//::SetDlgItemTextA(hDlg, IDC_STATUS, "Dumping done...");
		DumpPE64(dwPid, DumpFileName);
	}
}
예제 #17
0
	static void LuaGuiChooseSaveFile(lua_State *pState, void *ownerWindow, const std::string &strFilter, const std::string &initialFile, const luabind::object &initialDir, const luabind::object &dialogTitle)
	{
		boost::optional<std::string> optInitialDir, optTitle;
		char buffer[MAX_PATH], fileTitle[MAX_PATH];
		OPENFILENAMEA ofn;
		BOOL result;

		memset(&ofn, 0, sizeof(ofn));
		strcpy_s(buffer, sizeof(buffer), initialFile.c_str());

		ofn.lStructSize = sizeof(ofn);
		ofn.hwndOwner = reinterpret_cast<HWND>(ownerWindow);
		ofn.lpstrFilter = strFilter.c_str();
		ofn.nFilterIndex = 1;
		ofn.lpstrFile = buffer;
		ofn.nMaxFile = sizeof(buffer);
		ofn.lpstrFileTitle = fileTitle;
		ofn.nMaxFileTitle = sizeof(fileTitle);
		ofn.lpstrInitialDir = (optInitialDir = luabind::object_cast_nothrow<std::string>(initialDir))
			? optInitialDir->c_str()
			: NULL;
		ofn.lpstrTitle = (optTitle = luabind::object_cast_nothrow<std::string>(dialogTitle))
			? optTitle->c_str()
			: NULL;
		ofn.Flags = OFN_PATHMUSTEXIST;

		result = GetSaveFileNameA(&ofn);

		lua_pushboolean(pState, result);
		if (result)
		{
			lua_pushfstring(pState, "%s", buffer);
			lua_pushfstring(pState, "%s", fileTitle);
		}
		else
		{
			lua_pushnil(pState);
			lua_pushnil(pState);
		}
	}
char* platform::save_file_dialog()
{
    const int32 file_nameSize = MAX_PATH;
    char* file_name = (char*)malloc(file_nameSize);

    OPENFILENAME dialog_params = {};
    dialog_params.lStructSize = sizeof(OPENFILENAME);
    dialog_params.hwndOwner = GetActiveWindow();
    dialog_params.lpstrFilter = "PNG\0*.png\0";
    dialog_params.nFilterIndex = 2;
    dialog_params.lpstrFile = file_name;
    dialog_params.lpstrFile[0] = '\0';
    dialog_params.nMaxFile = file_nameSize;
    dialog_params.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT;

    BOOL result = GetSaveFileNameA(&dialog_params); // TODO: Unicode support?

    // Suffix .png if required
    {
        size_t len = strlen(file_name);
        if (len <= file_nameSize - 4 &&                                   //
            !((file_name[len-4] == '.') &&                                // Ugh.
              (file_name[len-3] == 'p' || file_name[len-3] == 'P') &&     // TODO: Write some string utility functions
              (file_name[len-2] == 'n' || file_name[len-2] == 'N') &&     //       and clean this up.
              (file_name[len-1] == 'g' || file_name[len-1] == 'G'))) {    //       Also, support for more than just PNGs.
            strcat(file_name, ".png");
        }
    }

    char buffer[256];
    sprintf(buffer, "%s\n", file_name);
    OutputDebugStringA(buffer);

    if (result) {
        return file_name;
    } else {
        free(file_name);
        return 0;
    }
}
예제 #19
0
lString8 SaveFileDialog( HWND hWndOwner )
{
    lString8 fn;
    OPENFILENAMEA ofn;
    char str[MAX_PATH] = "";
    memset( &ofn, 0, sizeof(ofn) );
    ofn.lStructSize = sizeof( ofn );
    ofn.hwndOwner = hWndOwner;
    ofn.lpstrFilter = "WOL files (*.wol)\0*.wol\0All Files (*.*)\0*.*\0\0";
    ofn.nFilterIndex = 1;
    ofn.lpstrFile = str;
    ofn.nMaxFile = MAX_PATH;
    ofn.lpstrTitle = "Please select book to open";
    ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
    ofn.lpstrDefExt = "wol";
//    ofn.FlagsEx = OFN_EX_NOPLACESBAR;
    if ( GetSaveFileNameA( &ofn ) )
    {
        fn = str;
    }
    return fn;
}
예제 #20
0
파일: CmFile.cpp 프로젝트: OpenHero/CmCode
string CmFile::BrowseFile(const char* strFilter, bool isOpen)
{
	static char Buffer[MAX_PATH];
	OPENFILENAMEA   ofn;  
	memset(&ofn, 0, sizeof(ofn));
	ofn.lStructSize = sizeof(ofn);
	ofn.lpstrFile = Buffer;
	ofn.lpstrFile[0] = '\0';   
	ofn.nMaxFile = MAX_PATH;   
	ofn.lpstrFilter = strFilter;   
	ofn.nFilterIndex = 1;    
	ofn.Flags = OFN_PATHMUSTEXIST;   

	if (isOpen) {
		ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
		GetOpenFileNameA(&ofn);
		return Buffer;
	}

	GetSaveFileNameA(&ofn);
	return string(Buffer);

}
예제 #21
0
bool EditorBase::SaveForm(
	const FILE_FORM_FILTER& filter,
	const char *szDir,
	char *szoFilePathName,
	char *szoFileName)
{
	char fileInfo[___OUTPUT_LENGTH] = "\0";
	char fileName[___OUTPUT_LENGTH];

	std::string sInitDir = Platform::AddLastSlash(szDir), out;

	OPENFILENAMEA saveFileName;
	saveFileName.lStructSize       = sizeof(saveFileName);
	saveFileName.hwndOwner         = NULL;
	saveFileName.hInstance         = 0;
	saveFileName.lpstrFilter       = AssembleWin32FilterString(filter, out);
	saveFileName.lpstrCustomFilter = NULL;
	saveFileName.nMaxCustFilter    = 0;
	saveFileName.nFilterIndex      = 1;
	saveFileName.lpstrFile         = fileInfo;
	saveFileName.nMaxFile          = ___OUTPUT_LENGTH;
	saveFileName.lpstrFileTitle    = fileName;
	saveFileName.nMaxFileTitle     = ___OUTPUT_LENGTH;
	saveFileName.lpstrInitialDir   = sInitDir.c_str();
	saveFileName.lpstrTitle        = NULL;
	saveFileName.Flags             = (OFN_OVERWRITEPROMPT);
	saveFileName.lpstrDefExt       = NULL;

	if (!GetSaveFileNameA(&saveFileName))
	{
		return false;
	}

	_ETH_SAFE_strcpy(szoFileName, fileName);
	_ETH_SAFE_strcpy(szoFilePathName, fileInfo);
	return true;
}
예제 #22
0
bool EditorBase::SaveForm(const char *filter, const char *szDir, char *szoFilePathName,
					   char *szoFileName, const char *szSolutionPath)
{
	char fileInfo[___OUTPUT_LENGTH] = "\0";
	char fileName[___OUTPUT_LENGTH];
	string sInitDir = szSolutionPath;

	// sInitDir += "\\";
	sInitDir += Platform::AddLastSlash(szDir);
	assert(DirectoryExists(sInitDir));

	OPENFILENAMEA saveFileName;
	saveFileName.lStructSize       = sizeof(saveFileName);
	saveFileName.hwndOwner         = NULL;
	saveFileName.hInstance         = 0;
	saveFileName.lpstrFilter       = filter;
	saveFileName.lpstrCustomFilter = NULL;
	saveFileName.nMaxCustFilter    = 0;
	saveFileName.nFilterIndex      = 1;
	saveFileName.lpstrFile         = fileInfo;
	saveFileName.nMaxFile          = ___OUTPUT_LENGTH;
	saveFileName.lpstrFileTitle    = fileName;
	saveFileName.nMaxFileTitle     = ___OUTPUT_LENGTH;
	saveFileName.lpstrInitialDir   = sInitDir.c_str();
	saveFileName.lpstrTitle        = NULL;
	saveFileName.Flags             = (OFN_OVERWRITEPROMPT);
	saveFileName.lpstrDefExt       = NULL;

	if (!GetSaveFileNameA(&saveFileName))
	{
		return false;
	}

	_ETH_SAFE_strcpy(szoFileName, fileName);
	_ETH_SAFE_strcpy(szoFilePathName, fileInfo);
	return true;
}
예제 #23
0
static void choose_destination_file_and_convert(HWND hwnd, struct prg2wav_params *params)
{
  char name[1024] = "";
  OPENFILENAMEA ofn;
  BOOL success;
  int freq;
  struct tapdec_params tapdec_params;
  struct play_pause_stop play_pause_stop = { .pause = 0 };
  HANDLE thread;
  DWORD thread_id;
  MSG msg;
  BOOL end_found = FALSE;
  uint8_t videotype;
  LRESULT selected_clock, selected_waveform;
  HBITMAP stop_icon;
  BOOL is_to_sound;

  name[0] = 0;
  freq = GetDlgItemInt(hwnd, IDC_FREQ, &success, FALSE);
  if (!success)
    freq = 44100;
  tapdec_params.volume = GetDlgItemInt(hwnd, IDC_VOL, &success, FALSE);
  if (!success)
    tapdec_params.volume = 254;
  if (tapdec_params.volume < 1)
    tapdec_params.volume = 1;
  tapdec_params.inverted = (IsDlgButtonChecked(hwnd, IDC_INVERTED) == BST_CHECKED);
  selected_clock =
    SendMessage(GetDlgItem(hwnd, IDC_MACHINE_TO), CB_GETCURSEL, 0, 0);
  switch(selected_clock){
    default:
      params->machine = TAP_MACHINE_C64;
      videotype = TAP_VIDEOTYPE_PAL;
      break;
    case 1:
      params->machine = TAP_MACHINE_C64;
      videotype = TAP_VIDEOTYPE_NTSC;
      break;
    case 2:
      params->machine = TAP_MACHINE_VIC;
      videotype = TAP_VIDEOTYPE_PAL;
      break;
    case 3:
      params->machine = TAP_MACHINE_VIC;
      videotype = TAP_VIDEOTYPE_NTSC;
      break;
    case 4:
      params->machine = TAP_MACHINE_C16;
      videotype = TAP_VIDEOTYPE_PAL;
      break;
    case 5:
      params->machine = TAP_MACHINE_C16;
      videotype = TAP_VIDEOTYPE_NTSC;
      break;
  }
  selected_waveform =
    SendMessage(GetDlgItem(hwnd, IDC_WAVEFORM), CB_GETCURSEL, 0, 0);
  switch(selected_waveform){
    default:
      tapdec_params.waveform = AUDIOTAP_WAVE_TRIANGLE;
      break;
    case 1:
      tapdec_params.waveform = AUDIOTAP_WAVE_SQUARE;
      break;
    case 2:
      tapdec_params.waveform = AUDIOTAP_WAVE_SINE;
      break;
  }

  if (IsDlgButtonChecked(hwnd, IDC_TO_WAV)) {
    if (audiotap_startup_status.audiofile_init_status != LIBRARY_OK) {
      MessageBoxA(hwnd,
                 "Cannot save to WAV: audiofile.dll is missing, invalid or incorrectly installed",
                 "WAV-PRG error", MB_ICONERROR);
      remove_all_simple_block_list_elements(&params->program);
      return;
    }
    memset(&ofn, 0, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = hwnd;
    ofn.lpstrFilter = "WAV files\0*.wav\0All files\0*.*\0\0";
    ofn.Flags = (OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT);
    ofn.lpstrFile = name;
    ofn.nMaxFile = sizeof(name);
    ofn.lpstrTitle = "Choose the WAV file to save to";
    ofn.lpstrDefExt = "wav";
    ofn.lpstrFile = name;
    ofn.nMaxFile = sizeof(name);

    if (!GetSaveFileNameA(&ofn)) {
      remove_all_simple_block_list_elements(&params->program);
      return;
    }
    if (tap2audio_open_to_wavfile4(&play_pause_stop.file, name, &tapdec_params, freq,
                            params->machine, videotype) != AUDIOTAP_OK) {
      MessageBoxA(hwnd, "Error opening file", "WAV-PRG error", MB_ICONERROR);
      remove_all_simple_block_list_elements(&params->program);
      return;
    }
  }
  else if (IsDlgButtonChecked(hwnd, IDC_TO_SOUND)) {
    if (audiotap_startup_status.portaudio_init_status != LIBRARY_OK) {
      MessageBoxA(hwnd,
                 "Cannot play to sound card: libportaudio.dll is missing, invalid or incorrectly installed",
                 "WAV-PRG error", MB_ICONERROR);
      remove_all_simple_block_list_elements(&params->program);
      return;
    }
    if (tap2audio_open_to_soundcard4(&play_pause_stop.file, &tapdec_params, freq,
                            params->machine, videotype) != AUDIOTAP_OK) {
      MessageBoxA(hwnd, "Error opening sound card", "WAV-PRG error",
                 MB_ICONERROR);
      remove_all_simple_block_list_elements(&params->program);
      return;
    }
  }
  else {
    uint8_t version;

    memset(&ofn, 0, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = hwnd;
    ofn.lpstrFilter = "TAP files\0*.tap\0All files\0*.*\0\0";
    ofn.Flags = (OFN_EXPLORER
                 | OFN_HIDEREADONLY
                 | OFN_OVERWRITEPROMPT | OFN_ENABLETEMPLATE | OFN_ENABLEHOOK);
    ofn.lpstrFile = name;
    ofn.nMaxFile = sizeof(name);
    ofn.lpstrTitle = "Choose the TAP file to save to";
    ofn.lpstrDefExt = "tap";
    ofn.lpfnHook = tap_save_hook_proc;
    ofn.lpstrFile = name;
    ofn.nMaxFile = sizeof(name);
    ofn.hInstance = instance;
    ofn.lpTemplateName = MAKEINTRESOURCEA(IDD_CHOOSE_TAP_VERSION);
    ofn.lCustData = (LPARAM)&version;

    if (!GetSaveFileNameA(&ofn)) {
      remove_all_simple_block_list_elements(&params->program);
      return;
    }
    if (tap2audio_open_to_tapfile3(&play_pause_stop.file, name, version, params->machine, videotype) !=
        AUDIOTAP_OK) {
      MessageBoxA(hwnd, "Error opening TAP file", "WAV-PRG error",
                 MB_ICONERROR);
      remove_all_simple_block_list_elements(&params->program);
      return;
    }
  }

  params->file = play_pause_stop.file;

  params->status_window =
    CreateDialog(instance, MAKEINTRESOURCE(IDD_PRG2WAV_STATUS), hwnd,
                 prg2wav_status_window_proc);
  EnableWindow(hwnd, FALSE);
  ShowWindow(params->status_window, SW_SHOWNORMAL);
  UpdateWindow(params->status_window);
  SetWindowLong(params->status_window, GWL_USERDATA, (LONG)&play_pause_stop);
  thread = CreateThread(NULL, 0, prg2wav_thread, params, 0, &thread_id);
  is_to_sound = IsDlgButtonChecked(hwnd, IDC_TO_SOUND);
  if (is_to_sound) {
    HWND stop_button = GetDlgItem(params->status_window, IDCANCEL);
    RECT window_rect, play_pause_button_rect;
    stop_icon = LoadBitmap(instance, MAKEINTRESOURCE(IDB_STOP));
    play_pause_stop.play_icon = LoadBitmap(instance, MAKEINTRESOURCE(IDB_PLAY));
    play_pause_stop.pause_icon = LoadBitmap(instance, MAKEINTRESOURCE(IDB_PAUSE));
    /* make sure the pause button is visible and shows the pause icon*/
    SendDlgItemMessage(params->status_window, IDC_PLAYPAUSE, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)play_pause_stop.pause_icon);
    ShowWindow(GetDlgItem(params->status_window, IDC_PLAYPAUSE), SW_SHOW);
    /* get width of window */
    GetClientRect(params->status_window, &window_rect);
    /* get absolute position of play-pause button */
    GetWindowRect(GetDlgItem(params->status_window, IDC_PLAYPAUSE), &play_pause_button_rect);
    /* get position of play-pause button within window */
    MapWindowPoints(NULL, params->status_window, (LPPOINT)&play_pause_button_rect, 2);
    /* make stop button as big as play-pause button, top-aligned and symmetrically placed */
    MoveWindow(stop_button,
      window_rect.right - play_pause_button_rect.right,
      play_pause_button_rect.top,
      play_pause_button_rect.right - play_pause_button_rect.left,
      play_pause_button_rect.bottom - play_pause_button_rect.top,
      TRUE);
    /* make sure the stop button shows the stop icon instead of the word Cancel*/
    SetWindowLongPtr(stop_button, GWL_STYLE, GetWindowLongPtr(stop_button, GWL_STYLE) | BS_BITMAP);
    SendDlgItemMessage(params->status_window, IDCANCEL, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)stop_icon);
  }

  while (1) {
    DWORD retval;
    retval =
      MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_ALLINPUT);
    if (retval == WAIT_OBJECT_0)
      break;
    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
      if (is_to_sound && msg.message == WM_KEYDOWN) {
        if (msg.wParam == VK_MEDIA_PLAY_PAUSE)
          PostMessage (params->status_window, WM_COMMAND, IDC_PLAYPAUSE, 0);
        else if (msg.wParam == VK_MEDIA_STOP)
          PostMessage (params->status_window, WM_COMMAND, IDCANCEL, 0);
      }
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }
  }

  EnableWindow(hwnd, TRUE);
  DestroyWindow(params->status_window);

  tap2audio_close(params->file);
  remove_all_simple_block_list_elements(&params->program);
  if (IsDlgButtonChecked(hwnd, IDC_TO_SOUND)) {
    DeleteObject(play_pause_stop.play_icon);
    DeleteObject(play_pause_stop.pause_icon);
    DeleteObject(stop_icon);
  }
}

static void choose_file(HWND hwnd){
  char name[1024] = "";
  OPENFILENAMEA ofn;
  struct prg2wav_params params;

  params.program = NULL;

  memset(&ofn, 0, sizeof(ofn));
  ofn.lStructSize = sizeof(ofn);
  ofn.hwndOwner = hwnd;
  ofn.hInstance = instance;
  ofn.lpstrFilter =
    "All supported types\0*.t64;*.prg;*.p00\0Tape image files (*.t64)\0*.t64\0Program files (*.prg)\0*.prg\0PC64 files (*.p00)\0*.p00\0All files\0*.*\0\0";
  ofn.lpstrCustomFilter = NULL;
  ofn.nMaxCustFilter = 0;
  ofn.nFilterIndex = 1;
  ofn.lpstrFile = name;
  ofn.nMaxFile = sizeof(name);
  ofn.lpstrFileTitle = NULL;
  ofn.nMaxFileTitle = 0;
  ofn.lpstrInitialDir = NULL;
  ofn.lpstrTitle = "Choose the PRG, P00 or T64 file";
  ofn.Flags = (OFN_EXPLORER
               | OFN_HIDEREADONLY
               | OFN_NOTESTFILECREATE
               | OFN_FILEMUSTEXIST
               | OFN_ENABLEHOOK | OFN_ENABLETEMPLATE | OFN_SHAREAWARE);
  ofn.lpfnHook = frompc_hook_proc;
  ofn.lpTemplateName = MAKEINTRESOURCEA(IDD_CONTENTS);
  ofn.nFileOffset = 0;
  ofn.nFileExtension = 0;
  ofn.lpstrDefExt = NULL;
  ofn.lCustData = (LPARAM)&params.program;

  if (GetOpenFileNameA(&ofn))
    choose_destination_file_and_convert(hwnd, &params);
}
예제 #24
0
static int MCA_do_file_dialog(MCExecPoint& ep, const char *p_title, const char *p_prompt, const char *p_filter, const char *p_initial, unsigned int p_options)
{
	int t_result = 0;

	char *t_initial_file;
	t_initial_file = NULL;

	char *t_initial_folder;
	t_initial_folder = NULL;

	ep . clear();

	if (*p_initial != '\0')
	{
		char *t_initial_clone;
		t_initial_clone = strdup(p_initial);
		MCU_w32path2std(t_initial_clone);
		MCU_fix_path(t_initial_clone);

		if (MCS_exists(t_initial_clone, False))
			t_initial_folder = t_initial_clone;
		else if ((p_options & MCA_OPTION_SAVE_DIALOG) != 0)
		{
			t_initial_file = strrchr(t_initial_clone, '/');
			if (t_initial_file == NULL)
			{
				if (strlen(t_initial_clone) != 0)
					t_initial_file = t_initial_clone;
			}
			else
			{
				*t_initial_file = '\0';
				t_initial_file++;
				
				if (t_initial_file[0] == '\0')
					t_initial_file = NULL;

				if (MCS_exists(t_initial_clone, False))
					t_initial_folder = t_initial_clone;
			}
		}
		else
		{
			char *t_leaf;
			t_leaf = strrchr(t_initial_clone, '/');
			if (t_leaf != NULL)
			{
				*t_leaf = '\0';
				if (MCS_exists(t_initial_clone, False))
					t_initial_folder = t_initial_clone;
			}
		}

		t_initial_file = strdup(t_initial_file);
		t_initial_folder = MCS_resolvepath(t_initial_folder);

		delete t_initial_clone;
	}

	if (!MCModeMakeLocalWindows())
	{
		char ** t_filters = NULL;
		uint32_t t_filter_count = 0;

		if (p_filter != NULL)
		{
			const char *t_strptr = p_filter;
			while (t_strptr[0] != '\0')
			{
				t_filter_count++;
				t_filters = (char**)realloc(t_filters, t_filter_count * sizeof(char*));
				t_filters[t_filter_count - 1] = (char *)t_strptr;
				t_strptr += strlen(t_strptr) + 1;
			}
		}

		MCRemoteFileDialog(ep, p_title, p_prompt, t_filters, t_filter_count, t_initial_folder, t_initial_file, (p_options & MCA_OPTION_SAVE_DIALOG) != 0, (p_options & MCA_OPTION_PLURAL) != 0);

		free(t_filters);
		return 0;
	}

	Window t_window;
	t_window = MCModeGetParentWindow();

	bool t_succeeded;
	int t_filter_index;

	if (MCmajorosversion >= 0x0600)
	{
		static SHCreateItemFromParsingNamePtr  s_shcreateitemfromparsingname = NULL;
		if (s_shcreateitemfromparsingname == NULL)
		{
			static HMODULE s_shell32_module = NULL;
			s_shell32_module = LoadLibraryA("shell32.dll");
			s_shcreateitemfromparsingname = (SHCreateItemFromParsingNamePtr)GetProcAddress(s_shell32_module, "SHCreateItemFromParsingName");
		}

		IFileSaveDialog *t_file_save_dialog;
		IFileOpenDialog *t_file_open_dialog;
		IFileDialog *t_file_dialog;

		t_file_dialog = NULL;

		HRESULT t_hresult;

		if ((p_options & MCA_OPTION_SAVE_DIALOG) == 0)
		{
			t_hresult = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, __uuidof(IFileOpenDialog), (LPVOID *)&t_file_open_dialog);
			t_succeeded = SUCCEEDED(t_hresult);

			t_file_dialog = t_file_open_dialog;
		}
		else
		{
			t_hresult = CoCreateInstance(CLSID_FileSaveDialog, NULL, CLSCTX_INPROC_SERVER, __uuidof(IFileSaveDialog), (LPVOID *)&t_file_save_dialog);
			t_succeeded = SUCCEEDED(t_hresult);

			t_file_dialog = t_file_save_dialog;
		}

		if (t_succeeded)
		{
			DWORD t_options;

			t_options = FOS_FORCEFILESYSTEM | FOS_NOCHANGEDIR | FOS_PATHMUSTEXIST;
			if (p_options & MCA_OPTION_PLURAL)
				t_options |= FOS_ALLOWMULTISELECT;
			if (p_options & MCA_OPTION_SAVE_DIALOG)
				t_options |= FOS_OVERWRITEPROMPT;
			if (p_options & MCA_OPTION_FOLDER_DIALOG)
				t_options |= FOS_PICKFOLDERS;
			else
				t_options |= FOS_FILEMUSTEXIST;

			t_hresult = t_file_dialog -> SetOptions(t_options);
			t_succeeded = SUCCEEDED(t_hresult);
		}

		if (t_succeeded && t_initial_folder != NULL)
		{
			IShellItem *t_initial_folder_shellitem;
			t_initial_folder_shellitem = NULL;
			t_hresult = s_shcreateitemfromparsingname(WideCString(t_initial_folder), NULL, __uuidof(IShellItem), (LPVOID *)&t_initial_folder_shellitem);
			if (SUCCEEDED(t_hresult))
				t_file_dialog -> SetFolder(t_initial_folder_shellitem);
			if (t_initial_folder_shellitem != NULL)
				t_initial_folder_shellitem -> Release();
			t_succeeded = SUCCEEDED(t_hresult);
		}

		if (t_succeeded && t_initial_file != NULL)
		{
			t_hresult = t_file_dialog -> SetFileName(WideCString(t_initial_file));
			t_succeeded = SUCCEEDED(t_hresult);
		}

		if (t_succeeded && p_filter != NULL && (p_options & MCA_OPTION_FOLDER_DIALOG) == 0)
		{
			uint4 t_filter_length, t_filter_count;
			measure_filter(p_filter, t_filter_length, t_filter_count);

			WideCString t_filters(p_filter, t_filter_length);
			COMDLG_FILTERSPEC *t_filter_spec;

			filter_to_spec(t_filters, t_filter_count, t_filter_spec);

			t_hresult = t_file_dialog -> SetFileTypes(t_filter_count, t_filter_spec);
			t_succeeded = SUCCEEDED(t_hresult);

			delete t_filter_spec;
		}

		if (t_succeeded && p_filter != NULL && (p_options & MCA_OPTION_FOLDER_DIALOG) == 0)
		{
			t_hresult = t_file_dialog -> SetFileTypeIndex(1);
			t_succeeded = SUCCEEDED(t_hresult);
		}

		if (t_succeeded)
			t_hresult = t_file_dialog -> SetTitle(WideCString(p_prompt));

		if (t_succeeded)
		{
			t_hresult = t_file_dialog -> Show(t_window != NULL ? (HWND)t_window -> handle . window : NULL);
			t_succeeded = SUCCEEDED(t_hresult);
		}

		if ((p_options & MCA_OPTION_SAVE_DIALOG) == 0)
		{
			IShellItemArray *t_file_items;
			t_file_items = NULL;
			if (t_succeeded)
			{
				t_hresult = t_file_open_dialog -> GetResults(&t_file_items);
				t_succeeded = SUCCEEDED(t_hresult);
			}

			DWORD t_file_item_count;
			if (t_succeeded)
			{
				t_hresult = t_file_items -> GetCount(&t_file_item_count);
				t_succeeded = SUCCEEDED(t_hresult);
			}

			if (t_succeeded)
			{
				ep . clear();
				for(uint4 t_index = 0; t_index < t_file_item_count && t_succeeded; ++t_index)
				{
					IShellItem *t_file_item;
					t_file_item = NULL;
					if (t_succeeded)
					{
						t_hresult = t_file_items -> GetItemAt(t_index, &t_file_item);
						t_succeeded = SUCCEEDED(t_hresult);
					}

					if (t_succeeded)
					{
						t_hresult = append_shellitem_path_and_release(ep, t_file_item, t_index == 0);
						t_succeeded = SUCCEEDED(t_hresult);
					}
				}
			}

			if (t_file_items != NULL)
				t_file_items -> Release();
		}
		else
		{
			IShellItem *t_file_item;
			t_file_item = NULL;
			if (t_succeeded)
			{
				t_hresult = t_file_dialog -> GetResult(&t_file_item);
				t_succeeded = SUCCEEDED(t_hresult);
			}

			if (t_succeeded)
			{
				ep . clear();
				t_hresult = append_shellitem_path_and_release(ep, t_file_item, true);
				t_succeeded = SUCCEEDED(t_hresult);
			}
		}

		t_filter_index = 0;
		if (t_succeeded && (p_options & MCA_OPTION_FOLDER_DIALOG) == 0)
		{
			UINT t_index;
			t_hresult = t_file_dialog -> GetFileTypeIndex(&t_index);
			t_succeeded = SUCCEEDED(t_hresult);
			if (t_succeeded)
				t_filter_index = (int)t_index;
		}

		if (t_file_dialog != NULL)
			t_file_dialog -> Release();

		if (!t_succeeded)
			t_result = t_hresult;
		else
			t_result = 0;
	}
	else
	{
		OPENFILENAMEA t_open_dialog;
		memset(&t_open_dialog, 0, sizeof(OPENFILENAMEA));
		t_open_dialog . lStructSize = sizeof(OPENFILENAMEA);

		char *t_initial_file_buffer = new char[MAX_PATH];
		if (t_initial_file != NULL)
			strcpy(t_initial_file_buffer, t_initial_file);
		else
			*t_initial_file_buffer = '\0';

		t_open_dialog . lpstrFilter = p_filter;
		t_open_dialog . nFilterIndex = 1;
		t_open_dialog . lpstrFile = t_initial_file_buffer;
		t_open_dialog . nMaxFile = MAX_PATH;
		t_open_dialog . lpstrInitialDir = t_initial_folder;
		t_open_dialog . lpstrTitle = p_prompt;
		t_open_dialog . Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR |
														OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_EXPLORER |
														OFN_ENABLEHOOK | OFN_ENABLESIZING;

		if (p_options & MCA_OPTION_PLURAL)
			t_open_dialog . Flags |= OFN_ALLOWMULTISELECT;

		if (p_options & MCA_OPTION_SAVE_DIALOG)
			t_open_dialog . Flags |= OFN_OVERWRITEPROMPT;

		t_open_dialog . lpstrFilter = p_filter;
		t_open_dialog . lpfnHook = open_dialog_hook;
		t_open_dialog . hwndOwner = t_window != NULL ? (HWND)t_window -> handle . window : NULL;

		if (p_options & MCA_OPTION_SAVE_DIALOG)
			t_succeeded = GetSaveFileNameA((LPOPENFILENAMEA)&t_open_dialog) == TRUE;
		else
		{
			*t_open_dialog . lpstrFile = '\0';
			t_succeeded = GetOpenFileNameA((LPOPENFILENAMEA)&t_open_dialog) == TRUE;
		}

		if (!t_succeeded)
			t_result = CommDlgExtendedError();

		// MW-2005-07-26: Try again without the specified filename if it was invalid
		if (t_result == FNERR_INVALIDFILENAME)
		{
			*t_open_dialog . lpstrFile = '\0';
			if (p_options & MCA_OPTION_SAVE_DIALOG)
				t_succeeded = GetSaveFileNameA((LPOPENFILENAMEA)&t_open_dialog) == TRUE;
			else
				t_succeeded = GetOpenFileNameA((LPOPENFILENAMEA)&t_open_dialog) == TRUE;

			if (!t_succeeded)
				t_result = CommDlgExtendedError();	
		}

		if (t_result == FNERR_BUFFERTOOSMALL)
			t_succeeded = true;

		if (t_succeeded)
		{
			build_paths(ep);
			t_filter_index = t_open_dialog . nFilterIndex;
		}

		delete t_initial_file_buffer;
	}

	if (t_succeeded)
	{
		if (p_options & MCA_OPTION_RETURN_FILTER)
		{
			const char *t_type = p_filter;
			const char *t_types = p_filter;
			for(int t_index = t_filter_index * 2 - 1; t_index > 1; t_types += 1)
				if (*t_types == '\0')
					t_type = t_types + 1, t_index -= 1;
			MCresult -> copysvalue(t_type);
		}

		t_result = 0;
	}

	waitonbutton();

	if (t_initial_folder != NULL)
		delete t_initial_folder;

	if (t_initial_file != NULL)
		delete t_initial_file;

	return t_result;
}
예제 #25
0
파일: filedlg.c 프로젝트: wesgarner/wine
/* bug 6829 */
static void test_DialogCancel(void)
{
    OPENFILENAMEA ofn;
    BOOL result;
    char szFileName[MAX_PATH] = "";
    char szInitialDir[MAX_PATH];

    GetWindowsDirectory(szInitialDir, MAX_PATH);

    ZeroMemory(&ofn, sizeof(ofn));

    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = NULL;
    ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
    ofn.lpstrFile = szFileName;
    ofn.nMaxFile = MAX_PATH;
    ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLEHOOK;
    ofn.lpstrDefExt = "txt";
    ofn.lpfnHook = OFNHookProc;
    ofn.lpstrInitialDir = szInitialDir;

    PrintDlgA(NULL);
    ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
       "expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());

    result = GetOpenFileNameA(&ofn);
    ok(0 == result, "expected 0, got %d\n", result);
    ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
       CommDlgExtendedError());

    PrintDlgA(NULL);
    ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
       "expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());

    result = GetSaveFileNameA(&ofn);
    ok(0 == result, "expected 0, got %d\n", result);
    ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
       CommDlgExtendedError());

    PrintDlgA(NULL);
    ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
       "expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());

    /* Before passing the ofn to Unicode functions, remove the ANSI strings */
    ofn.lpstrFilter = NULL;
    ofn.lpstrInitialDir = NULL;
    ofn.lpstrDefExt = NULL;

    PrintDlgA(NULL);
    ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
       "expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());

    SetLastError(0xdeadbeef);
    result = GetOpenFileNameW((LPOPENFILENAMEW) &ofn);
    if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
        win_skip("GetOpenFileNameW is not implemented\n");
    else
    {
        ok(0 == result, "expected 0, got %d\n", result);
        ok(0 == CommDlgExtendedError() ||
           broken(CDERR_INITIALIZATION == CommDlgExtendedError()), /* win9x */
           "expected 0, got %d\n", CommDlgExtendedError());
    }

    SetLastError(0xdeadbeef);
    result = GetSaveFileNameW((LPOPENFILENAMEW) &ofn);
    if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
        win_skip("GetSaveFileNameW is not implemented\n");
    else
    {
        ok(0 == result, "expected 0, got %d\n", result);
        ok(0 == CommDlgExtendedError() ||
           broken(CDERR_INITIALIZATION == CommDlgExtendedError()), /* win9x */
           "expected 0, got %d\n", CommDlgExtendedError());
    }
}
예제 #26
0
std::vector<std::string> file_dialog(const std::vector<std::pair<std::string, std::string>> &filetypes, bool save, bool multiple) {
    static const int FILE_DIALOG_MAX_BUFFER = 16384;
    if (save && multiple) {
        throw std::invalid_argument("save and multiple must not both be true.");
    }

#if defined(_WIN32)
    OPENFILENAME ofn;
    ZeroMemory(&ofn, sizeof(OPENFILENAME));
    ofn.lStructSize = sizeof(OPENFILENAME);
    char tmp[FILE_DIALOG_MAX_BUFFER];
    ofn.lpstrFile = tmp;
    ZeroMemory(tmp, FILE_DIALOG_MAX_BUFFER);
    ofn.nMaxFile = FILE_DIALOG_MAX_BUFFER;
    ofn.nFilterIndex = 1;

    std::string filter;

    if (!save && filetypes.size() > 1) {
        filter.append("Supported file types (");
        for (size_t i = 0; i < filetypes.size(); ++i) {
            filter.append("*.");
            filter.append(filetypes[i].first);
            if (i + 1 < filetypes.size())
                filter.append(";");
        }
        filter.append(")");
        filter.push_back('\0');
        for (size_t i = 0; i < filetypes.size(); ++i) {
            filter.append("*.");
            filter.append(filetypes[i].first);
            if (i + 1 < filetypes.size())
                filter.append(";");
        }
        filter.push_back('\0');
    }
    for (auto pair : filetypes) {
        filter.append(pair.second);
        filter.append(" (*.");
        filter.append(pair.first);
        filter.append(")");
        filter.push_back('\0');
        filter.append("*.");
        filter.append(pair.first);
        filter.push_back('\0');
    }
    filter.push_back('\0');
    ofn.lpstrFilter = filter.data();

    if (save) {
        ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
        if (GetSaveFileNameA(&ofn) == FALSE)
            return {};
    } else {
        ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
        if (multiple)
            ofn.Flags |= OFN_ALLOWMULTISELECT;
        if (GetOpenFileNameA(&ofn) == FALSE)
            return {};
    }

    size_t i = 0;
    std::vector<std::string> result;
    while (tmp[i] != '\0') {
        result.emplace_back(&tmp[i]);
        i += result.back().size() + 1;
    }

    if (result.size() > 1) {
        for (i = 1; i < result.size(); ++i) {
            result[i] = result[0] + "\\" + result[i];
        }
        result.erase(begin(result));
    }

    return result;
#else
    char buffer[FILE_DIALOG_MAX_BUFFER];
    buffer[0] = '\0';

    std::string cmd = "zenity --file-selection ";
    // The safest separator for multiple selected paths is /, since / can never occur
    // in file names. Only where two paths are concatenated will there be two / following
    // each other.
    if (multiple)
        cmd += "--multiple --separator=\"/\" ";
    if (save)
        cmd += "--save ";
    cmd += "--file-filter=\"";
    for (auto pair : filetypes)
        cmd += "\"*." + pair.first + "\" ";
    cmd += "\"";
    FILE *output = popen(cmd.c_str(), "r");
    if (output == nullptr)
        throw std::runtime_error("popen() failed -- could not launch zenity!");
    while (fgets(buffer, FILE_DIALOG_MAX_BUFFER, output) != NULL)
        ;
    pclose(output);
    std::string paths(buffer);
    paths.erase(std::remove(paths.begin(), paths.end(), '\n'), paths.end());

    std::vector<std::string> result;
    while (!paths.empty()) {
        size_t end = paths.find("//");
        if (end == std::string::npos) {
            result.emplace_back(paths);
            paths = "";
        } else {
            result.emplace_back(paths.substr(0, end));
            paths = paths.substr(end + 1);
        }
    }

    return result;
#endif
}
예제 #27
0
BBString *bbSystemRequestFile( BBString *text,BBString *exts,int defext,int save,BBString *file,BBString *dir ){

	BBString *str=&bbEmptyString;
	
	if( _usew ){
		wchar_t buf[MAX_PATH];
		OPENFILENAMEW of={sizeof(of)};
		
		wcscpy( buf,bbTmpWString( file ) );

		of.hwndOwner=GetActiveWindow();
		of.lpstrTitle=bbTmpWString( text );
		of.lpstrFilter=bbTmpWString( exts );
		of.nFilterIndex=defext;
		of.lpstrFile=buf;
		of.lpstrInitialDir=dir->length ? bbTmpWString( dir ) : 0;
		of.nMaxFile=MAX_PATH;
		of.Flags=OFN_HIDEREADONLY|OFN_NOCHANGEDIR;
		
		beginPanel();
		if( save ){
			of.lpstrDefExt=L"";
			of.Flags|=OFN_OVERWRITEPROMPT;
			if( GetSaveFileNameW( &of ) ){
				str=bbStringFromWString( buf );
			}
		}else{
			of.Flags|=OFN_FILEMUSTEXIST;
			if( GetOpenFileNameW( &of ) ){
				str=bbStringFromWString( buf );
			}
		}
		endPanel();
	}else{
		char buf[MAX_PATH];
		OPENFILENAMEA of={sizeof(of)};

		strcpy( buf,bbTmpCString( file ) );

		of.hwndOwner=GetActiveWindow();
		of.lpstrTitle=bbTmpCString( text );
		of.lpstrFilter=bbTmpCString( exts );
		of.nFilterIndex=defext;
		of.lpstrFile=buf;
		of.lpstrInitialDir=dir->length ? bbTmpCString( dir ) : 0;
		of.nMaxFile=MAX_PATH;
		of.Flags=OFN_HIDEREADONLY|OFN_NOCHANGEDIR;
		
		beginPanel();
		
		if( save ){
			of.lpstrDefExt="";
			of.Flags|=OFN_OVERWRITEPROMPT;
			if( GetSaveFileNameA( &of ) ){
				str=bbStringFromCString( buf );
			}
		}else{
			of.Flags|=OFN_FILEMUSTEXIST;
			if( GetOpenFileNameA( &of ) ){
				str=bbStringFromCString( buf );
			}
		}
		endPanel();
	}
	return str;
}
INT_PTR CALLBACK DlgProc(HWND hdlg, UINT wmsg, WPARAM wparam, LPARAM lparam){
	HANDLE phandle;
	ULONG index;
	OPENFILENAME ofn;
	HICON icon;

	switch (wmsg){
		case WM_INITDIALOG:
			GlobalList = GetDlgItem(hdlg, IDC_LIST1);
			icon = ::LoadIconA(GetModuleHandleA(0), (LPSTR)IDI_ICON1);
			SendMessageA(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)icon);
			SendMessageA(GlobalList, LB_RESETCONTENT, 0,0);
			::EnumProcesses(pids, 4096 * sizeof(DWORD), &needed);
			num_of_processes = needed / sizeof(DWORD);
			for (DWORD i = 0; i < num_of_processes; i++){
				phandle = ::OpenProcess(PROCESS_ALL_ACCESS, false, pids[i]);
				if (!phandle){
					wsprintf(buffer, "%.04X - process can't be opened", pids[i]);
					SendMessageA(GlobalList, LB_ADDSTRING, 0, (LPARAM)buffer);
					continue;
				}
				
				if (!EnumProcessModules(phandle, modules, 4096 * sizeof(HMODULE), &needed)){
					::CloseHandle(phandle);
					wsprintfA(buffer, "%.04X - can't obtain name", pids[i]);
					SendMessageA(GlobalList, LB_ADDSTRING, 0, (LPARAM)buffer);
					continue;
				}

				if (!::GetModuleFileNameExA(phandle, modules[0], proc_name, 4096)){
					::CloseHandle(phandle);
					wsprintfA(buffer, "%.04X - can't obtain name", pids[i]);
					SendMessageA(GlobalList, LB_ADDSTRING, 0, (LPARAM)buffer);
					continue;
				}

				wsprintfA(buffer, "%.04X - %s", pids[i], proc_name);
				SendMessageA(GlobalList, LB_ADDSTRING, 0, (LPARAM)buffer);
				::CloseHandle(phandle);
			}
			return 1;
		case WM_CLOSE:
			EndDialog(hdlg, 0);
			return 1;
		case WM_COMMAND:
			if (wparam == ID_DUMP){
				index = SendMessageA(GlobalList, LB_GETCURSEL, 0,0);
				if (index == LB_ERR){
					MessageBoxA(hdlg, "select process for dumping...", 0, 0);
					return 1;
				}
				mym(&ofn, 0, sizeof(OPENFILENAME));
				ofn.lStructSize = sizeof(OPENFILENAME);
				ofn.lpstrFilter = "Anyfile\0*.*\0\0";
				ofn.lpstrFile = (LPSTR)x_alloc(MAX_PATH);
				ofn.nMaxFile = MAX_PATH;
				ofn.hwndOwner = hdlg;
				if (!GetSaveFileNameA(&ofn)){
					MessageBoxA(hdlg, "select some file...", 0, 0);
					x_free(ofn.lpstrFile);
					return 1;
				}

				char *dir_name = ofn.lpstrFile + ::lstrlenA(ofn.lpstrFile) + 1;
				while (*dir_name != '\\')
					dir_name--;
				
				dir_name[0] = 0;
				dump_all(pids[index], ofn.lpstrFile);
				MessageBoxA(hdlg, "duming done...", "success", 0);
				x_free(ofn.lpstrFile);
				return 1;
			}
			
			if (wparam == ID_REFRESH){
				SendMessageA(GlobalList, LB_RESETCONTENT, 0,0);
				::EnumProcesses(pids, 4096 * sizeof(DWORD), &needed);
				num_of_processes = needed / sizeof(DWORD);
				for (DWORD i = 0; i < num_of_processes; i++){
					phandle = ::OpenProcess(PROCESS_ALL_ACCESS, false, pids[i]);
					if (!phandle){
						wsprintf(buffer, "%.04X - process can't be opened", pids[i]);
						SendMessageA(GlobalList, LB_ADDSTRING, 0, (LPARAM)buffer);
						continue;
					}
				
					if (!EnumProcessModules(phandle, modules, 4096 * sizeof(HMODULE), &needed)){
						::CloseHandle(phandle);
						wsprintfA(buffer, "%.04X - can't obtain name", pids[i]);
						SendMessageA(GlobalList, LB_ADDSTRING, 0, (LPARAM)buffer);
						continue;
					}

					if (!::GetModuleFileNameExA(phandle, modules[0], proc_name, 4096)){
						::CloseHandle(phandle);
						wsprintfA(buffer, "%.04X - can't obtain name", pids[i]);
						SendMessageA(GlobalList, LB_ADDSTRING, 0, (LPARAM)buffer);
						continue;
					}

					wsprintfA(buffer, "%.04X - %s", pids[i], proc_name);
					SendMessageA(GlobalList, LB_ADDSTRING, 0, (LPARAM)buffer);
					::CloseHandle(phandle);
				}
				return 1;
			}
		default:
			return 0;
	}

	return 0;
}
예제 #29
0
파일: dialog.c 프로젝트: aijiekj/drmingw
static LRESULT CALLBACK
WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_CREATE:
        {
            // Newer rich edit controls are much faster
            // http://blogs.msdn.com/b/murrays/archive/2006/10/14/richedit-versions.aspx
            // https://msdn.microsoft.com/en-us/library/windows/desktop/hh298375.aspx
            LoadLibraryA("riched20.dll");
            CreateWindowA(
                RICHEDIT_CLASS,
                "",
                WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_READONLY,
                CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                hwnd,
                (HMENU)IDC_MESSAGE,
                g_hInstance,
                NULL
            );

            // Set the background color to match the disabled edit control
            DWORD dwColor = GetSysColor(COLOR_3DFACE);
            SendDlgItemMessage(hwnd, IDC_MESSAGE, EM_SETBKGNDCOLOR, FALSE, dwColor);

            // We used to use GetStockObject(ANSI_FIXED_FONT), but it's known
            // to lead to unreliable results, particularly on Russion locales
            // or high-DPI displays, so now we match Notepad's default font.
            LOGFONTA lf = {
                10,                      // lfHeight
                0,                       // lfWidth
                0,                       // lfEscapement
                0,                       // lfOrientation
                FW_NORMAL,               // lfWeight
                FALSE,                   // lfItalic
                FALSE,                   // lfUnderline
                FALSE,                   // lfStrikeOut
                ANSI_CHARSET,            // lfCharSet
                0,                       // lfOutPrecision
                0,                       // lfClipPrecision
                DEFAULT_QUALITY,         // lfQuality
                FIXED_PITCH | FF_MODERN, // lfPitchAndFamily
                "Lucida Console"     // lfFaceName
            };

            // Apply the DPI scale factor
            // https://msdn.microsoft.com/en-us/library/windows/desktop/dn469266.aspx
            if (lf.lfHeight > 0) {
                HDC hdc = GetDC(NULL);
                int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
                ReleaseDC(NULL, hdc);

                lf.lfHeight = -MulDiv(lf.lfHeight, dpiY, 72);
            }

            HFONT hFont;
            hFont = CreateFontIndirectA(&lf);

            SendDlgItemMessage(hwnd, IDC_MESSAGE, WM_SETFONT, (WPARAM) hFont, MAKELPARAM(TRUE, 0));

            SendDlgItemMessage(hwnd, IDC_MESSAGE, EM_LIMITTEXT, ~(WPARAM)0, 0);
            break;
        }
        case WM_USER_APPEND_TEXT: {
            // http://support.microsoft.com/kb/109550
            HWND hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
            int ndx = GetWindowTextLength(hEdit);
            SetFocus(hEdit);
            SendMessage(hEdit, EM_SETSEL, (WPARAM) ndx, (LPARAM) ndx);
            SendMessage(hEdit, EM_REPLACESEL, (WPARAM) 0, lParam);
            free((void *)lParam);
            break;
        }
        case WM_SIZE:
            if(wParam != SIZE_MINIMIZED)
                MoveWindow(GetDlgItem(hwnd, IDC_MESSAGE), 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
            break;
        case WM_SETFOCUS:
            SetFocus(GetDlgItem(hwnd, IDC_MESSAGE));
            break;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case CM_FILE_SAVEAS:
                {
                    OPENFILENAMEA ofn;
                    char szFileName[MAX_PATH];

                    ZeroMemory(&ofn, sizeof(ofn));
                    szFileName[0] = 0;

                    ofn.lStructSize = sizeof(ofn);
                    ofn.hwndOwner = hwnd;
                    ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0";
                    ofn.lpstrFile = szFileName;
                    ofn.nMaxFile = MAX_PATH;
                    ofn.lpstrDefExt = "txt";

                    ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY |
                    OFN_OVERWRITEPROMPT;

                    if(GetSaveFileNameA(&ofn))
                    {
                        HANDLE hFile;
                        BOOL bSuccess = FALSE;

                        if((hFile = CreateFileA(szFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE)
                        {
                            HWND hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
                            DWORD dwTextLength = GetWindowTextLength(hEdit);
                            if(dwTextLength > 0) // No need to bother if there's no text.
                            {
                                LPSTR pszText;

                                if((pszText = GlobalAlloc(GPTR, dwTextLength + 1)) != NULL)
                                {
                                    if(GetWindowTextA(hEdit, pszText, dwTextLength + 1))
                                    {
                                        DWORD dwWritten;
                                        if(WriteFile(hFile, pszText, dwTextLength, &dwWritten, NULL))
                                            bSuccess = TRUE;
                                    }
                                    GlobalFree(pszText);
                                }
                            }
                            CloseHandle(hFile);
                        }

                        if(!bSuccess)
                            MessageBoxA(hwnd, "Save file failed.", "Error", MB_OK | MB_ICONEXCLAMATION);
                    }
                    break;
                }
                case CM_FILE_EXIT:
                    PostMessage(hwnd, WM_CLOSE, 0, 0);
                    break;

                case CM_HELP_ABOUT:
                    return DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc);
                  }
            break;
        case WM_CLOSE:
            DestroyWindow(hwnd);
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hwnd, Message, wParam, lParam);
    }
    return 0;
}
예제 #30
0
LRESULT CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    int             i = 0;
    char            saveFilePath[MAX_PATH];
    char            minLenStr[10];
    OPENFILENAMEA   saveFile;
    DWORD           threadId = 0;
    PTHREAD_ARGS    findStringsArg = NULL;

    switch (uMsg)
    {

    case WM_INITDIALOG:
    {
        _setViewColums(hDlg,FALSE,FALSE);
        SendDlgItemMessageA(hDlg, IDC_PROGRESS, PBM_SETSTEP, 1, (LPARAM)0);
        CheckDlgButton(hDlg, IDC_ASCII, BST_CHECKED);
        g_object = (PBYTE)CFFApi.eaGetObjectAddress(hDlg);
        g_stringsdone = FALSE;
        g_prevunicode = FALSE;
        break;
    }
    case WM_DESTROY:
    {
        SetEvent(g_event);
        break;
    }
    case WM_COMMAND:
    {
        switch (LOWORD(wParam))
        {
        case IDC_SAVE:
        {
            if (g_stringsdone)
            {
                ZeroMemory(saveFilePath, sizeof(saveFilePath));
                ZeroMemory(&saveFile, sizeof(saveFile));
                saveFile.lStructSize = sizeof(OPENFILENAMEA);
                saveFile.lpstrFile = saveFilePath;
                saveFile.nMaxFile = sizeof(saveFilePath);
                saveFile.lpstrDefExt = ".txt";
                saveFile.lpstrFilter = "Text File (.txt)\0*.txt\0\0";
                saveFile.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_CREATEPROMPT;
                if (GetSaveFileNameA(&saveFile))
                {
                    _saveListView(saveFilePath, hDlg);
                }
            }
            break;
        }
        case IDC_FINDSTRINGS:
        {

            if (NULL == g_thread)
            {
                if (NULL != (findStringsArg = calloc(sizeof(*findStringsArg),1)))
                {
                    ZeroMemory(minLenStr, sizeof(minLenStr));
                    Edit_GetText(GetDlgItem(hDlg, IDC_MINLEN), minLenStr, sizeof(minLenStr) - 1);

                    if (0 == strlen(minLenStr))
                    {
                        findStringsArg->minLen = 0;
                    }
                    else
                    {
                        findStringsArg->minLen = atoi(minLenStr);
                    }

                    if (IsDlgButtonChecked(hDlg, IDC_UNICODE) == BST_CHECKED)
                    {
                        findStringsArg->unicode = TRUE;
                    }

                    if (IsDlgButtonChecked(hDlg, IDC_OFFSETS) == BST_CHECKED)
                    {
                        findStringsArg->offsets = TRUE;
                    }

                    if (IsDlgButtonChecked(hDlg, IDC_ASCII) == BST_CHECKED)
                    {
                        findStringsArg->ascii = TRUE;
                    }

                    findStringsArg->hDlg = hDlg;

                    if (NULL == (g_thread = CreateThread(NULL, 0, _findStringThreadFunc, findStringsArg, 0, &threadId)))
                    {
                        free(findStringsArg);
                    }
                }
            }
        }
        }
    }
    }
    return FALSE;
}