Re: [GD-Windows] Mind numbing GetOpenFileName Problem
Brought to you by:
vexxed72
From: Andrew G. <an...@ra...> - 2002-02-18 18:51:39
|
Why are you defining the Windows version? Just miss these out and use sizeof(OPENFILENAME). This is from one of my tools; char szFileName[256] = {0}; // make sure this is null terminated or windows barfs char szInitialDir[256]; // Display the OpenFileName dialog. Then, try to load the specified file OPENFILENAME ofn = { sizeof(OPENFILENAME), NULL, NULL, _T(".IMF Files (.x)\0*.imf\0\0"), NULL, 0, 1, szFileName, 256, NULL, 0, szInitialDir, _T("Open Mesh File"), OFN_FILEMUSTEXIST, 0, 1, NULL, 0, NULL, NULL }; if( TRUE == GetOpenFileName( &ofn ) ) { // andrew ----- Original Message ----- From: "Paul Crowder" <pa...@pa...> To: <gam...@li...> Sent: Friday, February 15, 2002 11:01 PM Subject: [GD-Windows] Mind numbing GetOpenFileName Problem > All I want is an open file dialog box, but no, windows has to cause me > problems. Ok, its probably a silly mistake but here goes. > I'm compiling with both these flags set: > #define _WIN32_WINNT 0x500 > #define WINVER 0x500 > > to try and get various things (mousewheel, ...) to co-operate. The problem > comes when I try and open a file dialog. The code is below. The > > sticking point appears to be the ofn.lStructSize line. When set using the > VERSION_400 flag is fails gracefully with CDERR_STRUCTSIZE. If I use > > sizeof( OPENFILENAME ) it just crashes in the kernel on GetOpenFileName. > This should be really simple to get up and running, but I don't know how > > get out of this hole I seem to have dug. With no error message, useful or > otherwise, I'm a bit stuck. > > (I apologise for the crap formatting but outlook express has decided to put > double carriage returns everywhere - go figure). > > cheers > > Paul > > char inputfile[256], outputfile[256], filename[256]; > char initdir[] = "d:\\Projects\\Clearday\\Data/0"; > char title[] = "Select file to process/0"; > > > OPENFILENAME ofn; > ofn.lStructSize = sizeof( OPENFILENAME_SIZE_VERSION_400 ); // = > izeof( OPENFILENAME ); > ofn.hwndOwner = hWnd; > char *filter = "Max ASE files/0*.ASE/0/0"; > ofn.lpstrFilter = NULL; > ofn.lpstrCustomFilter = NULL; > ofn.lpstrFile = inputfile; > ofn.nMaxFile = 256; > ofn.lpstrFileTitle = filename; > ofn.nMaxFileTitle = 256; > ofn.lpstrInitialDir = NULL; > ofn.lpstrTitle = NULL; > ofn.Flags = ( OFN_ENABLESIZING | OFN_FILEMUSTEXIST ); > > if( GetOpenFileName( &ofn )!=0 ) > { > _world.PreProcess( type, inputfile, outputfile ); > } > else > { > DWORD err = CommDlgExtendedError(); > if( err == CDERR_STRUCTSIZE ) > { > int a = 1; > } > } > > > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > |