【发布时间】:2013-11-25 02:53:19
【问题描述】:
在 VS2013 中,我创建了一个基于对话的 MFC 应用程序。 我修改了项目,以便在应用程序开始时使用 PropertyPage 和 Propertysheet,因此它不会启动 CDialog,而是启动我的 propertypage。
之后,我创建了一个对话框,并且类关联(from::CdialogEx)。 我想在单击按钮后打开此对话框。
点击按钮后,我会这样做:
CMyDialog myDialog;
myDialog.DoModal();
我没有任何错误消息,但是我没有在屏幕上显示我的对话框。
也许是因为这个对话框没有子没有?
有人可以帮帮我吗?
非常感谢,
最好的问候,
尼克斯
编辑:
这是我的入口点:
#include "stdafx.h"
#include "KenoApp.h"
#include "KenoDlg.h"
#include "GenerationDlg.h"
#include "KenoSheet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CKenoApp
BEGIN_MESSAGE_MAP(CKenoApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// construction CKenoApp
CKenoApp::CKenoApp()
{
}
// Seul et unique objet CKenoApp
CKenoApp theApp;
// initialisation de CKenoApp
BOOL CKenoApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
#ifdef _AFXDLL
// Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CKenoSheet KenoSheet;
KenoSheet.SetTitle(L"Keno Helper v1.1");
CGenerationDlg Generation;
CKenoDlg KenoDlg;
KenoSheet.AddPage(&KenoDlg);
KenoSheet.AddPage(&Generation);
//m_pMainWnd = &KenoSheet;
int nResponse = KenoSheet.DoModal();
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
然后,在我的属性页上:
CAboutDlg myDialog;
theApp.m_pMainWnd = &myDialog;
myDialog.DoModal();
我现在的问题是,DoModal() 关闭了我的应用程序。
【问题讨论】:
-
您可以尝试将对话框显示为无模式的吗?
-
不,这是怎么做到的?我尝试使用 ShowWindow() 方法,但我有一个断言错误!
-
尝试和错误(见顶部);)
-
您是否查看过确保代码正在查找对话框资源?找不到资源时,对话框创建通常会失败。
标签: c++ visual-studio-2010 winapi mfc dialog