Reputation: 2927
WTL is template library, so i have to implement it in template library header file.
I want to implement my logic in .cpp
file otherwise, i will have to code a huge header file.
for example, in MainFrm.h
// ...
// MainFrm.h
class CMainFrame :
public CFrameWindowImpl<CMainFrame>,
public CUpdateUI<CMainFrame>,
public CMessageFilter, public CIdleHandler
{
//...
void function1()
{
//...
}
void function2()
{
//...
}
}
I want to have function1()
and function2()
in myfunction.cpp
, how to do it?
Please guide.
EDIT:
Solved! thanks to Jan S. i had include myfunction.cpp into WTL project and add some lines:
MainFrm.h:
// ...
// MainFrm.h
#if 1
#include <atlframe.h>
#include <atlsplit.h>
#include <atlctrls.h>
#include <atlctrlw.h>
#include <atlctrlx.h>
#include "sampleView.h"
#include "resource.h"
#endif
// MainFrm.h
class CMainFrame :
public CFrameWindowImpl<CMainFrame>,
public CUpdateUI<CMainFrame>,
public CMessageFilter, public CIdleHandler
{
//...
void functionx();
//...
};
myfunction.cpp:
// myfunction.cpp
#include "stdafx.h"
#include "MainFrm.h"
void CMainFrame::functionx()
{
//...
}
Upvotes: 1
Views: 460
Reputation: 408
In your header put the declaration
// MainFrm.h
class CMainFrame :
public CFrameWindowImpl<CMainFrame>,
public CUpdateUI<CMainFrame>,
public CMessageFilter, public CIdleHandler
{
//...
void functionx();
//...
};
In your .cpp file put the definition
#include MainFrm.h
void CMainFrame::functionx()
{
// more code
}
The compiler errors
You seem to be missing WTL header includes
#include <atlframe.h>
#include <atlsplit.h>
Off topic but, in your header make sure you have
#pragma once
or
#ifndef UNIQUE_HEADER_NAME
#define UNIQUE_HEADER_NAME
//header code
#endif
This will stop duplicate declarations.
Upvotes: 1