![]() |
|
#1
|
|||
|
|||
Dialog based applicationHello:
My dialog based program consisting of 1 input & 1 output boxes (for double variables) is working fine. Now, I'd like to get the output in a second dialog window that should appear when I hit a button on the first :-x one.The window #2 should offer a top level button for printing the output. What should I do ? Detailed replies will be very much appreciated as I'm only a beginner. Thanks a lot. Frandy |
|||
|
#2
|
||||
|
||||
|
Quote:
Took me a lot of time to answer, didn't it? Sorry about that, I'm a bussy man... As other people might do this in another way, I will encourage them to post their opinion on this. I will show you how I do it (this is *my* awesome way ).First, let's consider your 2 dialog classes are CDialogOneDlg and CDialogTwoDlg. Then, in add this include: CPP / C++ / C Code:
Then, call the second dialog when user clicks "Button": CPP / C++ / C Code:
Also,in DialogTwoDlg.h, include the header of CDialogOneDlg: CPP / C++ / C Code:
And in the member data area of CDialogTwoDlg, add a pointer to your first dialog (also in DialogTwoDlg.h) CPP / C++ / C Code:
In DialogTwoDlg.cpp, you will have the constructor defined something like: CPP / C++ / C Code:
Add to this constructor this simple line of code: CPP / C++ / C Code:
Now, you have a reference to your first dialog that you can use in your second one! Of course, you must make the data you are trying to use from your first dialog a member of your first dialog's class: Let's say you have a member data defined like this in DialogOneDlg.h: CPP / C++ / C Code:
You can use this in the second dialog like this: CPP / C++ / C Code:
I sure hope this was clear enough...If not, pls. let me know where is it you need more help and I'll provide it for you. Kind regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#3
|
|||
|
|||
|
Thanks for your reply.
Unfortunately, my second dialog has been created by means of the Menu/Insert Dialog. So, you have no OnInitDialog() in the DialogTwo.cpp. In the meantime, I've been using a list box to display the results. BUT, I don't know how to print the results on my printer by pressing a button on the main dialog. Have you any idea? Thanks again. Frandy |
|
#4
|
||||
|
||||
|
Quote:
Oh, you don't need to wory about that. You see, the OnInit method is just handling the dialog's "reaction" to an event. So, you can just add it in. I suppose you didn't create a class for your dialog either? If this is the case, just double-click the surface of your dialog box, and you'll be able to add a clas for it. You can jiust name it CDialogTwoDlg. Then, go to Class Wizard, to the "Message Map" section, and add this meesage: WM_INITDIALOG (you'll need to scroll down quite a bit). Click Add Function, and then Edit Code. Quote:
Well, you could do this pretty easy, if you used the Document/View architecture. Tis would imply working with a MDI or SDI application rather than a DIALOG-based one. In case you decide to go with this, please take the time to read this (very small) tutor. Don't get me wrong, it's not my style to point to a faq, but I think you will find this very useful. For any concerns you might still have, please don't hesitate to ask. Best regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
Recent GIDBlog
Running Linux Programs at Boot Time by gidnetwork
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| The Specified CGI Application Misbehaved by not running a complete set of HTTP Header | SSS | Computer Software Forum - Windows | 2 | 16-Oct-2006 23:01 |
| Send and receive data through port using MFC Dialog Based | mithila | MS Visual C++ / MFC Forum | 1 | 10-Sep-2004 02:01 |
| How to let Enter-key-press message goes to ActiveX control on dialog | Yuri | MS Visual C++ / MFC Forum | 3 | 08-Sep-2004 07:40 |
| daialog based application MFC | Pandiani | MS Visual C++ / MFC Forum | 2 | 01-Aug-2004 10:45 |
| controling dialog objects & multiple source files | omills | MS Visual C++ / MFC Forum | 0 | 14-Jul-2004 23:30 |
Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The