-
using templates
I have started a win32 simple application. I created a template of a window with a button on it. In the WinMain() function how do I code for the template to apears. I get the error of "base class undeclared" when I include the "frmmain.h" file.
Thanx in advance!
-
please be more specific
and post your code if you want
-
I have a dialog with just one button on it.
Code:
#include "stdafx.h"
#include "resource.h"
#include "FrmMain.h"
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
CFrmMain d;
d.DoModal();
return 0;
}
In the stdafx.h file I have this in it.
Code:
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN
//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
//#include <windows.h>
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
And this is the errors that I get;
c:\program files\microsoft visual studio\myprojects\test\test2\frmmain.cpp(52) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Any one know how to fix the problems?
Thanx in advance!
-
Maybe you should ...
I am thinking you need to "#include" the "stdafx.h" header file to the dialog class's source/header file.
Code:
// In CFrmMain.h
#include "stdafx.h"
///////////////////////////
/* Other stuff here */
///////////////////////////
Code:
// In CFrmMain.cpp
#include "stdafx.h"
///////////////////////////
/* Other stuff here */
///////////////////////////
-
Thanx. I don't know if that is the correct thing to do but after puting that header I get the following errors;
Code:
FrmMain.obj : error LNK2005: "public: __thiscall CFrmMain::CFrmMain(class CWnd *)" (??0CFrmMain@@QAE@PAVCWnd@@@Z) already defined in test2.obj
FrmMain.obj : error LNK2005: "protected: virtual void __thiscall CFrmMain::DoDataExchange(class CDataExchange *)" (?DoDataExchange@CFrmMain@@MAEXPAVCDataExchange@@@Z) already defined in test2.obj
FrmMain.obj : error LNK2005: "protected: virtual struct AFX_MSGMAP const * __thiscall CFrmMain::GetMessageMap(void)const " (?GetMessageMap@CFrmMain@@MBEPBUAFX_MSGMAP@@XZ) already defined in test2.obj
FrmMain.obj : error LNK2005: "protected: void __thiscall CFrmMain::OnButtonClick(void)" (?OnButtonClick@CFrmMain@@IAEXXZ) already defined in test2.obj
FrmMain.obj : error LNK2005: "protected: static struct AFX_MSGMAP const CFrmMain::messageMap" (?messageMap@CFrmMain@@1UAFX_MSGMAP@@B) already defined in test2.obj
FrmMain.obj : error LNK2005: "private: static struct AFX_MSGMAP_ENTRY const * const CFrmMain::_messageEntries" (?_messageEntries@CFrmMain@@0QBUAFX_MSGMAP_ENTRY@@B) already defined in test2.obj
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/test2.exe : fatal error LNK1120: 2 unresolved externals
-
as u see youve already defined some stuff
so you should remove one
-
Thanx. That worked. But then other problems came;
Code:
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/test3.exe : fatal error LNK1120: 2 unresolved externals
How can I fix those errors?
Thanx in advance!
-
-
Thank you very much! I finaly got it to work. This is the first forum that helped me this much in C++. I have another question. How do I start a class. I know I have to first declare a variable of a class and then create and instance. I think that is how to do it but Im not sure. Could someone please direct me to the correct way to start this?
Thanx in advance!
-
In my opinion, the correct way to start is with a good book.
gg