Click here to Skip to main content
15,895,084 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: catch block and 'return' Pin
ns30-Sep-02 4:48
ns30-Sep-02 4:48 
GeneralRe: catch block and 'return' Pin
Chris Losinger30-Sep-02 4:48
professionalChris Losinger30-Sep-02 4:48 
GeneralQuestion about excel automation with VC++ Pin
Gérald Mercet30-Sep-02 4:26
Gérald Mercet30-Sep-02 4:26 
GeneralRe: Question about excel automation with VC++ Pin
Stephane Rodriguez.30-Sep-02 4:42
Stephane Rodriguez.30-Sep-02 4:42 
GeneralRe: Question about excel automation with VC++ Pin
Gérald Mercet30-Sep-02 5:24
Gérald Mercet30-Sep-02 5:24 
Questiondragable view? Pin
dazinith30-Sep-02 4:00
dazinith30-Sep-02 4:00 
GeneralCreate resource dll's Pin
Zizilamoroso30-Sep-02 3:39
Zizilamoroso30-Sep-02 3:39 
GeneralRe: Create resource dll's Pin
Stephane Rodriguez.30-Sep-02 4:02
Stephane Rodriguez.30-Sep-02 4:02 
Grote Smurf wrote:
What I want to do is create an mfc-dll with one dialog inside, created with the resource editor. The dll's dialog will be called from another app through some sort of ShowDialog()-function

Your DLL must implement the DllMain entry-point, and attach itself to the chain of app resources, thanks to two calls :
- AfxInitExtensionModule(...)
- instantiation of CDynLinkLibrary(...)

See code below


Grote Smurf wrote:
What dll-wizard do I use for this (mfc-static, mfc-dynamic or mfc-extension)?
Are there any specs to set in the project wizard?


That's up to you.


Now for a sample code :
// myresourceen.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include <afxdllx.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

static AFX_EXTENSION_MODULE myresourceDLL = { NULL, NULL };
static CDynLinkLibrary *s_Module = NULL;

extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
	// Remove this if you use lpReserved
	UNREFERENCED_PARAMETER(lpReserved);

	if (dwReason == DLL_PROCESS_ATTACH)
	{
		// Extension DLL one-time initialization
		if (!AfxInitExtensionModule(myresourceDLL, hInstance))
			return 0;

		TRACE0("MYRESOURCE.DLL Initializing!\n");

		// Insert this DLL into the resource chain
		// NOTE: If this Extension DLL is being implicitly linked to by
		//  an MFC Regular DLL (such as an ActiveX Control)
		//  instead of an MFC application, then you will want to
		//  remove this line from DllMain and put it in a separate
		//  function exported from this Extension DLL.  The Regular DLL
		//  that uses this Extension DLL should then explicitly call that
		//  function to initialize this Extension DLL.  Otherwise,
		//  the CDynLinkLibrary object will not be attached to the
		//  Regular DLL's resource chain, and serious problems will
		//  result.

		s_Module = new CDynLinkLibrary(myresourceDLL);
		ASSERT(s_Module != NULL);
	}
	else if (dwReason == DLL_PROCESS_DETACH)
	{
		TRACE0("MYRESOURCE.DLL Terminating!\n");

		// Terminate the library before destructors are called
		ASSERT(s_Module != NULL);
		if (s_Module) 
		{
			// Remove this resource from the resource list
			delete s_Module;
			s_Module = NULL;
		}
		AfxTermExtensionModule(myresourceDLL);
	}
	return 1;   // ok
}
 

__declspec(dllexport) void uselessmethod();

__declspec(dllexport) void uselessmethod()
{
}




sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
GeneralRe: Create resource dll's Pin
Zizilamoroso30-Sep-02 4:22
Zizilamoroso30-Sep-02 4:22 
GeneralRe: Create resource dll's Pin
Andreas Saurwein30-Sep-02 4:22
Andreas Saurwein30-Sep-02 4:22 
GeneralRe: Create resource dll's Pin
Zizilamoroso30-Sep-02 4:25
Zizilamoroso30-Sep-02 4:25 
GeneralProblem with tray icon - very strange behaviour Pin
s_k30-Sep-02 3:36
s_k30-Sep-02 3:36 
GeneralChild Window Focus Pin
mleslar30-Sep-02 3:24
sussmleslar30-Sep-02 3:24 
GeneralCFileDialog and "New Folder" button. Pin
ns30-Sep-02 2:57
ns30-Sep-02 2:57 
GeneralbrowseInfo structure Pin
ns30-Sep-02 2:44
ns30-Sep-02 2:44 
GeneralRe: browseInfo structure Pin
jmkhael30-Sep-02 2:47
jmkhael30-Sep-02 2:47 
GeneralRe: browseInfo structure Pin
ns30-Sep-02 2:53
ns30-Sep-02 2:53 
Generalhow to prevent the new folder button? Pin
ns30-Sep-02 2:55
ns30-Sep-02 2:55 
GeneralRe: how to prevent the new folder button? Pin
Michael P Butler30-Sep-02 3:01
Michael P Butler30-Sep-02 3:01 
GeneralThanks!! Pin
ns30-Sep-02 3:09
ns30-Sep-02 3:09 
GeneralCOM in MFC Pin
Shamim Afridi30-Sep-02 2:11
sussShamim Afridi30-Sep-02 2:11 
GeneralRe: COM in MFC Pin
Stephane Rodriguez.30-Sep-02 11:05
Stephane Rodriguez.30-Sep-02 11:05 
GeneralSerious Bug in VC7 Pin
Elf30-Sep-02 0:54
Elf30-Sep-02 0:54 
GeneralRe: Serious Bug in VC7 Pin
Stephane Rodriguez.30-Sep-02 1:19
Stephane Rodriguez.30-Sep-02 1:19 
GeneralRe: Serious Bug in VC7 Pin
Blade[DMS]30-Sep-02 2:26
Blade[DMS]30-Sep-02 2:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.