Archived

This topic is now archived and is closed to further replies.

wah_on_2

How to correct it?

Recommended Posts

wah_on_2    122
I am the beginner using MFC in Viusal C++. #include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { CWnd WndObj; WndObj.CreateEx(WS_EX_APPWINDOW, "testing", "testing", WS_POPUP, 0, 0, 640, 480, NULL, NULL, NULL); ........ return 0; }; compile error: Why? How can i solve it? nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCD.lib(new.obj) nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCD.lib(dbgdel.obj) nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex Debug/LongRunner.exe : fatal error LNK1120: 2 unresolved externals

Share this post


Link to post
Share on other sites
Askadar    122
Can''t use MFC like that. You don''t need WinMain for MFC, it''s in the header files and calls the framework, so you should not mess with it.

Now MFC is too complex to explain it on the fly, but generally you need to derive a class from CWinApp and one from CWnd, and than start from there with a proper message map and do the initialization in CWinApp::InitInstance(), where you attach your window.

Look up MFC in your VC6 documentation.

Share this post


Link to post
Share on other sites
wah_on_2    122
Yes. I think MFC is too complex for me.
In fact, i just want to create button, picturebox and textbox. I know MFC can provide those of them.

Besides MFC, can i have another method to create those controls?

Please help me quickly. Thanks a lot of.

Share this post


Link to post
Share on other sites
Askadar    122
You can create those by creating new windows that are childs of your main window and are of the correct window classes.

If you want to learn about MFC (it''s a great tool) check into "MFC Programming from the Ground Up" by Herbert Schildt.

The best I found, and he''s a great author!

Share this post


Link to post
Share on other sites
wah_on_2    122
"MFC Programming from the Ground Up" Is it a book?

Mm....I have a question. When i open a new project in VC++, should i open the Win32 Application for using MFC?
I mean that can i use the MFC in Win32 Application? Or can i only use MFC in MFC AppWizard?

Share this post


Link to post
Share on other sites