Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, Quad), 903 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 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