PocketMatrix forums

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

Common GetFile dialog in eVc

Hi,

I would like to know how to call the standard windows CE getfile dialog without having to write my own? I've been searching for it for quite a while and couldn't find anything.
GetOpenFileName.

Dan East
Thanx a lot, do you have a code example on how to use the LPOPENFILENAME structure? I know it's a stupid question but I am not an experienced C programmer and pointers are still giving me problems.

Regards,
Kornalius.
Well, off the top of my head it would be something like this:

Code:

TCHAR szFileName[MAX_PATH];
OPENFILENAME ofn;
memset(ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize=sizeof(OPENFILENAME);
ofn.lpstrFile=szFileName;
ofn.nMaxFile=sizeof(szFileName)/sizeof(TCHAR);

if (GetOpenFileName(&ofn;)) {
//Do something with the file the user chose
//Filename will be in szFileName
}


I don't think I've ever used that API before. I have used CFileDialog, which is the MFC wrapper to GetOpenFileName. So I may be missing something in setting up the OPENFILENAME struct.

Dan East
Thank you very much Dan, I will try it tonight.

Btw, do you know how to get the directory where the application is ran from? Like a GetDir(0,s); in Delphi.
I've never even seen a line of Delphi code, but you use GetModuleFileName in Windows CE. That returns the full path and filename of the process that you are running in. Strip the filename off and you've got the path.

Dan East
To answer your next question, and not waste time:

Code:

TCHAR szPath[MAX_PATH];
GetModuleFileName(NULL, szPath, sizeof(szPath)/sizeof(TCHAR));

//Strip filename from path
LPTSTR pPos=szPath+_tcslen(szPath)-1;
while (*pPos!=_T('\\') && --pPos > szPath);
*pPos=_T('\0');



That's all off the top of my head, so there may be syntax or logical errors. I coded that routine to strip the filename differently than I normally do, so that is untested.

Dan East
Thanx a lot!

Regards,
Kornalius