Click here to Skip to main content
15,908,015 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Text Editor as a list control? Pin
Magnus Westin8-Jul-03 6:48
Magnus Westin8-Jul-03 6:48 
GeneralRe: Text Editor as a list control? Pin
Jay Hova8-Jul-03 7:53
Jay Hova8-Jul-03 7:53 
GeneralRe: Text Editor as a list control? Pin
Magnus Westin8-Jul-03 8:10
Magnus Westin8-Jul-03 8:10 
GeneralRe: Text Editor as a list control? Pin
Jay Hova8-Jul-03 8:54
Jay Hova8-Jul-03 8:54 
GeneralRe: Text Editor as a list control? Pin
David Crow8-Jul-03 9:33
David Crow8-Jul-03 9:33 
QuestionHow to unzip archive file in C/C++ Pin
Valera2411768-Jul-03 6:07
Valera2411768-Jul-03 6:07 
AnswerRe: How to unzip archive file in C/C++ Pin
Jon Sagara8-Jul-03 6:21
Jon Sagara8-Jul-03 6:21 
GeneralMysterious C++ behaviour Pin
RK_20008-Jul-03 6:01
RK_20008-Jul-03 6:01 
I have 4 DLLs as following:

CFiles.dll
CExceptions.dll
CXML.Dll
CDataFormat.dll


CExceptions contains an Object factory that follows the Loki Object Factory model as following:

It has a map containing function pointers with enteries such as following:

void CExceptionFactory::InitializeMap()
{
AddToMethodMap(CExceptionFactory::DATABASE_EXCEPTIONS, CreateDatabaseExceptions);
AddToMethodMap(CExceptionFactory::NULL_POINTER_EXCEPTIONS, CreateNullPointerExceptions);
AddToMethodMap(CExceptionFactory::READER_EXCEPTIONS, CreateReadExceptions);
}

Now, within the DataFormat DLL, depending on the type of formatting, I load different DLLs. For instance, if the type is XML, I load the XML dll as following:

case ID_XML:
{
//m_pDataFormat = new XML();
HMODULE hLibrary = 0;
DataFormatProc pfnDataFormat = 0;
GEA pfnGEA = 0;

hLibrary = ::LoadLibrary("CXML.dll");

if(hLibrary != 0)
{
DWORD dw = 0;
pfnDataFormat = (DataFormatProc) GetProcAddress (hLibrary, "CreateXMLSingletonInstance");

dw = GetLastError();

if(pfnDataFormat != 0)
m_pDataFormat = pfnDataFormat();

m_pDataFormat->LoadFile(L"Stocks.xml");

::FreeLibrary(hLibrary);
}

Now if the method LoadFile above fails, it throws an exception by calling CExcpetionFactory class above and CExceptionFactory will try to look inside its Loki map and retrieve the required method as shown below:



CExceptionFactory::CExceptionFactory(int nTypeID, const string & strMessage)
{
InitializeMap();
CreateObject(nTypeID);

if(m_pException != 0)
{
m_pException->Log(strMessage);
delete m_pException;
}
else
{
throw CExceptionFactory(CExceptionFactory::NULL_POINTER_EXCEPTIONS,"Unknown Exception.");
}
}


void CExceptionFactory::CreateObject(int nTypeID)
{
CallbackMap::const_iterator i = m_Callbacks.find(nTypeID);

if( i != m_Callbacks.end())
{
m_pException = (i->second)();

}
else
m_pException = 0;

}

Now, as soon as the code hits (i->second)(); , it leaves the exception dll all together and goes back to the beginning of that case statement above.

I am quite puzzled with this behaviour.

I am guessing I have a function pointer to begin with the loaded DLL and then I am getting a second function pointer and the compiler gets confused, but why should it?

Your help would be highly appreciated.

thanksConfused | :confused:

GeneralRe: Mysterious C++ behaviour Pin
Magnus Westin8-Jul-03 6:52
Magnus Westin8-Jul-03 6:52 
GeneralWM_KEYDOWN Events... Pin
Tintori Francesco8-Jul-03 5:09
Tintori Francesco8-Jul-03 5:09 
GeneralRe: WM_KEYDOWN Events... Pin
Mike Dimmick8-Jul-03 5:26
Mike Dimmick8-Jul-03 5:26 
GeneralRe: WM_KEYDOWN Events... Pin
Tintori Francesco8-Jul-03 5:39
Tintori Francesco8-Jul-03 5:39 
GeneralRe: WM_KEYDOWN Events... Pin
Rage8-Jul-03 5:55
professionalRage8-Jul-03 5:55 
GeneralRe: WM_KEYDOWN Events... Pin
Mike Dimmick8-Jul-03 5:56
Mike Dimmick8-Jul-03 5:56 
GeneralRe: WM_KEYDOWN Events... Pin
Tintori Francesco8-Jul-03 6:01
Tintori Francesco8-Jul-03 6:01 
Generalgetting the path Pin
pnpfriend8-Jul-03 4:53
pnpfriend8-Jul-03 4:53 
GeneralRe: getting the path Pin
valikac8-Jul-03 5:30
valikac8-Jul-03 5:30 
GeneralRe: getting the path Pin
Joaquín M López Muñoz8-Jul-03 7:02
Joaquín M López Muñoz8-Jul-03 7:02 
GeneralRe: getting the path Pin
David Crow8-Jul-03 7:29
David Crow8-Jul-03 7:29 
GeneralWorking with files Pin
jales8-Jul-03 4:02
jales8-Jul-03 4:02 
GeneralRe: Working with files Pin
AlexO8-Jul-03 4:06
AlexO8-Jul-03 4:06 
GeneralRe: Working with files Pin
John M. Drescher8-Jul-03 4:13
John M. Drescher8-Jul-03 4:13 
GeneralRe: Working with files Pin
Rage8-Jul-03 5:57
professionalRage8-Jul-03 5:57 
GeneralRe: Working with files Pin
Magnus Westin8-Jul-03 6:38
Magnus Westin8-Jul-03 6:38 
GeneralRe: Working with files Pin
jales9-Jul-03 0:38
jales9-Jul-03 0:38 

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.