Can't add Dialog resource

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
djorge
Senior Member
Senior Member
Posts: 422
Joined: 2003-07-03, 12:48 UTC
Location: Portugal

Can't add Dialog resource

Post by *djorge »

Hi,
i'm using Visual C++, and when i try to add a dialog resource to my plugin (and include afxwin.h) and compile i get the folowing error:

c:\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>

Do i have to create a MFC Dll with VS app wizard, and copy the contents of the provided sample source code to my project? I'm not sure if it works.

how do you guys do it to support mfc code?

Thanks in advance,
djorge
User avatar
fg_2002fr
Senior Member
Senior Member
Posts: 267
Joined: 2003-02-24, 10:12 UTC
Location: Tours (France)
Contact:

Post by *fg_2002fr »

Hi djorge,

if you want to use MFC you should not include windows.h. this is done directly by the call to afxwin.h
djorge
Senior Member
Senior Member
Posts: 422
Joined: 2003-07-03, 12:48 UTC
Location: Portugal

Post by *djorge »

You're rigth. I've changed the #include "windows.h" to #incliude "AfxWin.h", but now the complier tells me that there are two DllMain defined:
nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in fsplugin.obj
nafxcwd.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in fsplugin.obj; second definition ignored
Debug/fsplugin.wfx : fatal error LNK1169: one or more multiply defined symbols found

How do i solve this problem?

thanks,
djorge
User avatar
fg_2002fr
Senior Member
Senior Member
Posts: 267
Joined: 2003-02-24, 10:12 UTC
Location: Tours (France)
Contact:

Post by *fg_2002fr »

you should not have a dllmain entry too. this is done by the afx library.

you need to derive a class from CWinApp and declare an instance of this class.
Preprocessor definition must have WIN32, _DEBUG, _WINDOWS, _WINDLL, _AFXDLL for debug mode


============== sample from dircpy.wcx

CListplugApp theApp("DIRCPY_WCX");

BOOL CListplugApp::InitInstance()
{
BOOL val = CWinApp::InitInstance();
hInst = m_hInstance;
TRACE1("dircpy : InitInstance : %d\n", m_hInstance);
return val;
}

CListplugApp::CListplugApp(LPCTSTR pszAppName) : CWinApp(pszAppName)
{
TRACE0("dircpy : plug-in initialized\n");
}

====== end sample

but try to use the wizard to see the code generated. I think it's the best way to start a dll based on MFC and add your exported function.

FG
Post Reply