Game Development Reference
In-Depth Information
has a member function Format that works like sprintf . We can then
transfer this string value into the control IDC_NUM3 using the CWnd
member function SetWindowText .
void CMFCDialogDlg::OnChangeNum2()
{
double a, b;
CString str;
GetDlgItem(IDC_NUM1)->GetWindowText(str);
a = atof((LPCTSTR)str);
GetDlgItem(IDC_NUM2)->GetWindowText(str);
b = atof((LPCTSTR)str);
str.Format(”%f”, a + b);
GetDlgItem(IDC_NUM3)->SetWindowText(str);
}
If you want to populate the dialog before displaying it then tied member
variables are the best way. You can create a dialog, then set the values of
the member variables before calling DoModal . The DoModal function that
displays the dialog looks after transferring the data from the variable into
the control.
Creating an SDI application
If your application is a little more complex, then a good choice is an SDI
application. For this type start a new MFC AppWizard (exe) workspace. In
the first AppWizard panel choose the Single document for the application
type.
A default single document application contains the following:
CMFCSingleDocApp derived from CWinApp
CMFCSingleDocDoc derived from CDocument
CMFCSingleDocView derived from CView
CMainFrame derived from CframeWnd
This type of approach is called the document view architecture. The idea
is that you store all your data in the document and you decide how this is
displayed using the view. The benefit of this is that you can display the
same data in several ways. Toon3D uses four views of the same data.
The view in the top left is a tree view of the document, allowing the user
Search Nedrilad ::




Custom Search