簡體   English   中英

在非模式模式下顯示對話框形式

[英]Show dialog form not in modal mode

我有對話表格。 要從我的應用程序中調用它,請使用以下代碼:

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

要創建非模式對話框,您必須調用對話框的Create函數。 在對話框類的構造函數中執行此操作。 然后,您必須從InitInstance返回TRUE,以保持程序運行。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM