Raaja.K

Hi,

I am new to win32 application. working with pocket pc application development. I am using the following code to open the file open dialog.

Code Snippet

// lpofn->lpstrFile = (LPWSTR)sFilePath;
OPENFILENAME ofn; // common dialog box structure
char szFile[260]; // buffer for file name

HANDLE hf; // file handle

// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwndTab;
ofn.lpstrFile = (LPWSTR)szFile;
//
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not
// use the contents of szFile to initialize itself.
//
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = L"All\0*.jpg\0Text\0*.TXT\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST ;
if (GetOpenFileName(&ofn)==TRUE)
{
SendMessage(GetDlgItem(hWndSoundVideo,IDC_RINGTONE_PATH),WM_SETTEXT,(WPARAM)TRUE,(LPARAM)ofn.lpstrFile);

}

break;



Everything working good. But, after selected a file from the dialog... my entire application got closed. I don't know why it's closing my app. can anyone help me plz...

Thanks in Advance.
Raja.





Re: Smart Devices Native C++ Development GetOpenFileName closing my entire application.

UdayaBG

Hello,

Please note the documentation at http://msdn2.microsoft.com/en-us/library/aa932877.aspx, says,

lpstrFilter

Long pointer to a buffer that contains pairs of null-terminated filter strings. The last string in the buffer must be terminated by two NULL characters.

Thanks

Udaya.





Re: Smart Devices Native C++ Development GetOpenFileName closing my entire application.

Jonason

There is how I Initialize ofn.lpstrFile :

ofn.lpstrFile = NULL;

After user GetOpenFileName(&ofen),ofn.lpstrFile will be the file you choose.

Hope that will help you!