954,219 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Common Open dialog box

Hi.
How can I call common open dialog box in MS Visual C++ 6.0 ?
I tried to use getOpenFileName() and CreateFile(). But my function doesn't work.
There is tehe body:
void FlashProgram::OnButtonPOpen()
{
// TODO: Add your control notification handler code here

OPENFILENAME ofn; // common dialog box structure
char szFile[260]; // buffer for file name
HWND hwnd; // owner window
HANDLE hf; // file handle

// I nitialize OPENFILENAME
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "All\0*.*\0Text\0*.hex\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)==TRUE)
hf = CreateFile(ofn.lpstrFile, GENERIC_READ,0, (LPSECURITY_ATTRIBUTES) NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,(HANDLE) NULL);

}


Can You give me any helps or hints :?:
Or example? :o
More Thanks
Milan

Milan
Newbie Poster
1 post since Aug 2004
Reputation Points: 10
Solved Threads: 0
 

hi everyone,
This is the way to do it
void FlashProgram::OnButtonPOpen( )
{
// TODO: Add your control notification handler code here
CFileDialog m_a (true);
if (m_a.DoModal = = IDOK)
{
//Do whatever you want
UpdateData(false);
}
}

Yours Sincerely

Richard West

freesoft_2000
Practically a Master Poster
623 posts since Jun 2004
Reputation Points: 25
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You