- created a new project : single document, database view with file support and then I chose my datasource and table
- all the other stuff I kept default
So now I had 1 dialog, I placed an edit control on it and set the variable to m_pSet->m_Bouwjaar
I ran it and voila database is working.
Now to get that second dialog working :
First : Insert->Resource->Dialog
Then I changed the ID to IDD_DIALOG2
Right mouse button->ClassWizard
Now I get the question to add a new class for my new dialog :
So : new class -> class name : CDialog2
Base class : CDialog
Dialog ID : IDD_DIALOG2
OK and OK again
So now I have my second Dialog
Now I placed a new button on the main dialog and named it "Open Dialog2"
Double clicked on it : New member function : "OnButtonOpenDialog2", OK
Now, entering the following code :
CDialog2 dlg2 ;HRESULT hresult = dlg2.DoModal() ;
and offcourse adding #include "Dialog2.h" on top of my 2DialogsView.cpp (main dialog, source file)
compile + run = everything OK, Pressing the button shows my second Dialog
Also in my editbox on my main dialog I get the value of the first record.
But now to get my database working on my second dialog!
So this is what I did :
first of all I added this line as a public member in my class CDialog2 :
CDialog2(const CMy2DialogsSet& db) ; // CMy2DialogSet is the database, right?
secondly I added the next line also in the private section of my class :
const CMy2DialogsSet& m_db;
and then in my CDialog2.cpp
CDialog2::CDialog2(const CMy2DialogsSet& db)
: m_db(db)
{
}
Now first changing
CDialog2 dlg2 ;
to
CDialog2 dlg2(*m_pSet) ;
Compiling now : 8 errors
I forgot to include the header file, so I #include "CMy2DialogsSet.h" on top of the CDialog2.h
compiling : 1 error :
error C2758: 'm_db' : must be initialized in constructor base/member initializer list
And pointed to my original constructor.
uhhhhh, what the hell?
Still doesn't work :(
I also tried setting an editbox on my second Dialog and tried to assign the variable m_db->m_Bouwjaar to it but I get the error : "invalid symbol "m_db->m_Bouwjaar" specified" :(
I hope you take the time to read this and I also hope that you can help me!
thanx in advance
[Edited by - da_cobra on March 2, 2005 12:54:29 PM]