• 大小: 19KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-21
  • 语言: C/C++
  • 标签: mfc  消息响应  windows  

资源简介

通常我们都是使用MFC的资源视图在对话框或FormView上通过拖拽的方式添加按钮,这里我们利用CButton对象来动态创建按钮,并对按钮添加单击消息响应。如果你有任何疑问,欢迎和我讨论。

资源截图

代码片段和文件信息

// DBN.cpp : Defines the class behaviors for the application.
//

#include “stdafx.h“
#include “DBN.h“
#include “DBNDlg.h“

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDBNApp

BEGIN_MESSAGE_MAP(CDBNApp CWinApp)
//{{AFX_MSG_MAP(CDBNApp)
// 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()

/////////////////////////////////////////////////////////////////////////////
// CDBNApp construction

CDBNApp::CDBNApp()
{
// TODO: add construction code here
// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CDBNApp object

CDBNApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CDBNApp initialization

BOOL CDBNApp::InitInstance()
{
AfxEnableControlContainer();

// 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.

#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

CDBNDlg 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;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      35244  2012-08-26 18:58  DBN\DBN.APS

     文件       1001  2012-08-26 19:14  DBN\DBN.clw

     文件       2021  2012-08-26 18:58  DBN\DBN.cpp

     文件       4109  2012-08-26 19:14  DBN\DBN.dsp

     文件        529  2012-08-26 18:58  DBN\DBN.dsw

     文件       1291  2012-08-26 18:58  DBN\DBN.h

     文件       5146  2012-08-26 18:58  DBN\DBN.rc

     文件       4405  2012-08-26 19:14  DBN\DBNDlg.cpp

     文件       1376  2012-08-26 19:14  DBN\DBNDlg.h

     文件       3525  2012-08-26 18:58  DBN\ReadMe.txt

     文件       1078  2012-08-26 18:58  DBN\res\DBN.ico

     文件        395  2012-08-26 18:58  DBN\res\DBN.rc2

     文件        528  2012-08-26 18:58  DBN\Resource.h

     文件        205  2012-08-26 18:58  DBN\StdAfx.cpp

     文件       1054  2012-08-26 18:58  DBN\StdAfx.h

     目录          0  2012-08-26 18:58  DBN\res

     目录          0  2012-08-26 19:16  DBN

----------- ---------  ---------- -----  ----

                61907                    17


评论

共有 条评论