在非模式模式下显示对话框形式 [英] Show dialog form not in modal mode

查看:88
本文介绍了在非模式模式下显示对话框形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有对话框.要从我的应用程序中调用它,我使用代码:

I have dialog form. To call it from my application I use code:

BOOL CpointMFC2App::InitInstance()
{
    CWinApp::InitInstance();
    Dialog dlg1;
    dlg1.txt= "NotificationText";
    int r= dlg.DoModal();
        return r;
}

现在我不再需要模式模式-我想让程序在不等待用户输入的情况下运行.如何使我的dlg1在非模式模式下显示?

And now I don't wont to have modal mode - I would like to let program go without waiting user input. How to make my dlg1 show in non modal mode?

对话框形式:

#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();
}

推荐答案

要创建非模式对话框,您必须调用对话框的Create函数.在您的对话框类的构造函数中执行此操作.然后,您必须从InitInstance返回TRUE,以保持程序运行.

To create a nonmodal dialog you have to call the dialog's Create function. Do this in the constructor of your dialog class. Then you must return TRUE from InitInstance to keep the program running.

m_pMainWnd = new Dialog();
return TRUE; // Run MFC message pump

这篇关于在非模式模式下显示对话框形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆