Page 1 of 1
Portable File Selector (PC & PPC)

Posted:
Mar 14, 2003 @ 4:55pm
by Andrea

Posted:
Mar 14, 2003 @ 8:08pm
by ppcStudios

Posted:
Mar 14, 2003 @ 8:59pm
by Andrea

Posted:
Mar 14, 2003 @ 9:54pm
by damian
You can use the standard Win32 API for that... that'll make it work well and be portable.
Portable

Posted:
Mar 14, 2003 @ 10:37pm
by warmi

Posted:
Mar 15, 2003 @ 3:47am
by Andrea
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))
{
//..
}

Posted:
Mar 15, 2003 @ 5:10am
by Sm!rk

Posted:
Mar 15, 2003 @ 7:01am
by damian
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:
)again, remember you'll need to modify everything there for unicode)

Posted:
Mar 15, 2003 @ 5:14pm
by Andrea
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