By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,084 Members | 1,969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,084 IT Pros & Developers. It's quick & easy.

CFileDialog problem please help

100+
P: 100
Hi,
I have a dialog box which has menu "File->open"...and in the messagemap function OnOpen()
I am trying to opening a file using CFileDialog...
Expand|Select|Wrap|Line Numbers
  1. afx_msg void CExoDialog::Onopen()
  2. {
  3.     MessageBox("Alpha","U pressed Alpha");
  4.     CFileDialog dialog1(TRUE,"txt",NULL,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,"Text files(*.txt)| *.txt||");
  5. }
  6.  

But it is giving errors...PLs help
Jun 19 '07 #1
Share this Question
Share on Google+
4 Replies


Meetee
Expert Mod 100+
P: 931
Hi,
I have a dialog box which has menu "File->open"...and in the messagemap function OnOpen()
I am trying to opening a file using CFileDialog...
Expand|Select|Wrap|Line Numbers
  1. afx_msg void CExoDialog::Onopen()
  2. {
  3.     MessageBox("Alpha","U pressed Alpha");
  4.     CFileDialog dialog1(TRUE,"txt",NULL,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,"Text files(*.txt)| *.txt||");
  5. }
  6.  

But it is giving errors...PLs help
Kindly mention what are the errors so it becomes easy to find the problem.

Regards
Jun 19 '07 #2

100+
P: 100
error C2065: 'CFileDialog' : undeclared identifier
E:\bookexample\one.cpp(268) : error C2146: syntax error : missing ';' before identifier 'dialog1'
E:\bookexample\one.cpp(268) : error C2065: 'dialog1' : undeclared identifier
E:\bookexample\one.cpp(268) : error C2065: 'OFN_FILEMUSTEXIST' : undeclared identifier
E:\bookexample\one.cpp(268) : error C2065: 'OFN_HIDEREADONLY' : undeclared identifier
E:\bookexample\one.cpp(269) : error C2228: left of '.DoModal' must have class/struct/union type



These are the errors
Jun 19 '07 #3

Meetee
Expert Mod 100+
P: 931
.
Expand|Select|Wrap|Line Numbers
  1. afx_msg void CExoDialog::Onopen()
  2. {
  3.     MessageBox("Alpha","U pressed Alpha");
  4.     CFileDialog dialog1(TRUE,"txt",NULL,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,"Text files(*.txt)| *.txt||");
  5. }
  6.  

But it is giving errors...PLs help
Do something like this

afx_msg void CExoDialog::Onopen()
{
MessageBox("Alpha","U pressed Alpha");
CFileDialog* dialog1 = new CFileDialog(TRUE,"txt",NULL,OFN_FILEMUSTEXIST|OFN_ HIDEREADONLY,"Text files(*.txt)| *.txt||");
if ( dialog1->DoModal() == IDOK) {
...
}
}

Hope this helps
Regards
Jun 19 '07 #4

Meetee
Expert Mod 100+
P: 931
P.S. Also add #include <commdlg.h> if u havn't
Jun 19 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.