资源简介
一个例子演示如何在VC++中用函数指针实现回调。
完整文章见我的blog:
http://blog.csdn.net/lincyang/article/details/29175413
代码片段和文件信息
// CallBack.cpp : Defines the class behaviors for the application.
//
#include “stdafx.h“
#include “CallBack.h“
#include “CallBackDlg.h“
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CCallBackApp
BEGIN_MESSAGE_MAP(CCallBackApp CWinApp)
ON_COMMAND(ID_HELP &CWinApp::onhelp)
END_MESSAGE_MAP()
// CCallBackApp construction
CCallBackApp::CCallBackApp()
{
// support Restart Manager
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
// TODO: add construction code here
// Place all significant initialization in InitInstance
}
// The one and only CCallBackApp object
CCallBackApp theApp;
// CCallBackApp initialization
BOOL CCallBackApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
// Create the shell manager in case the dialog contains
// any shell tree view or shell list view controls.
CShellManager *pShellManager = new CShellManager;
// Activate “Windows Native“ visual manager for enabling themes in MFC controls
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
// 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
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T(“Local AppWizard-Generated Applications“));
CCallBackDlg dlg;
m_pMainWnd = &dlg;
INT_PTR 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
}
else if (nResponse == -1)
{
TRACE(traceAppMsg 0 “Warning: dialog creation failed so application is terminating unexpectedly.\n“);
TRACE(traceAppMsg 0 “Warning: if you are using MFC controls on the dialog you cannot #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS.\n“);
}
// Delete the shell manager created above.
if (pShellManager != NULL)
{
delete pShellManager;
}
// Since the dialog has been closed return FALSE so that we exit the
// application rather than start the application‘s message pump.
return FALSE;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-06-06 17:30 CallBack\
目录 0 2014-06-06 17:30 CallBack\CallBack\
文件 891 2014-06-05 15:45 CallBack\CallBack.sln
文件 31232 2014-06-06 17:30 CallBack\CallBack.v11.suo
文件 107736 2014-06-05 17:23 CallBack\CallBack\CallBack.aps
文件 2941 2014-06-05 15:44 CallBack\CallBack\CallBack.cpp
文件 517 2014-06-05 15:44 CallBack\CallBack\CallBack.h
文件 9310 2014-06-05 17:23 CallBack\CallBack\CallBack.rc
文件 6223 2014-06-05 17:23 CallBack\CallBack\CallBack.vcxproj
文件 2279 2014-06-05 17:23 CallBack\CallBack\CallBack.vcxproj.filters
文件 2657 2014-06-06 17:29 CallBack\CallBack\CallBackDlg.cpp
文件 823 2014-06-06 17:27 CallBack\CallBack\CallBackDlg.h
文件 2596 2014-06-06 08:48 CallBack\CallBack\CallBack_vs110_Debug_Win32.lnt
文件 163 2014-06-06 16:39 CallBack\CallBack\Color.cpp
文件 465 2014-06-06 16:37 CallBack\CallBack\Color.h
文件 4453 2014-06-05 15:44 CallBack\CallBack\ReadMe.txt
目录 0 2014-06-05 15:45 CallBack\CallBack\res\
文件 994 2014-06-05 17:01 CallBack\CallBack\resource.h
文件 67777 2012-01-11 16:22 CallBack\CallBack\res\CallBack.ico
文件 800 2014-06-05 15:45 CallBack\CallBack\res\CallBack.rc2
文件 210 2014-06-05 15:45 CallBack\CallBack\stdafx.cpp
文件 1751 2014-06-06 17:02 CallBack\CallBack\stdafx.h
文件 314 2014-06-05 15:45 CallBack\CallBack\targetver.h
相关资源
- OPC客户端源代码
- hough检测直线的程序
- 基于VC6.0的Bresenham直线算法
- vc网络聊天室源代码mfc聊天器VC网络编
- Ethernet帧结构解析程序
- VC++ 编写的 Modbus 协议类 并附带串口通
- QT调用VS生成的C++库
- VC++ HIDAPI实现USB数据读写
- SQlite3库及头文件在VS2010中MFC使用成功
- Live555 源代码 VC6
- 不用驱动直接获取硬盘信息 vc++
- VC++中运算表达式字符串解析求值四则
- VC++实现客户端与服务器端的文件传输
- VC++网络考试系统,服务器+用户端+数
- VC++和OpenGL实现八叉树分割
- VC/VC++ 动态加载Gif动画
- 三子连珠游戏VC++程序
- 随机线性网络编码和确定线性网络编
- VC 6.0快速修改工程名工具
- 开发一个VC++证券模拟交易系统源代码
- Em算法实现聚类(VC++实现)
- 课程设计--计算器基于MFC
- VC编写的飞机仪表显示
- MFC基于对话框的二进制与十六进制间
- vc 源码 md5字符串加密算法 绝对可以用
- VC6.0_MFC_读写配置文件
- MFC中给对话框添加皮肤Skin_H
- VC++ DES 加密解密算法
- vc2008工程转为vc6工具
- vc++实现哲学家吃面问题
评论
共有 条评论