0
我有对话窗体。从我的应用程序调用它,我用代码:显示对话窗体不在模态模式下
BOOL CpointMFC2App::InitInstance()
{
CWinApp::InitInstance();
Dialog dlg1;
dlg1.txt= "NotificationText";
int r= dlg.DoModal();
return r;
}
现在我不惯于有模态模式 - 我想,让程序去,而无需等待用户输入。如何使我的dlg1在非模式模式下显示?
对话形式:
#include "stdafx.h"
#include "pointMFC2.h"
#include "Dialog.h"
#include "afxdialogex.h"
// Dialog dialog
IMPLEMENT_DYNAMIC(Dialog, CDialogEx)
Dialog::Dialog(CWnd* pParent /*=NULL*/)
: CDialogEx(Dialog::IDD, pParent)
{
}
Dialog::~Dialog()
{
}
void Dialog::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(Dialog, CDialogEx)
ON_BN_CLICKED(IDOK, &Dialog::OnBnClickedOk)
END_MESSAGE_MAP()
// Dialog message handlers
BOOL Dialog::OnInitDialog()
{
CDialogEx::OnInitDialog();
SetWindowText(txt);
return TRUE;
}
void Dialog::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
CDialogEx::OnOK();
}
搜索有关*无模式对话框* ... – ikh
即使更改对话框无模式,你不能让对话框挂什么时候'CpointMFC2App :: InitInstance中()'返回,因为'dlg1'会超出范围并将被销毁,所以您的对话框将崩溃 –