请问,在不是基于MFC的VC++程序中,怎样使用MFC中的类,比如,CPoint 请问,在不是基于MFC的VC++程序中,怎样使用MFC中的类,比如,CPoint,请大侠们指点!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 try#include <iostream>#include <afxwin.h>using namespace std;int main(){ CPoint pt(1,2); cout << pt.x <<"," << pt.y << endl; return 0;}make sure you use /MD compiler option,for exampleD:\>vcvars32D:\>cl /MD testcpp.cpp using namespace std; 这个有什么用/MD 有什么用 程序中,有#include <windows.h>,再添上#include <afxwin.h>有错误提示:d:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>Error executing cl.exe.a.exe - 1 error(s), 0 warning(s) 改变一下包含头文件的顺序,把#include <windows.h>放到#include <afxwin.h>之前:#include <windows.h>,#include <afxwin.h>另外在Project/Setting/General中选择using MFC in a shared DLL。很多MFC类需要多线程版,所以还需要在Project/Setting/ C/C++ 的 Code Generation的use run-time library 中选择多线程,比如Debug Multithreaded DLL(for Debug版) 或者Multithreaded DLL(for Releas版) 只需#include <afx.h>,然后在Project/Setting/General中选择using MFC in a shared DLL。就这样就可以了,我经常在Console程序里面用MFC的类,比如CList,CMap等等。 因为cout是在标准库iostream里面声明的,而且用namespace封装了起来,你如果不用using指示符的话则cout等所有标准库里面的所有类对你的程序是不可见的。 我试了一下,顺序应该是:#include <afxwin.h>#include <windows.h>多谢大家了 MSXML使用cloneNode(true)为什么实现不了深拷贝? 怎么在OCX的事件里面传递内存(指针) TextOut函数问题 一个关于控件的输入输出的显示问题!! debug程序不能运行????? C++前辈进来一下啊,小问题 在VC下如何写DLL,我用VC向导生成了一个空的DLL。 请问怎么能枚举一个进程下的所有线程 帮我找个汽车修理厂的程序 为什么在switch(expression)中不能用CString类? 关闭工具条是会发出什么系统消息 请各位指教:急!,在线等候.
#include <afxwin.h>using namespace std;int main()
{
CPoint pt(1,2);
cout << pt.x <<"," << pt.y << endl;
return 0;
}make sure you use /MD compiler option,for example
D:\>vcvars32
D:\>cl /MD testcpp.cpp
/MD 有什么用
有错误提示:d:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
Error executing cl.exe.a.exe - 1 error(s), 0 warning(s)
#include <afxwin.h>
另外在Project/Setting/General中选择using MFC in a shared DLL。很多MFC类需要多线程版,所以还需要在Project/Setting/ C/C++ 的 Code Generation的use run-time library 中选择多线程,比如Debug Multithreaded DLL(for Debug版) 或者Multithreaded DLL(for Releas版)
#include <afxwin.h>
#include <windows.h>
多谢大家了