Home > Software engineering >  Weak weak ask questions on MFC dialog control to use
Weak weak ask questions on MFC dialog control to use

Time:09-27

In VS a MFC project, to generate a window, the system will automatically generate the CPP was associated with the window with a header file


But if alone in resource view, create a new window,

That how to build that is associated with the window of the CPP and header files?


MFC on how to control this separate window? MFC ultra small white for guidance,

CodePudding user response:

Add MFC class, the base class to choose CDialog (or CDialogEx), fill in the name of the class, ID, etc

CodePudding user response:

Class wizard in the project menu to add the corresponding function, class, variable, etc., of course the selected controls, then right-click the same,

CodePudding user response:

Double-click on the dialog resource editor pops out requirements input dialog window class name, used to dialog class resources associated with the window up,

CodePudding user response:

Double-click the dialog box directly, also can pop up to let you binding classes

CodePudding user response:

Add - class - the MFC class cdialog

CodePudding user response:

reference 1st floor zgl7903 response:
add MFC class, base class selected CDialog (or CDialogEx), fill in the name of the class, ID, etc.


My button calls through the main form, on the new window,
 
Void CMy2013MFCTwoDlg: : OnBnClickedButton1 ()
{
//TODO: add the control notification handler code
//DialogBox (NULL, MAKEINTRESOURCE (IDD_DIALOG1), NULL, DirectoryDlgProc);

CDialogEx * conditionBtnDlg;
ConditionBtnDlg=new CDialogEx;
ConditionBtnDlg - & gt; Create (IDD_DIALOG1, this);

ConditionBtnDlg - & gt; ShowWindow (SW_SHOW);
}


But why call out the window, I associate with a new window class constructors and other methods, why did not break down?
 
# include "stdafx. H"
# include "2013 mfctwo. H
"# include "Dialog1Manager. H"
# include "afxdialogex. H"


//CDialog1Manager dialog

IMPLEMENT_DYNAMIC (CDialog1Manager CDialog)

CDialog1Manager: : CDialog1Manager (pParent/*=NULL CWnd * */)
: CDialog (CDialog1Manager: : IDD, pParent)
{
MessageBox (" testtest "L, L" fuck ", MB_OK);
}

CDialog1Manager: : ~ CDialog1Manager ()
{
}

Void CDialog1Manager: : DoDataExchange (CDataExchange * symbol)
{
CDialog: : DoDataExchange (symbol);
}


BEGIN_MESSAGE_MAP (CDialog1Manager CDialog)
END_MESSAGE_MAP ()


Excuse me what reason be

CodePudding user response:

CDialog1Manager * conditionBtnDlg;
ConditionBtnDlg=new CDialog1Manager;

CodePudding user response:

Double-click the automatically generated manually add initialization function after class

CodePudding user response:

 CDialogEx * conditionBtnDlg; 
ConditionBtnDlg=new CDialogEx;
ConditionBtnDlg - & gt; Create (IDD_DIALOG1, this);

ConditionBtnDlg - & gt; ShowWindow (SW_SHOW);

The expression here you write wrong,
Should be:
1. The modal window
 CDialog1Manager * conditionBtnDlg; 
ConditionBtnDlg=new CDialogEx;
ConditionBtnDlg - & gt; Create (IDD_DIALOG1, this);

ConditionBtnDlg - & gt; ShowWindow (SW_SHOW)

At the same time pay attention to create IDD_DIALOG1 consistent with the resources inside,
Modal window
2.
 CDialog1Manager DLG (this); 
DLG. DoModal ();
  • Related