首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

简单的的很难吗?该怎么处理

2012-02-20 
简单的的很难吗?1。在VC,file.C 里面编译可以定义PROC lpAdder MessageBoxA在VC,file.CPP里面编译时却不

简单的的很难吗?
1。
在VC,file.C 里面编译可以定义
PROC lpAdder = MessageBoxA;

在VC,file.CPP里面编译时却不可以定义????
PROC lpAdder = MessageBoxA;

int WINAPI MyMesageBoxA(
HWND hWnd, // handle of owner window
LPCTSTR lpText, // address of text in message box
LPCTSTR lpCaption, // address of title of message box
UINT uType // style of message box
)
{
return lpAdder(NULL,lpText,lpCaption,uType);//
}
难道C++里面不可以这样定义?
把MessageBox(HWND , LPCTSTR ,LPCTSTR ,UINT )转换成(CALLBACK *PROC)(),无参数型的?
谢谢!


[解决办法]
typedef int (WINAPI *PFNMESSAGEBOX)(HWND hWnd,LPCTSTR lpText,LPCTSTR lpCaption,UINT uType);

int WINAPI MyMesageBoxA(
HWND hWnd, // handle of owner window
LPCTSTR lpText, // address of text in message box
LPCTSTR lpCaption, // address of title of message box
UINT uType // style of message box
)
{
return ((PFNMESSAGEBOX)(lpAdder))(NULL,lpText,lpCaption,uType); //函数签名转换
}

[解决办法]

探讨
typedef int (WINAPI *PFNMESSAGEBOX)(HWND hWnd,LPCTSTR lpText,LPCTSTR lpCaption,UINT uType);

int WINAPI MyMesageBoxA(
HWND hWnd, // handle of owner window
LPCTSTR lpText, // address of text in mes……

热点排行