我想写的是模拟方言,但我有问题。 当方案启动时,窗口立即关闭。
当我做示范方言时(DoModal(
)。
Csetkliens.h
#pragma once
#ifndef __AFXWIN_H__
#error "include stdafx.h before including this file for PCH"
#endif
#include "resource.h" // main symbols
#include "CsetkliensDlg.h"
class CCsetkliensApp : public CWinApp
{
public:
CCsetkliensApp();
virtual BOOL InitInstance();
DECLARE_MESSAGE_MAP()
private:
CCsetkliensDlg* dlg;
};
extern CCsetkliensApp theApp;
<>Csetkliens.cpp
#include "stdafx.h"
#include "Csetkliens.h"
#include "CsetkliensDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
BEGIN_MESSAGE_MAP(CCsetkliensApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
CCsetkliensApp::CCsetkliensApp()
{
dlg = NULL;
}
CCsetkliensApp theApp;
BOOL CCsetkliensApp::InitInstance()
{
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
CShellManager *pShellManager = new CShellManager;
dlg = new CCsetkliensDlg();
m_pMainWnd = dlg;
dlg->Create(CCsetkliensDlg::IDD);
dlg->ShowWindow(SW_SHOW);
if (pShellManager != NULL)
{
delete pShellManager;
}
return FALSE;
}
CsetkliensDlg.h
#pragma once
#include "ConnectDlg.h"
class CCsetkliensDlg : public CDialogEx
{
public:
CCsetkliensDlg(CWnd* pParent = NULL);
enum { IDD = IDD_CSETKLIENS_DIALOG };
protected:
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
};
<>CsetkliensDlg.cpp
#include "stdafx.h"
#include "Csetkliens.h"
#include "CsetkliensDlg.h"
#include "afxdialogex.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
CCsetkliensDlg::CCsetkliensDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CCsetkliensDlg::IDD, pParent)
{
}
BEGIN_MESSAGE_MAP(CCsetkliensDlg, CDialogEx)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
END_MESSAGE_MAP()
BOOL CCsetkliensDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
return TRUE;
}