Click to See Complete Forum and Search --> : C++ and prog


MI4C
April 2nd, 2004, 02:58 PM
First of all I'm really as nOOb in C/C++ or Visual C++.

Ok, I know most stops reading at that point, but the rest of you...

I really have read and tried to learn as much as I can, have read actually 4 books (which I amaze of myself...)

1. Charles Petzold (windows programming (translated version))
2. Mark Andrews (learn your self visual c++)
3. just some teacher made book of visual c++
4. Lean and Mean Visual C++

Still I'm at the beginning...

I am trieng to use Microsoft Visual Studio .NET 2003 (The Visual C++/MFC) for making my own program(s).

Well here is my first painfull issue, (tried to solve it about 2 weeks before sending this mail) I would like to build MFC/Dialog product without adding extra features from project wizzard...

Now, I go to create several buttons (1,2,3,4,5 and 6) and 1 edit field...

I rename button ID's what i want (also the caption), then I create CButton(s) variables (control(s)) named by my favor. Then I double click to all buttons to get the button1click etc... What should I do to get Opendialog opening example from the first button... I would like to give specific class to it also for future plans, to get later on like a file.txt to play all wav files listed in it, I know procedure to strip the chunk etc... but the main problem is now the opendialog thing...

I thought i knew the way but it wasn't like I thought...
I thought it could put in something.h and specified like a class OpenFileDialog Openfile; (I think that is something to do with borland... the one book shown later on to be borland c++ tutorial

Well, if I never manage to be a good programmer, I would like to be the assistor than the requester... =)

Andreas Masur
April 2nd, 2004, 03:33 PM
[Moved thread]

Andreas Masur
April 2nd, 2004, 03:34 PM
Well...I am not sure whether I understood correctly...are you trying to display the 'File Open' dialog? In this case...
1. Single-selection

void CYourDialog::OnFileOpen()
{
CFileDialog FileDialog(TRUE,
"*.*",
NULL,
OFN_HIDEREADONLY,
"Text Files: (*.txt)|*.txt||");

if(FileDialog.DoModal() == IDOK)
{
CString PathName = FileDialog.GetPathName();
// Do something with 'PathName'
}
}

2. Multi-Selection

The following example allows you to select multiple files. They will be stored in the 'lpstrFile' buffer which was allocated to hold ten filenames.

void CYourDialog::OnFileOpen()
{
CFileDialog FileDialog(TRUE,
"*.*",
NULL,
OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT,
"Text Files: (*.txt)|*.txt||");

// Create buffer for ten filenames
TCHAR strFiles[MAX_PATH * 10] = "";

FileDialog.m_ofn.lpstrFile = strFiles;
FileDialog.m_ofn.nMaxFile = sizeof(strFiles);

if(FileDialog.DoModal() == IDOK)
{
POSITION pos = FileDialog.GetStartPosition();

if(pos)
{
CString PathName;

do
{
PathName = FileDialog.GetNextPathName(pos);
// Do something with 'PathName'
} while(pos);
}
}
}

MI4C
April 2nd, 2004, 03:48 PM
Ty, for reply...

Now I get error message "Cmydlg": is not a class or namespace name... so do i need to make new class for this purpose and point it to this button?

Andreas Masur
April 2nd, 2004, 04:34 PM
No...you need to add a message handler for the button 'Click' event. Inside the message handler you can paste one of the examples I gave... :cool:

MI4C
April 3rd, 2004, 04:53 AM
Thanks m8, that help'd me to get started, with my prog....

Andreas Masur
April 3rd, 2004, 06:35 AM
You are welcome...