Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass information from a dialog box to CDocument

Status
Not open for further replies.

Huskey

Vendor
Aug 23, 2002
53
0
0
GB
How to pass the information from a dialog box to CDocument? For example, let's say I am importing a database into a program through a dialog box. As soon as I press OK button, the dialog box is closed, returning to the CDocument MDI application but, the "OK" has signalled the program to import the data. However am I supposed to do it?? Any experts there, pleaseee try to help! Many many thanks!
 
Hi

There are several ways to do this... Perhaps the easier is to put an other button 'Import'. Clicking on this button would start the Db import. Then the 'Ok' button would be used to close the dialog box ...

An other possiblity is to put the import code into the handler of the Ok button.

A last one is to check the return value of the DoModal function and start the import if the DoModal function returns IDOK

HTH

Thierry


 
Hi Thierry,

Thanks for your info. Sorry to trouble you, is it possible that you can show me in an example or perhaps any good resources I could refer to. My knowledge in C++ is very limited. Please help me. Have been trying for days and still couldnt fix it. Thanks very much.
 
If you've got only single variables, it'll be no problem, for example like this:

Start the dialog in your document class and receive the variable ( here a CString mydialog.m_myString ):

CMyDialog mydialog;
if ( mydialog.DoModal()==IDOK )
{
TRACE (mydialog.myString);
}

if you need to transfer a whole bunch of variables just try to construct a global array in your dialog ( maybe a CArray ... ) and then transfer your data after pressing "OK Button" ( that's what I normally do, could be that there are better solutions, but I don't know them.

Regards,
SAM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top