This topic is 4755 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey guys, been a long time :) Ok, here's the deal. I have a DLL that gets loaded into my application at run time. I have defined a resource file within that DLL that defines a dialog box and I'm trying to create and display the dialog from the DLL. Some source code for you.... This code is in the DLL along with the resource file and resource header

/**********************************************************************
/* CIgnusDebug.cpp
/*
/* Contains the function implementations for the CIgnusDebug class
/*
/**********************************************************************/

#include "CIgnusDebug.h"

//
// Static instantiation
//
char	CIgnusDebug::m_szTextBuf[MAX_BUFFER_SIZE];
HWND	CIgnusDebug::m_hDlg = NULL;
HINSTANCE	g_hDLL = GetModuleHandle(NULL);

//
// INIT
//
void	CIgnusDebug::Init()
{
char	errBuf[256];
char	errStr[256];

// Need to load the richedit dll
MessageBox(NULL, "Error Loading riched20.dll. Verify that this DLL is loaded on the system", "IgnusEngine - Error", MB_OK | MB_ICONINFORMATION);

// Create the dialog box
m_hDlg = CreateDialog(g_hDLL, MAKEINTRESOURCE(IDD_IGNUS_LOG),NULL, (DLGPROC)LogDlgProc);
if(!m_hDlg)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), LANG_SYSTEM_DEFAULT, errBuf, 256, NULL);
MessageBox(NULL, errStr, "IgnusEngine - Error", MB_OK | MB_ICONINFORMATION);
}

}


The CreateDialog function fails. The error message returned from windows is : "The specified resource name cannot be found in the image file" I've looked basically everywhere and there isn't much info on this error. Any insight would be very helpful. Thanks!

##### Share on other sites
Quote:
 If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process (.exe file).

Your g_hDLL is the application module handle. To get the dll handle, get it from the DllMain() function.

I didn't test this. I usually avoid this kind of situation.

HTH,

##### Share on other sites
Hey,

I actually was using that at one point, but it didn't seem to be the issue. At least not that by itself. But you are correct and I should change it back because it is at least fundamentally closer to correct.

About why I'm doing it this way: My engine is contained in a DLL and I want to create a log/debug window with rich edit text control and I'm just spitting out text to this control. Pretty much the same little console that quakeIII arena uses and I think doom3 uses the same because it's the same code base.

If you know of another way of doing something like this while keeping it outside of the application using the DLL then I'm all ears :)

Thanks again!

##### Share on other sites
As usual, I must have been missing something simple becuase when I used the DLL instance from DllMain, it worked perfect.

Sorry for being such an ignoramous, and thanks for your suggestion!