Click here to Skip to main content
16,007,843 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ICM Profiles.. Pin
Jeremy Falcon2-Mar-02 8:02
professionalJeremy Falcon2-Mar-02 8:02 
GeneralRe: ICM Profiles.. Pin
Jeremy Falcon4-Mar-02 7:43
professionalJeremy Falcon4-Mar-02 7:43 
GeneralMFC Dialog called dynamically Pin
1-Mar-02 22:51
suss1-Mar-02 22:51 
GeneralRe: MFC Dialog called dynamically Pin
Nish Nishant1-Mar-02 22:56
sitebuilderNish Nishant1-Mar-02 22:56 
GeneralRe: MFC Dialog called dynamically Pin
1-Mar-02 23:53
suss1-Mar-02 23:53 
GeneralRe: MFC Dialog called dynamically Pin
Nish Nishant2-Mar-02 0:11
sitebuilderNish Nishant2-Mar-02 0:11 
GeneralRe: MFC Dialog called dynamically Pin
Tomasz Sowinski2-Mar-02 1:37
Tomasz Sowinski2-Mar-02 1:37 
GeneralRe: MFC Dialog called dynamically Pin
2-Mar-02 5:27
suss2-Mar-02 5:27 
ok, a little code to go with this mess I have Smile | :)


// ******************************************************************
// MFCTestDll4.dll is a MFC extension dll.

#define MFCTESTDLL4_API __declspec(dllexport)

// used for determining of dll contains deObject definitions
extern "C"
{
MFCTESTDLL4_API char* GetData();
MFCTESTDLL4_API void SetData(char* data);
MFCTESTDLL4_API void CreateMyDialog(char* name);
}

// **********************************************************************


// the dll code is like this

// MFCTestDLL4.cpp : Defines the initialization routines for the DLL.
//

#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 MFCTestDLL4DLL = { NULL, 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)
{
TRACE0("MFCTESTDLL4.DLL Initializing!\n");

// Extension DLL one-time initialization
if (!AfxInitExtensionModule(MFCTestDLL4DLL, hInstance))
return 0;

// 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.

new CDynLinkLibrary(MFCTestDLL4DLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("MFCTESTDLL4.DLL Terminating!\n");
// Terminate the library before destructors are called
AfxTermExtensionModule(MFCTestDLL4DLL);
}
return 1; // ok
}


#include "MFCTestDLL4.h"
#include "testdialog4.h"
#include "DE3DUtils.h"

char gData[10000] = "testing the data stream";

MFCTESTDLL4_API char* GetData()
{
Log("Inside DLL, GetData()");
return gData;
}

MFCTESTDLL4_API void SetData(char* data)
{
Logf("Inside DLL, SetData(%s)",data);
strcpy(gData,data);
}

MFCTESTDLL4_API void CreateMyDialog(char* name)
{
Logf("Inside DLL, CreateMyDialog(%s)",name);

TestDialog4 t;

Log("Inside DLL, TestDialog t");

if (t.DoModal() == IDOK)
{
Log("Inside DLL, DoModal == IDOK");
SetData("Hello world we picked the idok button");
}

Log("Inside DLL, After dialog");
}



// **********************************************************************



// now, in my main app i do this


// find the dialog dll
// attempt to load the dll
char filename[255] = "resourcedll\\MFCTestDLL4.dll";
HMODULE hwnd = LoadLibrary(filename);
if (!hwnd)
{
// something went wrong when loading the DLL
Log("Unable To Load Resource Library",filename);
return;
}
else
{
// we have a good library to use
Log("Resource Library Loaded",filename);
}
// set the data
typedef void (*SETDATA)(char*);
SETDATA SetDataProc = (SETDATA) GetProcAddress(hwnd, "SetData");
if (!SetDataProc)
{
Log("Unable to locate SetData Function");
return;
}
else
{
Log("SetData Function located");
SetDataProc("from the main app");
}
// run the dialog
typedef void (*CREATEMYDIALOG)(char*);
CREATEMYDIALOG CreateMyDialogProc = (CREATEMYDIALOG) GetProcAddress(hwnd, "CreateMyDialog");
if (!CreateMyDialogProc)
{
Log("Unable to locate CreateMyDialog Function");
return;
}
else
{
Log("CreateMyDialog Function located");
CreateMyDialogProc("TestDialog");
}
// get the data
typedef char* (*GETDATA)();
GETDATA GetDataProc = (GETDATA) GetProcAddress(hwnd, "GetData");
if (!GetDataProc)
{
Log("Unable to locate GetData Function");
return;
}
else
{
Log("GetData Function located");
char s[255];
strcpy(s,GetDataProc());
}


// **********************************************************************
// after all of this, my log file looks like this...

Resource Library Loaded - resourcedll\MFCTestDLL4.dll
SetData Function located - (null)
Inside DLL, SetData(from the main app) - (null)
CreateMyDialog Function located - (null)
Inside DLL, CreateMyDialog(TestDialog) - (null)
Inside DLL, TestDialog t - (null)


// and i get a nice little windows messagebox telling me i screwed up Smile | :)
as you can see from the log file, it is during the DoMocal() call that I have the trouble.
any thoughts?
GeneralAbout CTypedPtrList class--"new" and "delete".. Pin
anju1-Mar-02 22:45
anju1-Mar-02 22:45 
Questionhow to get the whole URLs form the intetnet shortcuts(the file in c:\windows\history)? Pin
benben1-Mar-02 21:47
benben1-Mar-02 21:47 
AnswerRe: how to get the whole URLs form the intetnet shortcuts(the file in c:\windows\history)? Pin
Nish Nishant1-Mar-02 23:00
sitebuilderNish Nishant1-Mar-02 23:00 
AnswerRe: how to get the whole URLs form the intetnet shortcuts(the file in c:\windows\history)? Pin
2-Mar-02 0:23
suss2-Mar-02 0:23 
QuestionDeriving classes thru ClassWizard? Pin
Maverick1-Mar-02 21:42
Maverick1-Mar-02 21:42 
AnswerRe: Deriving classes thru ClassWizard? Pin
Mazdak1-Mar-02 21:52
Mazdak1-Mar-02 21:52 
AnswerRe: Deriving classes thru ClassWizard? Pin
Tomasz Sowinski2-Mar-02 1:44
Tomasz Sowinski2-Mar-02 1:44 
GeneralRe: Deriving classes thru ClassWizard? Pin
Maverick2-Mar-02 3:14
Maverick2-Mar-02 3:14 
GeneralRe: Deriving classes thru ClassWizard? Pin
14-Mar-02 23:38
suss14-Mar-02 23:38 
GeneralProblem in Hijri date in Win2000 ! Pin
Hadi Rezaee1-Mar-02 20:12
Hadi Rezaee1-Mar-02 20:12 
GeneralA small tip for capturing focus in Win2K Pin
Nish Nishant1-Mar-02 19:40
sitebuilderNish Nishant1-Mar-02 19:40 
GeneralBeginning MFC (Prosise) Part III - Now What? :: C++ Pin
valikac1-Mar-02 14:49
valikac1-Mar-02 14:49 
GeneralRe: Beginning MFC (Prosise) Part III - Now What? :: C++ Pin
Nish Nishant1-Mar-02 14:57
sitebuilderNish Nishant1-Mar-02 14:57 
GeneralRe: Beginning MFC (Prosise) Part III - Now What? :: C++ Pin
Christian Graus1-Mar-02 15:32
protectorChristian Graus1-Mar-02 15:32 
GeneralRe: Beginning MFC (Prosise) Part III - Now What? :: C++ Pin
valikac1-Mar-02 16:03
valikac1-Mar-02 16:03 
GeneralRe: Beginning MFC (Prosise) Part III - Now What? :: C++ Pin
Christian Graus1-Mar-02 16:19
protectorChristian Graus1-Mar-02 16:19 
GeneralRe: Beginning MFC (Prosise) Part III - Now What? :: C++ Pin
Nish Nishant1-Mar-02 16:35
sitebuilderNish Nishant1-Mar-02 16:35 

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.