Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
file_dialog bug in strio.c #330356
06/27/10 08:10
06/27/10 08:10
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
As discover by The_Clyde, the filter in "file_dialog" doesnt work when you set your own filter parameter.

After a dig, Ive discovered it is a typo in the function called "filename(char* title,char* filter)".
The 'szFilter' definition isnt declared STATIC, so then this function terminates and returns to file_dialog, the
char array your filter is in gets freed. This wont happen if it is STATIC.
Code:
...
    if (filter) {
        static char szFilter[256];    //needs to be made STATIC
        ZeroMemory(szFilter,256);
        ...






"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: file_dialog bug in strio.c [Re: EvilSOB] #330378
06/27/10 11:07
06/27/10 11:07
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
Or just change the ofn.lpstrFilter = szFilter; to ofn.lpstrFilter = filter; when you need the standard C file format, like this:

Quote:
cOpenAs = file_dialog_open("Open Model As...","Supported Files Types (*.mdl;*.hmp;*.obj;*.dae;*.ase;*.3ds;*.x)\0*.mdl;*.hmp;*.obj;*.dae;*.3ds;*.x\03D GameStudio (.mdl)\0*.mdl\03D GameStudio Terrain (.hmp)\0*.hmp\0Wavefront Object (.obj)\0*.obj\0Collada (.dae)\0*.dae\03ds Max ASE (.ase)\0*.ase\03ds Max 3DS (.3ds)\0*.3ds\0DirectX X(.x)\0*.x\0All Files (*.*)\0*.*\0");


Anyway, it would be great to added a handle ofn.hwndOwner = hWnd; and added also the OFN_OVERWRITEPROMPT flag like this:

I need this for my project wink

Code:
// file functions /////////////////////////////////

OPENFILENAME* filename(char* title,char* filter)
{
	static char szFile[MAX_PATH];
	ZeroMemory(szFile,MAX_PATH);
	static OPENFILENAME ofn;
	ZeroMemory(&ofn,sizeof(OPENFILENAME));
	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hwndOwner = hWnd;
	ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
	if (filter) {
   	char szFilter[256];
	   ZeroMemory(szFilter,256);
	   int size = str_len(filter);
	   strcpy(szFilter,_chr(filter));
	   strcpy(szFilter+size+1,_chr(filter));
	   ofn.lpstrFilter = filter;
	} else
	   ofn.lpstrFilter = "All Files(*.*)\0*.*\0\0";
	   
	ofn.lpstrTitle	= _chr(title);
	ofn.lpstrFile	= szFile;
	ofn.nMaxFile	= MAX_PATH;
	return &ofn;
}




Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: file_dialog bug in strio.c [Re: rojart] #331175
07/02/10 12:06
07/02/10 12:06
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
Thanks, this will be fixed.


Moderated by  jcl, Nems, Spirit, Tobias 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1