//Hello.h
class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance ();
};class CMainWindow : public CFrameWnd
{
public:
CMainWindow ();protected:
afx_msg void OnPaint ();
DECLARE_MESSAGE_MAP ()
};
//Hello.cpp
#include <afxwin.h>
#include "Hello.h"CMyApp myApp;/////////////////////////////////////////////////////////////////////////
// CMyApp member functionsBOOL CMyApp::InitInstance ()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow (m_nCmdShow);
m_pMainWnd->UpdateWindow ();
return TRUE;
}/////////////////////////////////////////////////////////////////////////
// CMainWindow message map and member functionsBEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_PAINT ()
END_MESSAGE_MAP ()CMainWindow::CMainWindow ()
{
Create (NULL, _T ("The Hello Application"));
}void CMainWindow::OnPaint ()
{
CPaintDC dc (this);
CRect rect;
GetClientRect (&rect); dc.DrawText (_T ("Hello, MFC"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance ();
};class CMainWindow : public CFrameWnd
{
public:
CMainWindow ();protected:
afx_msg void OnPaint ();
DECLARE_MESSAGE_MAP ()
};
//Hello.cpp
#include <afxwin.h>
#include "Hello.h"CMyApp myApp;/////////////////////////////////////////////////////////////////////////
// CMyApp member functionsBOOL CMyApp::InitInstance ()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow (m_nCmdShow);
m_pMainWnd->UpdateWindow ();
return TRUE;
}/////////////////////////////////////////////////////////////////////////
// CMainWindow message map and member functionsBEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_PAINT ()
END_MESSAGE_MAP ()CMainWindow::CMainWindow ()
{
Create (NULL, _T ("The Hello Application"));
}void CMainWindow::OnPaint ()
{
CPaintDC dc (this);
CRect rect;
GetClientRect (&rect); dc.DrawText (_T ("Hello, MFC"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
解决方案 »
- 如何用DirectInput 枚举两个游戏杆?
- 如何达到独立兼职做些项目?
- 求助:关于注册表RegQueryValueEx函数使用问题。
- winpcap的发送函数pcap_sendpacket老错,花费了很多时间调试,求助!
- lisctcontrol 分页功能
- 服务器send成功,但是客户机没有接收到信息,请问为什么?
- 高手,如何同时读入多个文档到内存区?
- IUnknown Interface和_stdcall是做什么用的?
- 如何让应用程序不出现在应用程序栏(不是通知区域)?
- 遇到一个题,感到有点晕,请帮忙看一下!
- 在Windows XP下如何为VC++.NET的应用程序进行打包发布,使得在非.NET平台下(如win98、winME、win2000等)也能使用??
- 急急急,win2000的串口通信不正常问题,使用MSCOMM控件控制RTS在98下可以,2000下出现问题
就是没法编译。
分别建一个.h文件,
一个.cpp文件,装下各自的内容,可以运行!
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/hello.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.hello.exe - 3 error(s), 0 warning(s)
以上错误如何修正?还请高手言明创建选项和步骤!!!谢谢!!!
通过。
Use run_time library 里选Multithreaded试试看
endthreadex来创建和结束线程,而默认的Win32创建的项目编译选项是单线程的,因此会出现上面的错误,其实只要把编译选项的/ML 改为/MT就可以了,《深入浅出MFC》中对这个问题有讲解,可以看看。
1、选win32 Application-->An Empty project,Project-->Add to project/File-->添加Hello.c和Hello.h代码
2、选Project/Settings/Normal-->Microsoft Foundation Classes里选Use MFC in a Shared DLL或Use MFC in a Static Library。
在Project/Settings/c/c++-->Categoty里选code generration
-->Use run-time library里选Debug Multithreaded。
哎哟!!!写写清楚嘛!!让我找了几分钟!!!
Compiling...
hello.cpp
Linking...
libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/hello.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.hello.exe - 2 error(s), 0 warning(s)