Load file dialog

Posted By: crumply

Load file dialog - 08/03/09 14:48

Hey,

Is there a way I can get the standard windows file dialog to pop up so I can put a file's location into a string then load it?

I really need help with this one.

An alternative would be how to drag a file onto the executable and have it output a file.

Thanks

Ed
Posted By: Espér

Re: Load file dialog - 08/03/09 19:11

Code:
OPENFILENAME ofd;
	char buf[256];
	FillMemory(&ofd,sizeof(ofd),0);
	FillMemory(buf,256,0);
	
	ofd.Flags=OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_NOCHANGEDIR;
	ofd.lStructSize=sizeof(ofd);
	ofd.hwndOwner=hWnd;
	ofd.lpstrFilter	="Windows Bitmap\0*.bmp\0Portable Network Graphics\0*.png\0JPEG\0*.jpg\0TARGA\0*.tga\0\0";
	ofd.lpstrInitialDir = _chr(""); //work_dir
	ofd.lpstrFile=buf;
	ofd.nMaxFile=255;	
	ofd.lpstrTitle="Lade eine Bilddatei für den Hintergrund";
	if (GetOpenFileName(&ofd))
	{
		// ofd.lpstrFile == the string of the filename + location
                // use it like: ent_create(ofd.lpstrFile, vector, NULL);
	}
	else
	{
		// when file is not existing or nothing selected
	}


© 2024 lite-C Forums