![]() |
|
Load/Save File Dialog |
Anomie
Member #9,403
January 2008
![]() |
Is there some easy way to summon a generic load file/save file dialog from the depths of my OS? Working with the Allegro GUI seems to be about as much fun as removing my teeth with a hand-drill. (not that I've tried using any other GUI...) It seems like these dialogs are used in every single GUI'd application ever, and it's always identical (except for GIMP...), so is there some simple function to bring one up in Windows? ______________ |
SiegeLord
Member #7,827
October 2006
![]() |
Quote: Is there some easy way to summon a generic load file/save file dialog from the depths of my OS? Working with the Allegro GUI seems to be about as much fun as removing my teeth with a hand-drill. (not that I've tried using any other GUI...) First, an off-topic comment. I never had any trouble using allegro GUI myself, it is simple and well documented. I found the Dialog Editor to be very useful for it. But anyway.. onto your main question. Quote: so is there some simple function to bring one up in Windows?
Yes, here it is: [url http://msdn.microsoft.com/en-us/library/dk77e5e7(VS.80).aspx] Unfortunately for you it is very very hard (imo at least) to get that function into your program, since somehow you will have to link with MFC. Nonetheless, a search of the forums shows that this worked once for one person in 2001. He did not provide the code showing how to do that however. Brainstorming a bit, it may be possible to use wxWidgets and use its file dialog functions (which map to native dialogs for Windows), however I do not know whether it is possible to bind a wxWindow to a pre-existing allegro window. But basically, what you ask for is very hard to accomplish. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Anomie
Member #9,403
January 2008
![]() |
Isn't the Allegro GUI totally blocking, until it's closed down? Otherwise, that editor is very interesting, indeed. And thanks for the answer! ______________ |
SiegeLord
Member #7,827
October 2006
![]() |
Quote: Isn't the Allegro GUI totally blocking, until it's closed down?
Depends on what you use. If you use do_dialog, then yes, it is blocking. Usually, however, you use the:init_dialog/update_dialog/shutdown_dialog Basically, you call the init_dialog on your DIALOG* array when you wish to invoke/initialize the GUI, and then in your game loop you call update_dialog on the DIALOG_PLAYER. Later on you call the shutdown_dialog to clean up. I can't seem to find a good tutorial on this unfortunately... although I had little trouble using this. (Although I did have to force it to draw by calling dialog_message with the MSG_DRAW message every time before I did update_dialog)... EDIT: If you end up sticking with Allegro's gui, I highly recommend AGUP to make it look a little nicer. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Anomie
Member #9,403
January 2008
![]() |
Well, it's good to hear that it's not so bad. And that editor kinda makes it more like brushing my teeth than removing them. I'm still in a bit of trouble though. How would I make a normal menu, with sub-menus and such? Is there some method of naming each element that I'm not aware of? [edit] Writing that, I figured I'd just look through the examples to figure out how to replicate that generic file dialog window in Allegro, but I can't find any examples using it... Any help with that one? ______________ |
Timorg
Member #2,028
March 2002
|
Something I thought I would whip something up. The joy of having done some windows programing before. So name this "main.c"
Then in mingw go... gcc -odialog.exe main.c -lalleg -lcomdlg32 For more information about the function and the struct look at GetOpenFileName http://msdn.microsoft.com/en-us/library/ms646927(VS.85).aspx You should read through the docs, to make sure I haven't made a mistake in understanding OPENFILENAME. This assumes everything is in ansi strings, but I call the ansi function so all good. You might need to tweak stuff if you want this to work under NT you need to detect it and use "OPENFILENAME_SIZE_VERSION_400" not "sizeof(OPENFILENAME)" I hope this helps, I haven't used this function in a long while. If anyone does end up using this in something complete a thanks in a doc wouldn't go astray If you have problems, post them and I will help where I can. ____________________________________________________________________________________________ |
SiegeLord
Member #7,827
October 2006
![]() |
Aha, I knew that only working with MFC would come to haunt me some day. Now, if only we can replicate this for GNOME, KDE and whatever Mac uses, we can make this a part of Allegro 5! "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Timorg
Member #2,028
March 2002
|
I would be willing to attempt it in gnome and kde (when the computer comes back from the shop), but I don't have a mac to do that part. I'm not sure implementing it based on desktop environments is that good an idea, we need something that will work in fluxbox without gnome or kde stuff installed, my current setup. This doesn't really belong in allegro core anyway, it should be an addon. ____________________________________________________________________________________________ |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Quote: This doesn't really belong in allegro core anyway, it should be an addon. If freedesktop.org would get something done for once, there would be a xdg-file-dialog command you could shell out to on most distros. But sadly, most of the people involved with fd.org are gnome peeps, and they don't seem to like finishing anything. -- |
SiegeLord
Member #7,827
October 2006
![]() |
Quote: This doesn't really belong in allegro core anyway, it should be an addon.
Naturally not, most everything seems to be an addon for Allegro 5 anyway. Quote: I'm not sure implementing it based on desktop environments is that good an idea, we need something that will work in fluxbox without gnome or kde stuff installed, my current setup. The idea is to have an easy to use function able to call up the native file open dialog if possible for the current system. I guess in Fluxbox's case, if it doesn't have such a standard file open dialog (I don't have much experience with Fluxbox), some sort of Allegro GUI dialog would be called as a fallback option. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Timorg
Member #2,028
March 2002
|
Oh just a thought here is the src and compiled example. Clicky. (Its compiled against 4.2.2) Edit: I could install the gnome stuff and the kde stuff, its automatically installed with a gnome or kde app anyway, but small is the important thing for this system. So only gtk apps here. Edit: I just noticed I missed out on cookies. ____________________________________________________________________________________________ |
Anomie
Member #9,403
January 2008
![]() |
Awesome! That looks like it's just what I needed. Compiles fine with MinGW, too. (that was certainly an issue with MFC stuff...) Just gotta figure out what's going on...then I'll be set! Um... * awards Schrodinger's Cookie? * Just don't look at it. [edit]And I'm not too worried about the NT bit...if I was wanting it to run on anything but my machine, I'd have to find something more portable anyways. ______________ |
|