PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Portable File Selector (PC & PPC)

Hi, I'm a game developer on Pocket PC and PC (using GapiDraw).
I really need to have a file chooser at the begining of one of my programs (even before calling GapiDraw if this may help) and I don't know how to do so.
It is very tough for me because :
- I want to develop on my PC, so the file chooser should also run on the PC...
- I adsolutely don't know MFC or STL or whatever and to be honest, I don't really plan to learn, because what I need is very specific and I don't have other needs to justify learning...

Without it, I'm blocked for the release of my game.

If you had some source code to share with me, I would be very, very, grateful !! :D :oops: :D
Thanks
You _could_ create one. A very simple one would consist of an array to store the file names, a graphical box onto which you would draw the text of the file names, and a couple of buttons (up/down) that would scroll thru the array. I'm sure you could pretty it up some to match the GUI of your game. Just one method...

-- GR
Thanks for your answer, that's true, I can create one, put I *hoped* it could already exist... :D
In the meantime, I'll do that, but the question is still open if somebody reads this...
You can use the standard Win32 API for that... that'll make it work well and be portable.
warmi · 14 Mar 2003, 21:37 UTC — Portable
Portable to what ?

Hehe .. what other OS supports Win32 File Requester APi ?

;-)
I've tried this and it works fine on my PC. Unfortunately, it refuses to compile for my Pocket PC.
Could somebody help me? I think I use a part of the Win32 API that is not supported under WinCE...
Thanks

OPENFILENAME ofn;
char szFileName[MAXPATH] = "";

ZeroMemory(&ofn;, sizeof(ofn));

ofn.lStructSize = sizeof(ofn);
//ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAXPATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "txt";

if(GetOpenFileName(&ofn;))
{
//..
}
The filter string is incorrect, you need a double null at the end. And IIRC you may need that at the end of each filter.

Something like:
Code:

ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0\0All Files (*.*)\0*.*\0\0";


This may or may not be *the* problem. Also I've only ever used this and set the hwndOwner, I don't know the behavior when you do not set it.


Also this question isn't GD specific you might get more help posting to the general devel forum.
Another problem is that you need to have your strings in unicode for WinCE.

By portability, I meant that it works both in WinCE and normal Windows.

In case you're still having problems, check this page out:
http://winprog.org/tutorial/app_two.html )again, remember you'll need to modify everything there for unicode)
Thank you Damian, Sm!rk, ppcStudios and warmi !! It works !! Here is the code I used :

OPENFILENAME ofn;
TCHAR szFileName[MAXPATH] = TEXT("");

ZeroMemory(&ofn;, sizeof(ofn));

ofn.lStructSize = sizeof(ofn);
//ofn.hwndOwner = hwnd;
ofn.lpstrFilter = TEXT("Executable Files (*.exe)\0*.exe\0All Files (*.*)\0*.*\0\0");
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAXPATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = TEXT("exe");
if(GetOpenFileName(&ofn;))
{
}

And using tGetFile from Tillanosoft make it even better !! (just replace GetOpenFileName by tGetOpenFileName)
Thanks again for solving my problem so quickly.
Andrea