Click to See Complete Forum and Search --> : New programmer about ready to throw his computer out the window


joe joe
July 28th, 1999, 10:45 AM
Can someone give me advice on a good book or website to get technical info about c++ that will actually help me. I am trying to use a dialog box to have a user input float type variables and when the ok button is clicked put them into a mathematical function and then have the answers spit back onto a window. I am trying to use a CEdit member function to do this such as GetWindowText. This is the only info I have from the crappy books I have. They give examples but don't really give you enough info to do your own applications.

Wayne Fuller
July 28th, 1999, 10:51 AM
What exactly are you having trouble with? Getting the strings from the edit boxes or converting them to floats or what? Let me know and I can help you. If you want send me the application and I will point out what needs to be done.

Wayne

wphfuller@mindspring.com

Paul McKenzie
July 28th, 1999, 12:39 PM
On the OK handler, don't destroy the dialog, (don't call the default OnOK() handler). Just call CEdit::GetWindowText() and you'll get the string. From there it's up to you as to how to translate the string into a mathematical function (this step has *nothing* to do with Windows).

Once your function has values, you need to translate them back into strings. Use the CString::Format() function, or sprintf() to do the job (or you can use the strstream functions from the C++ I/O library). Write the new values to another read-only edit fields in the same dialog to see if writing the strings back to an edit field works OK. Use the "Cancel" button to close the dialog.

Just some observations concerning your problem:
Your problem is an MFC problem, not a C++ problem. A lot of beginners erroneously mix up the C++ language with Windows, but the C++ language is just a language. There is no "Windows" aspect to it. You can use the C++ language to create a Windows program, but you could have also use Pascal, Basic, Java, Perl, Smalltalk, Fortran, COBOL, or any other language that allows you to call the WinAPI 32 functions to create windows, dialogs, etc. If I were to suggest a "C++ site", you will not see a discussion of dialog boxes, radio buttons, MDI, MFC, or DLLs. You will see a discussion of templates, pointers, STL, Run Time Type ID, class design, etc. So the question is this: Is your problem C++, or is it Windows programming in general? Good C++ books are by

Bjarne Stroustrup (the inventor of the language)
Stanley Lippmann
Scott Meyers

I don't know any MFC programming books off-hand.

Regards,

Paul McKenzie

Erich Ruth
July 28th, 1999, 12:44 PM
In my days of learning visual development, I have found that the textbooks generally suck. They are incomplete and offer poor examples. Once I learned how to do basic data exchange between edit fields and check boxes, my desire to learn visual development and daily study of other people's code really helped me to learn visual c++. This site has a ton of code stored on it. I encourage you to search through it and download examples with features you like and study it. Another cool site is with some nice examples;

http://home.earthlink.net/~railro/mfc_link.html

The internet is truly the visual developer's guide to learning.

Now, in response to your question. You have an edit field in your dialog box. Create another edit field below it. Go to class wizard and make the two edit field member variables, m_edit1 and m_edit2, a CString not a CEdit. In the CMyDialog::OnOk() type

char buf[256];
GetDlgItemText(IDC_EDIT1, buf);
...
SetDlgItemText(IDC_EDIT2, buf);

John Killingbeck
July 28th, 1999, 09:41 PM
The book I use and have recommended is the Que black soft-cover series. My version is Mastering Visual C++ 4.0. The book goes at a reasonable pace without hand-holding, provides working examples with full source code at the end of each chapter, and provides a thorough overview of MFC, including dialog boxes and the CEdit class. The book assumes a general knowledge of C and C++ programming. It shows MFC, OLE, etc. techniques, not fundamental programming. It includes an overview of C++ and differences from C, classes, templates, etc. at the start. Examples of CArray, CTypedPtrArray and other key features besides Windows features are covered.