5 个解决方案
#1
研究半天知道了,第一个对话框关联的类是默认的不能修改,在另建一个对话框就好了,在其上建立关联类。
#2
第一个对话框关联的类可以修改,另建个新的也可以
#3
全局替换即可~
#4
给你一个参考:
BOOL CMultiDialogApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
//
int nResponse;
while (m_iSteps) //!=0
{
nResponse=-1;
switch (m_iSteps)
{
case DIALOG_MAIN://main dialog
{
CMultiDialogDlg dlg;
m_pCurrentDlg=&dlg;
nResponse = dlg.DoModal();
switch (nResponse)
{
case IDC_BUTTON1:// DialogExtract
m_iSteps=DIALOG_A;
break;
case IDC_BUTTON2:// DialogMKArc
m_iSteps=DIALOG_B;
break;
case IDCANCEL:
m_iSteps=DIALOG_NO;
break;
}
}
break;
case DIALOG_A://DialogA
{
CString ArcFileName;
char CurDir[MAX_PATH];
GetCurrentDirectory(MAX_PATH,CurDir);
char drive[MAX_PATH];
char dir[MAX_PATH];
char fname[MAX_PATH];
char ext[10];
_splitpath(ArcFileName,drive,dir,fname,ext);
//
CFileDialog fd(TRUE);//open
//you do not set: m_pMainWnd = &fd;
fd.m_ofn.lpstrTitle="Open Archive File";
fd.m_ofn.lpstrInitialDir=strcat(drive,dir);
fd.m_ofn.lpstrFile=strcat(fname,ext);
fd.m_ofn.lpstrFilter="ARC archive file(*.arc)\0*.arc\0";
fd.m_ofn.Flags|=OFN_FILEMUSTEXIST;
//one file fd.m_ofn.Flags|=OFN_ALLOWMULTISELECT;
fd.m_ofn.Flags|=OFN_NODEREFERENCELINKS;// ".lnk"
//
if (fd.DoModal()==IDOK)
{// invalid file name will be prompted.
// file existence will be checked
ArcFileName=fd.GetPathName();
// afxDump<<ArcFileName;
CArcView ArcView;
// m_pMainWnd = &ArcView;
m_pCurrentDlg = &ArcView;
ArcView.m_ArcFileName = ArcFileName;
ArcView.DoModal();
}
// directory changed
SetCurrentDirectory(CurDir);
m_iSteps=DIALOG_NO;
}
break;
case DIALOG_B://DialogB
{
make_arc dlgB;
m_pCurrentDlg=&dlgB;
nResponse = dlgB.DoModal();
switch (nResponse)
{
case IDOK:
m_iSteps=DIALOG_MAIN;
break;
case IDCANCEL:
m_iSteps=DIALOG_NO;
break;
}
}
// any other dialog
break;
default:
m_iSteps=DIALOG_NO;
}// end switch (m_iSteps)
//afxDump << m_iSteps << "\n" ;
m_pCurrentDlg=0;
}// end while m_iSteps
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
BOOL CMultiDialogApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
//
int nResponse;
while (m_iSteps) //!=0
{
nResponse=-1;
switch (m_iSteps)
{
case DIALOG_MAIN://main dialog
{
CMultiDialogDlg dlg;
m_pCurrentDlg=&dlg;
nResponse = dlg.DoModal();
switch (nResponse)
{
case IDC_BUTTON1:// DialogExtract
m_iSteps=DIALOG_A;
break;
case IDC_BUTTON2:// DialogMKArc
m_iSteps=DIALOG_B;
break;
case IDCANCEL:
m_iSteps=DIALOG_NO;
break;
}
}
break;
case DIALOG_A://DialogA
{
CString ArcFileName;
char CurDir[MAX_PATH];
GetCurrentDirectory(MAX_PATH,CurDir);
char drive[MAX_PATH];
char dir[MAX_PATH];
char fname[MAX_PATH];
char ext[10];
_splitpath(ArcFileName,drive,dir,fname,ext);
//
CFileDialog fd(TRUE);//open
//you do not set: m_pMainWnd = &fd;
fd.m_ofn.lpstrTitle="Open Archive File";
fd.m_ofn.lpstrInitialDir=strcat(drive,dir);
fd.m_ofn.lpstrFile=strcat(fname,ext);
fd.m_ofn.lpstrFilter="ARC archive file(*.arc)\0*.arc\0";
fd.m_ofn.Flags|=OFN_FILEMUSTEXIST;
//one file fd.m_ofn.Flags|=OFN_ALLOWMULTISELECT;
fd.m_ofn.Flags|=OFN_NODEREFERENCELINKS;// ".lnk"
//
if (fd.DoModal()==IDOK)
{// invalid file name will be prompted.
// file existence will be checked
ArcFileName=fd.GetPathName();
// afxDump<<ArcFileName;
CArcView ArcView;
// m_pMainWnd = &ArcView;
m_pCurrentDlg = &ArcView;
ArcView.m_ArcFileName = ArcFileName;
ArcView.DoModal();
}
// directory changed
SetCurrentDirectory(CurDir);
m_iSteps=DIALOG_NO;
}
break;
case DIALOG_B://DialogB
{
make_arc dlgB;
m_pCurrentDlg=&dlgB;
nResponse = dlgB.DoModal();
switch (nResponse)
{
case IDOK:
m_iSteps=DIALOG_MAIN;
break;
case IDCANCEL:
m_iSteps=DIALOG_NO;
break;
}
}
// any other dialog
break;
default:
m_iSteps=DIALOG_NO;
}// end switch (m_iSteps)
//afxDump << m_iSteps << "\n" ;
m_pCurrentDlg=0;
}// end while m_iSteps
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
#5
如果你足够熟悉MFC的架构,可以手动修改的,对话框还比较简单,可以将你自己的类的继承原RMSDlg类,然后将对话框ID按照RMSDlg中的定义方式定义在自己的类中,就可以用自己的类直接替换工程中的原类来创建对话框了
#1
研究半天知道了,第一个对话框关联的类是默认的不能修改,在另建一个对话框就好了,在其上建立关联类。
#2
第一个对话框关联的类可以修改,另建个新的也可以
#3
全局替换即可~
#4
给你一个参考:
BOOL CMultiDialogApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
//
int nResponse;
while (m_iSteps) //!=0
{
nResponse=-1;
switch (m_iSteps)
{
case DIALOG_MAIN://main dialog
{
CMultiDialogDlg dlg;
m_pCurrentDlg=&dlg;
nResponse = dlg.DoModal();
switch (nResponse)
{
case IDC_BUTTON1:// DialogExtract
m_iSteps=DIALOG_A;
break;
case IDC_BUTTON2:// DialogMKArc
m_iSteps=DIALOG_B;
break;
case IDCANCEL:
m_iSteps=DIALOG_NO;
break;
}
}
break;
case DIALOG_A://DialogA
{
CString ArcFileName;
char CurDir[MAX_PATH];
GetCurrentDirectory(MAX_PATH,CurDir);
char drive[MAX_PATH];
char dir[MAX_PATH];
char fname[MAX_PATH];
char ext[10];
_splitpath(ArcFileName,drive,dir,fname,ext);
//
CFileDialog fd(TRUE);//open
//you do not set: m_pMainWnd = &fd;
fd.m_ofn.lpstrTitle="Open Archive File";
fd.m_ofn.lpstrInitialDir=strcat(drive,dir);
fd.m_ofn.lpstrFile=strcat(fname,ext);
fd.m_ofn.lpstrFilter="ARC archive file(*.arc)\0*.arc\0";
fd.m_ofn.Flags|=OFN_FILEMUSTEXIST;
//one file fd.m_ofn.Flags|=OFN_ALLOWMULTISELECT;
fd.m_ofn.Flags|=OFN_NODEREFERENCELINKS;// ".lnk"
//
if (fd.DoModal()==IDOK)
{// invalid file name will be prompted.
// file existence will be checked
ArcFileName=fd.GetPathName();
// afxDump<<ArcFileName;
CArcView ArcView;
// m_pMainWnd = &ArcView;
m_pCurrentDlg = &ArcView;
ArcView.m_ArcFileName = ArcFileName;
ArcView.DoModal();
}
// directory changed
SetCurrentDirectory(CurDir);
m_iSteps=DIALOG_NO;
}
break;
case DIALOG_B://DialogB
{
make_arc dlgB;
m_pCurrentDlg=&dlgB;
nResponse = dlgB.DoModal();
switch (nResponse)
{
case IDOK:
m_iSteps=DIALOG_MAIN;
break;
case IDCANCEL:
m_iSteps=DIALOG_NO;
break;
}
}
// any other dialog
break;
default:
m_iSteps=DIALOG_NO;
}// end switch (m_iSteps)
//afxDump << m_iSteps << "\n" ;
m_pCurrentDlg=0;
}// end while m_iSteps
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
BOOL CMultiDialogApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
//
int nResponse;
while (m_iSteps) //!=0
{
nResponse=-1;
switch (m_iSteps)
{
case DIALOG_MAIN://main dialog
{
CMultiDialogDlg dlg;
m_pCurrentDlg=&dlg;
nResponse = dlg.DoModal();
switch (nResponse)
{
case IDC_BUTTON1:// DialogExtract
m_iSteps=DIALOG_A;
break;
case IDC_BUTTON2:// DialogMKArc
m_iSteps=DIALOG_B;
break;
case IDCANCEL:
m_iSteps=DIALOG_NO;
break;
}
}
break;
case DIALOG_A://DialogA
{
CString ArcFileName;
char CurDir[MAX_PATH];
GetCurrentDirectory(MAX_PATH,CurDir);
char drive[MAX_PATH];
char dir[MAX_PATH];
char fname[MAX_PATH];
char ext[10];
_splitpath(ArcFileName,drive,dir,fname,ext);
//
CFileDialog fd(TRUE);//open
//you do not set: m_pMainWnd = &fd;
fd.m_ofn.lpstrTitle="Open Archive File";
fd.m_ofn.lpstrInitialDir=strcat(drive,dir);
fd.m_ofn.lpstrFile=strcat(fname,ext);
fd.m_ofn.lpstrFilter="ARC archive file(*.arc)\0*.arc\0";
fd.m_ofn.Flags|=OFN_FILEMUSTEXIST;
//one file fd.m_ofn.Flags|=OFN_ALLOWMULTISELECT;
fd.m_ofn.Flags|=OFN_NODEREFERENCELINKS;// ".lnk"
//
if (fd.DoModal()==IDOK)
{// invalid file name will be prompted.
// file existence will be checked
ArcFileName=fd.GetPathName();
// afxDump<<ArcFileName;
CArcView ArcView;
// m_pMainWnd = &ArcView;
m_pCurrentDlg = &ArcView;
ArcView.m_ArcFileName = ArcFileName;
ArcView.DoModal();
}
// directory changed
SetCurrentDirectory(CurDir);
m_iSteps=DIALOG_NO;
}
break;
case DIALOG_B://DialogB
{
make_arc dlgB;
m_pCurrentDlg=&dlgB;
nResponse = dlgB.DoModal();
switch (nResponse)
{
case IDOK:
m_iSteps=DIALOG_MAIN;
break;
case IDCANCEL:
m_iSteps=DIALOG_NO;
break;
}
}
// any other dialog
break;
default:
m_iSteps=DIALOG_NO;
}// end switch (m_iSteps)
//afxDump << m_iSteps << "\n" ;
m_pCurrentDlg=0;
}// end while m_iSteps
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
#5
如果你足够熟悉MFC的架构,可以手动修改的,对话框还比较简单,可以将你自己的类的继承原RMSDlg类,然后将对话框ID按照RMSDlg中的定义方式定义在自己的类中,就可以用自己的类直接替换工程中的原类来创建对话框了