Dialog程序中 APP 类和Dlg类他们是什么关系?

FourQueue 2007-01-26 10:08:48
它们是什么关系? 如何联系在一起的? 可以参考那些资料来理解这些知识

CMyApp 和 CMyDlg
...全文
737 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
FourQueue 2007-01-26
  • 打赏
  • 举报
回复

有没有那本书看了之后就能知道在那里加代码了?
sokewoniu 2007-01-26
  • 打赏
  • 举报
回复
CMyApp派生于CWinApp类,CMyDlg派生于CDialog类
程序运行时先执行CMyApp的InitInstance()函数
在InitInstance()中会有这样的代码
CMyDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
菲斯可儿 2007-01-26
  • 打赏
  • 举报
回复
MFC的东西很复杂,不是三言两语可以说清楚的,可以参考下深入浅出mfc等书。
CMyApp负责程序主框架的工作,可以理解为WinMain的封装。
CMyDlg是主对话框了,负责界面显示,消息循环等。
FourQueue 2007-01-26
  • 打赏
  • 举报
回复
谢谢参与
// B14.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include "B14.h" #include "B14Dlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CB14App BEGIN_MESSAGE_MAP(CB14App, CWinApp) //{{AFX_MSG_MAP(CB14App) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG ON_COMMAND(ID_HELP, CWinApp::OnHelp) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CB14App construction CB14App::CB14App() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CB14App object CB14App theApp; ///////////////////////////////////////////////////////////////////////////// // CB14App initialization BOOL CB14App::InitInstance() { // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. CB14Dlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧