示例#1
0
/* 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;
}
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
0
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
0
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);
}
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
0
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
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
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);
}
// ^<見出し> '|' <拡張子パターン> ( ';' <拡張子パターン> )* '\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
0
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
0
BOOL GetOpenFileNameUTF8(LPOPENFILENAME lpofn)
{
#ifdef WDL_SUPPORT_WIN9X
  if (GetVersion()&0x80000000) return GetOpenFileNameA(lpofn);
#endif
  return GetOpenSaveFileNameUTF8(lpofn,FALSE);
}
示例#12
0
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
0
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
0
文件: Files.cpp 项目: Daivuk/onut
    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
0
/**
 * 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);
}
示例#16
0
文件: window.cpp 项目: Igopin/TextPad
/* WM_COMMAND message processing */
void window::WMCommand(HWND &hwnd, UINT &message, WPARAM &wParam, LPARAM &lParam)
{
  int
    horz_range,
    vert_range;
  char
    buf[32],         /* Status bar text buffer */
    file_name[256];

  switch (wParam)
  {
  case IDM_OPEN:
    OpenFName.hwndOwner = hwnd;
    OpenFName.lpstrFile =  file_name;
    OpenFName.lpstrFileTitle = NULL;
    OpenFName.lpstrFile[0] = '\0';
    OpenFName.Flags = OFN_HIDEREADONLY | OFN_CREATEPROMPT;
    GetOpenFileNameA(&OpenFName);
    if (file_name[0] != 0)
    {
      txt.Reset();
      max_str_len = txt.LoadFile(file_name);

      vert_range = txt.num_of_str - client_field.y;
      if (vert_range < 0)
        vert_range = 0;

      if (vert_range > MAX_RANGE)
        vert_scrlb_step = (int)(ceil(vert_range * 1.0 / MAX_RANGE));
      else
        vert_scrlb_step = 1;
      SetScrollRange(hwnd, SB_VERT, 0, vert_range /= vert_scrlb_step, TRUE);
      SetScrollPos(hwnd, SB_VERT, 0, TRUE);
      SetScrollRange(hwnd, SB_HORZ, 0, max_str_len - client_field.x, TRUE);
      SetScrollPos(hwnd, SB_HORZ, 0, TRUE);
      start_str_pos = 0;
      sprintf(buf, "NUM OF STRINGS: %i", txt.GetNumOfStr());
      SendMessage(hStatWnd, SB_SETTEXT, (WPARAM)0, (LPARAM)buf);
      start_str_pos = 0;
    }
    break;
  case IDM_ABOUT:
    MessageBox(hwnd, "Igor Pinaev 2013 33601/1", "About", MB_ICONINFORMATION);
    break;
  case IDM_EXIT:
    SendMessage(hwnd, WM_CLOSE, 0, 0L);
    break;
  }

  InvalidateRect(hwnd, NULL, TRUE);
} /* End of 'window::WMCommand' function */
示例#17
0
	std::vector<std::string> OpenFileDialog(const char * filter)
	{
		char curDir[MAX_PATH];
		GetCurrentDirectoryA(MAX_PATH,curDir);
		std::vector<char> filedata(MAX_PATH * 1000);
		char * szFileName = &filedata[0];
		OPENFILENAMEA opf;
		opf.hwndOwner = 0;
		opf.lpstrFilter = filter;
		opf.lpstrCustomFilter = 0;
		opf.nMaxCustFilter = 0L;
		opf.nFilterIndex = 1L;
		opf.lpstrFile = szFileName;
		opf.nMaxFile = (DWORD)filedata.size();
		opf.lpstrFileTitle = 0;
		opf.nMaxFileTitle=50;
		opf.lpstrInitialDir = 0;
		opf.lpstrTitle = "Open";
		opf.nFileOffset = 0;
		opf.nFileExtension = 2;
		opf.lpstrDefExt = "*.*";
		opf.lpfnHook = NULL;
		opf.lCustData = 0;
		opf.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT | OFN_EXPLORER;
		//opf.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
		opf.lStructSize = sizeof(OPENFILENAMEA);
		std::vector<std::string> retval;
		if(GetOpenFileNameA(&opf))
		{
			if(opf.nFileOffset > strlen(szFileName))
			{
				std::string path = std::string(szFileName) + "\\";
				unsigned startOffset = opf.nFileOffset;
				while(szFileName[startOffset])
				{
					retval.push_back( path + std::string(&szFileName[startOffset]));
					startOffset += (unsigned int) strlen(&szFileName[startOffset])+1;
				}
			}
			else
				retval.push_back(szFileName);
		}
		else
		{
			DWORD retval = CommDlgExtendedError();
			while(0);
		}
		SetCurrentDirectoryA(curDir);
		return retval;
	}
/**
 * name:		DlgExIm_OpenFileName
 * desc:		displayes a slightly modified OpenFileName 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_OpenFileName(HWND hWndParent, LPCSTR pszTitle, LPCSTR pszFilter, LPSTR pszFile)
{
	OPENFILENAMEA ofn;
	CHAR szInitialDir[MAX_PATH];

	InitOpenFileNameStruct(&ofn, hWndParent, pszTitle, pszFilter, szInitialDir, pszFile);
	ofn.Flags |= OFN_PATHMUSTEXIST;
	if (!GetOpenFileNameA(&ofn)) {
		DWORD dwError = CommDlgExtendedError();
		if (dwError) MsgErr(ofn.hwndOwner, LPGENT("The OpenFileDialog returned an error: %d!"), dwError);
		return -1;
	}
	SaveInitialDir(pszFile);
	return ofn.nFilterIndex;
}
示例#19
0
文件: _global.cpp 项目: cdaze/akt
bool BrowseFileOpen(HWND owner, const char* filter, const char* defext, char* filename, int filename_size, const char* init_dir)
{
    OPENFILENAME ofstruct;
    memset(&ofstruct, 0, sizeof(ofstruct));
    ofstruct.lStructSize=sizeof(ofstruct);
    ofstruct.hwndOwner=owner;
    ofstruct.hInstance=hInst;
    ofstruct.lpstrFilter=filter;
    ofstruct.lpstrFile=filename;
    ofstruct.nMaxFile=filename_size;
    ofstruct.lpstrInitialDir=init_dir;
    ofstruct.lpstrDefExt=defext;
    ofstruct.Flags=OFN_EXTENSIONDIFFERENT|OFN_HIDEREADONLY|OFN_NONETWORKBUTTON;
    return GetOpenFileNameA(&ofstruct);
}
示例#20
0
//--------------------------------------------------------------------------------------
// Name: OpenXbeFile
// Desc: Allows the user to search for any given .xbe file to use with the emulator.
//--------------------------------------------------------------------------------------
bool OpenXbeFile( void )
{
	char filter[256] = {0};
	char filename[256] = {0};
	OPENFILENAMEA File;

	if( Xbe.m_bXbeHasBeenOpened )
		XBEUnload();

	strcat( filter, "XBox Executable Files (*.xbe)" );
	ZeroMemory( &File, sizeof( OPENFILENAME ) );

	int index = lstrlenA( filter ) + 1;
	filter[index++] = '*';
	filter[index++] = '.';
	filter[index++] = 'x';
	filter[index++] = 'b';
	filter[index++] = 'e';

	File.lStructSize = sizeof( OPENFILENAME );
	File.hwndOwner = GetActiveWindow();
	File.lpstrFilter = filter;
	File.lpstrFile = filename;
	File.nMaxFile = 256;
	File.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR;

	if( !GetOpenFileNameA( &File ) )
		return EmuError( "Unable to load file.\n" );

	// Back up the .exe data before executing
	EmuMMUSaveExeContents();

	// Now, actually load the .xbe into memory.
	if( !XBELoad( File.lpstrFile ) )
	{
		EmuError( "Unable to load Xbe file!\n" );
		return 0;
	}

	// Hijack kernel functions
	HookKrnlFunctions();

	// Activate other threads
	ResumeThread( g_hExecutionThread );
	ResumeThread( g_hUpdateThread );

	return true;
}
示例#21
0
文件: filedlg.c 项目: wesgarner/wine
static void test_create_view_window2(void)
{
    OPENFILENAMEA ofn = {0};
    char filename[1024] = {0};
    DWORD ret;

    ofn.lStructSize = sizeof(ofn);
    ofn.lpstrFile = filename;
    ofn.nMaxFile = 1024;
    ofn.lpfnHook = create_view_window2_hook;
    ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER;
    ret = GetOpenFileNameA(&ofn);
    ok(!ret, "GetOpenFileNameA returned %#x\n", ret);
    ret = CommDlgExtendedError();
    ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
}
示例#22
0
string openfilename(char *filter, HWND owner) 
{
	OPENFILENAMEA 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 ( GetOpenFileNameA(&ofn) )
	fileNameStr = fileName;
	return fileNameStr;
}
示例#23
0
文件: KeysTab.cpp 项目: cryham/cAmp
void cAmp::PlsOpen()
{
	OPENFILENAMEA ofn;  ZeroMemory(&ofn,sizeof(ofn));  ofn.lStructSize = sizeof(ofn);
	char szFile[MP], sDir[MP];	ofn.hwndOwner = hWnd;

	ofn.lpstrFile = szFile;  ofn.lpstrFile[0]='\0';  ofn.nMaxFile = sizeof(szFile);
	ofn.lpstrFilter = "cAmp Playlists (*.cp)\0*.cp\0";	ofn.nFilterIndex=1;
	ofn.lpstrFileTitle = NULL;	ofn.nMaxFileTitle = 0;

	scpy(sDir, cSnd::appPath.c_str());  sadd(sDir, "playlists");
	ofn.lpstrInitialDir = sDir;
	ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_ENABLESIZING|
		OFN_NOCHANGEDIR|OFN_NONETWORKBUTTON|OFN_HIDEREADONLY/*|OFN_ALLOWMULTISELECT*/;

	if (GetOpenFileNameA(&ofn)==TRUE)  {
		char* pp = strrchr(ofn.lpstrFile,'\\')+1, *pe = strrchr(ofn.lpstrFile,'.');  pe[0]=0;  //no dir,ext
		//dont duplicate pls names--
		pls->name = /*ofn.lpstrFile*/pp;  pls->Load();  }
}
示例#24
0
BOOL OpenAEArtFile( 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 File To Open";
  ofn->Flags           = OFN_NONETWORKBUTTON |
                      OFN_FILEMUSTEXIST |
                      OFN_PATHMUSTEXIST |
                      OFN_HIDEREADONLY;
  if (GetOpenFileNameA( ofn ))
    return( TRUE );
  return FALSE;
}
示例#25
0
文件: filedlg.c 项目: wesgarner/wine
static void test_create_view_template(void)
{
    OPENFILENAMEA ofn = {0};
    char filename[1024] = {0};
    DWORD ret;

    ofn.lStructSize = sizeof(ofn);
    ofn.lpstrFile = filename;
    ofn.nMaxFile = 1024;
    ofn.lpfnHook = (LPOFNHOOKPROC)template_hook;
    ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE;
    ofn.hInstance = GetModuleHandleA(NULL);
    ofn.lpTemplateName = "template1";
    ofn.lpstrFilter="text\0*.txt\0All\0*\0\0";
    ret = GetOpenFileNameA(&ofn);
    ok(!ret, "GetOpenFileNameA returned %#x\n", ret);
    ret = CommDlgExtendedError();
    ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
}
示例#26
0
int GetFile(char *szFileName, char *szParse=0,u32 flags=0) 
{
	cfgLoadStr("config","image",szFileName,"null");
	if (strcmp(szFileName,"null")==0)
	{
#if defined(OMAP4)
		strcpy(szFileName,GetPath("/gdimage/crazy_taxi.chd").c_str());
#else
	#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);
		}
	#else
		strcpy(szFileName,GetPath("/game.chd").c_str());
	#endif
#endif
	}

	if (strcmp(szFileName,"hardpath")==0)
	{
		strcpy(szFileName,"D:\\DC\\shenmue.chd");
	}

	
	return 1; 
}
std::string getFileName(HWND hWnd, PCHAR lpstrFilter, PCHAR lpstrTitle)
{
	EnableWindow(hWnd, false);
	CHAR szFileName[1000] = { 0 };
	OPENFILENAMEA ofn;
	ZeroMemory(&ofn, sizeof(OPENFILENAME));
	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hInstance = hInst;
	ofn.lpstrFilter = lpstrFilter;
	ofn.lpstrTitle = lpstrTitle;
	ofn.lpstrFile = szFileName;
	ofn.nMaxFile = sizeof(szFileName);
	ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
	std::string fileName;
	if (GetOpenFileNameA(&ofn))
		fileName.append(szFileName);
	EnableWindow(hWnd, true);
	SetFocus(hWnd);
	return fileName;
}
示例#28
0
std::string GetFilename()
{
#ifdef CPUT_OS_WINDOWS
    OPENFILENAMEA filename;
    CHAR file[MAX_PATH];
    ZeroMemory(file, sizeof(file));
    ZeroMemory(&filename, sizeof(OPENFILENAME));
    filename.lStructSize = sizeof(OPENFILENAME);
    filename.lpstrFile = file;
    filename.nMaxFile = MAX_PATH;
    filename.lpstrFilter = "*.scene\0\0";
    filename.nFilterIndex = 1;
    filename.lpstrInitialDir = NULL;
    filename.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
    GetOpenFileNameA(&filename);
    return std::string(filename.lpstrFile);
#else
    return std::string("");
#endif
}
示例#29
0
文件: SRB2MP.c 项目: HipsterLion/SRB2
//
// OpenWadfile
//
// Provides a common dialog box
// for selecting the desired wad file.
//
static inline VOID OpenWadfile(HWND hDlg)
{
	OPENFILENAMEA ofn;
	CHAR FileBuffer[256] = "";

	ZeroMemory(&ofn, sizeof(ofn));
	ofn.hwndOwner = hDlg;
	ofn.lpstrFilter = "WAD Files\0*.wad\0All Files\0*.*\0\0";
	ofn.lpstrInitialDir = NULL;
	ofn.lpstrFile = FileBuffer;
	ofn.lStructSize = sizeof(ofn);
	ofn.nMaxFile = sizeof(FileBuffer);
	ofn.nFilterIndex = 1;
	ofn.lpstrFileTitle = NULL;
	ofn.nMaxFileTitle = 0;
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;

	if (GetOpenFileNameA(&ofn))
		ReadWADLumps(FileBuffer, hDlg);
}
示例#30
0
static int TlenEnterBitmapName( char* szDest )
{
	OPENFILENAMEA ofn = {0};
	char str[ MAX_PATH ];
	char szFilter[ 512 ];
	*szDest = 0;
	CallService( MS_UTILS_GETBITMAPFILTERSTRINGS, sizeof szFilter, ( LPARAM )szFilter );
	str[0] = 0;
	ofn.lStructSize = sizeof( OPENFILENAME );
	ofn.lpstrFilter = szFilter;
	ofn.lpstrFile = szDest;
	ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
	ofn.nMaxFile = MAX_PATH;
	ofn.nMaxFileTitle = MAX_PATH;
	ofn.lpstrDefExt = "bmp";
	if ( !GetOpenFileNameA( &ofn ))
		return 1;

	return ERROR_SUCCESS;
}