Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 920 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Problems with GetOpenFileName function #461956
08/30/16 20:42
08/30/16 20:42
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline OP
Serious User
txesmi  Offline OP
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Hi,
Once a file is selected with GetOpenFileName the engine does not find the paths to the files it already found before. I squeezed the problem to the following full working bunch of code lines.
Code:
#include <acknex.h>
#include <windows.h>
#define PRAGMA_PATH "images"

char* fileOpenDialog ( char* _chrLocation, char* _chrFilter )
{
	char szFile[MAX_PATH];
	ZeroMemory ( szFile, MAX_PATH );
	OPENFILENAME ofn;
	ZeroMemory ( &ofn, sizeof(OPENFILENAME) );
	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_NOREADONLYRETURN;
	if ( _chrFilter ) 
	{
		char szFilter[256];
	   ZeroMemory ( szFilter, 256 );
	   int size = str_len ( _chrFilter );
	   strcpy ( szFilter, _chr(_chrFilter) );
	   strcpy ( szFilter+size+1, _chr(_chrFilter) );
	   ofn.lpstrFilter = szFilter;
	} 
	else
	{
	   ofn.lpstrFilter = "All Files(*.*)\0*.*\0\0";
	}
	ofn.lpstrTitle      = NULL;
	ofn.lpstrFile       = szFile;
	ofn.nMaxFile        = MAX_PATH;
	ofn.lpstrInitialDir = _chr(_chrLocation);
	ofn.hwndOwner       = hWnd;
	if ( GetOpenFileName(&ofn) )
		return szFile;
	else
	   return NULL;
}

void evnSpace ()
{
	while ( key_space )
		wait(1);
	char *_chr = fileOpenDialog ( NULL, NULL );
}

void main ()
{
	wait(1);
	level_load ( "" );
	on_space = evnSpace;
	while ( !key_esc )
	{
		draw_text ( work_dir, 10, 10, COLOR_WHITE ); // Never changes
		if ( file_exists ( "negro.png" ) )
			draw_text ( "the file is accesable", 10, 40, COLOR_GREEN );
		else
			draw_text ( "the file is not accesable", 10, 40, COLOR_RED );
		wait(1);
	}
	sys_exit ( NULL );
}



After a week of headaches I would bet it changes the engines working folder because in the case you select a file into the project main folder everything works as expected although you select a file out of it before.

Any hint on how to restore the engines working path? Could this issue be a bug? I copied the dialog opening code from this forum. I am a winapi nescient laugh

Thak you in advance,
txes

Re: Problems with GetOpenFileName function [Re: txesmi] #461957
08/30/16 20:50
08/30/16 20:50
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline OP
Serious User
txesmi  Offline OP
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
I just found the flag OFN_NOCHANGEDIR

I can't understand how I missed it blush


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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