Open/browse dialog

Posted By: croman

Open/browse dialog - 06/08/09 12:53

How can i make an open/browse dialog in lite-c? Dialog like: File->Open dialog in sed, wed, med...
Posted By: Quad

Re: Open/browse dialog - 06/08/09 13:02

winapi openfiledialog

there is an example in the samples folder.
Posted By: croman

Re: Open/browse dialog - 06/08/09 13:49

thnx


wait, is it possible to do that in pure lite-c or do i need to work in legacy mode?
Posted By: Quad

Re: Open/browse dialog - 06/08/09 14:21

you can do it in both modes. just add windows.h
Posted By: Espér

Re: Open/browse dialog - 06/08/09 17:46

just include windows.h

and use this code:
Code:
        STRING* filename = "#25";

        [...]

	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	="Portable Network Graphic\0*.png\0\0";
	ofd.lpstrInitialDir = _chr(""); //work_dir
	ofd.lpstrFile=buf;
	ofd.nMaxFile=255;	
	ofd.lpstrTitle="Lade eine Levelbitmap";
	if (GetOpenFileName(&ofd))
	{
		str_cpy(filename, ofd.lpstrFile);
	}

Posted By: croman

Re: Open/browse dialog - 06/08/09 21:39

thnx
Posted By: Jaeger

Re: Open/browse dialog - 06/09/09 00:38

I'm very glad you asked this question, and very glad you guys answered it. I was going to ask the other day, but forgot. Thanks!

Any other goodies in windows.h that could be useful? smile
Posted By: Quad

Re: Open/browse dialog - 06/09/09 06:22

nearly all winapi functions?
Posted By: EvilSOB

Re: Open/browse dialog - 06/09/09 09:10

Only problem is that Ive never gotten any "window" type functions to be
"on-top" when 3DGS is in full-screen mode.

Unless someone has found a workaround for that???
Posted By: Jaeger

Re: Open/browse dialog - 06/09/09 09:47

Seems like there should be some way to decide which window is active. I just don't know how. If there's no Lite-C command, then I guess we could use something like window_active(STRING* window_name); That would be cool, if a comparable counterpart doesn't already exist somewhere in Acknexland...
Posted By: EvilSOB

Re: Open/browse dialog - 06/09/09 10:20

Its not that Jaeger.
Its just that 3DGS (like any DirectX app) create the full-screen in a different
"video-space"(called a D3Ddevice) to windows itself, and the API's ONLY create
themselves on the windows D3Ddevice.

Ive played with your idea in the past, and all I could get was the API box coming
up in front OK, but the 3DGS display freezes, even though the game is still running,
or the game would get kicked back to windowed mode with the API box in front.

Neither of which was acceptable.
Posted By: croman

Re: Open/browse dialog - 06/09/09 11:02

ok, so basicly, i can create text boxes, window buttons, tabs, menus...with windows.h?
Posted By: croman

Re: Open/browse dialog - 06/09/09 12:17

help me out with this one, will ya? i'm new to this windows.h stuff

how can i create a text box for example and that the text inside of it gets saved to some STRING?
Posted By: Espér

Re: Open/browse dialog - 06/13/09 01:05

Have a question too...

is there any code to ask, if a file exists ( without creating the file )???
Posted By: EvilSOB

Re: Open/browse dialog - 06/13/09 02:28

Esper :: Lite-C or windows.h?
Code:
//LITE-C
var fhandle = file_open_read("test"); 
if(fhandle)	{ file_close(fhandle);   printf("file exists");	}
else		{ printf("file DOESNT exist");			}


//when you have included "windows.h"
if(GetFileAttributes("test.txt")+1)	{   printf("file exists");		}
else				{   printf("file DOESNT exist");	}
//also used like this when filename is in a 3DGS string
if(GetFileAttributes(filename_string.chars)+1)	{   printf("file exists");		}
else						{   printf("file DOESNT exist");	}

PM me if you need more than this...


Croman :: Sorry for that minor highjack of your thread.
As to your question about building your own dialog box, I cant help there sorry.
I dont do much in the way of "visible" API work because its very anti-fullscreen.
Plus what you want is a-lot of work. Visual API stuff is hideously complex/messy.
I strongly advise you coding something in lite-c code instead.
Posted By: Espér

Re: Open/browse dialog - 06/14/09 18:34

uhm.. both are not wkring..

because i included windows.h:
Code:
	if(menutyp == 0)
	{
		menupart_x = (screensize.x*0);
		menupart_y = (screensize.y*0);
		var filecounter = 1;
		while(filecounter != 5)
		{
			if(filecounter == 1)
			{
				if(GetFileAttributes("chronicle_1.sav")+1)
				{PANEL* button_1 = pan_create("pos_x=71;pos_y=131;flags=SHOW;
				button(0, 0, icon_save13, icon_save11, icon_save12, call_file_1, NULL, NULL);",2);printf("1 existiert");}
				else
				{PANEL* button_1 = pan_create("pos_x=71;pos_y=131;flags=SHOW;
				button(0, 0, button_leer, button_leer, button_leer, new_file_1, NULL, NULL);",2);}
			}
			if(filecounter == 2)
			{
				if(GetFileAttributes("\\Saves\chronicle_2.sav")+1)
				{PANEL* button_2 = pan_create("pos_x=71;pos_y=131;flags=SHOW;
				button(0, 0, icon_save23, icon_save21, icon_save22, call_file_2, NULL, NULL);",2);}
				else
				{PANEL* button_2 = pan_create("pos_x=71;pos_y=241;flags=SHOW;
				button(0, 0, button_leer, button_leer, button_leer, new_file_2, NULL, NULL);",2);}
			}
			if(filecounter == 3)
			{
				if(GetFileAttributes("\\Saves\chronicle_3.sav")+1)
				{PANEL* button_3 = pan_create("pos_x=71;pos_y=351;flags=SHOW;
				button(0, 0, icon_save33, icon_save31, icon_save32, call_file_3, NULL, NULL);",2);}
				else
				{PANEL* button_3 = pan_create("pos_x=71;pos_y=351;flags=SHOW;
				button(0, 0, button_leer, button_leer, button_leer, new_file_3, NULL, NULL);",2);}
			}
			if(filecounter == 4)
			{
				if(GetFileAttributes("\\Saves\chronicle_4.sav")+1)
				{PANEL* button_4 = pan_create("pos_x=71;pos_y=461;flags=SHOW;
				button(0, 0, icon_save43, icon_save41, icon_save42, call_file_4, NULL, NULL);",2);}
				else
				{PANEL* button_4 = pan_create("pos_x=71;pos_y=461;flags=SHOW;
				button(0, 0, button_leer, button_leer, button_leer, new_file_4, NULL, NULL);",2);}
			}
			filecounter += 1;
		}
	}


i stored chronicle_1.sav and chronicle_2.sav, in the "Saves" Folder of my project..
But always the else condition is activated..
Posted By: EvilSOB

Re: Open/browse dialog - 06/15/09 15:04

The format for the path and filename does NOT want to start with "\\".

These lines should all use the 'path' format as follows.
if(GetFileAttributes("Saves\\chronicle_2.sav")+1)

API-based functions assume you are starting from the project folder.
If you put a '\\' at the beginning of the file/path string, then it assumes
you want to look at the root directory of that drive letter.
ie If your project is at C:\projects\myproject, and the you use the test
GetFileAttributes("\\Saves\\chronicle_2.sav")+1),
then it will be checking for the file "C:\Saves\chronicle_2.sav"...
(When you use API functions anyway)
© 2024 lite-C Forums