http://msdn2.microsoft.com
OPENFILENAME ofn; // common dialog box structure
char szFile[260]; // buffer for file name
HWND hwnd; // owner window
HANDLE hf; // file handle
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = 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 = "All\0*.*\0Text\0*.TXT\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
// Display the Open dialog box.
if (GetOpenFileName(&ofn)==TR
hf = CreateFile(ofn.lpstrFile, GENERIC_READ,
0, (LPSECURITY_ATTRIBUTES) NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
(HANDLE) NULL);
Main Topics
Browse All Topics





by: mahesh1402Posted on 2006-11-12 at 19:41:21ID: 17927779
Following are details for CDM_GETFILEPATH : /en-us/lib rary/ms646 847.aspx
ARAM wParam, LPARAM lParam, LRESULT* pResult)
DM_GETFILE PATH, MAX_PATH, (LPARAM)szFileName);
http://msdn2.microsoft.com
The CDM_GETFILEPATH message retrieves the path and file name of the selected file in an Explorer-style Open or Save As dialog box. The dialog box must have been created with the OFN_EXPLORER flag; otherwise, the message fails.
You can use the CDM_GETFILEPATH message to get the full path of the selected file like following :
// Called when the selected file has changed
BOOL CMyFileDialog::OnNotify(WP
{
OFNOTIFY* pOFN = (OFNOTIFY*)lParam;
if (pOFN->hdr.code == CDN_SELCHANGE)
{
// Selection changed
// Get the filename
TCHAR szFileName[MAX_PATH];
::ZeroMemory(szFileName, MAX_PATH);
GetParent()->SendMessage(C
ProcessFile(szFileName);
}
// Pass to base class
return CFileDialog ::OnNotify(wParam, lParam, pResult);
}
-MAHESH