ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dialog in Static Library

4 REPLIES 4
Reply
Message 1 of 5
EMD1954
771 Views, 4 Replies

Dialog in Static Library

I have a dialog box consisting of 8 progress bars which is used by multiple projects.  I define it in a project which creates a static library file called EMD_Common.lib which is on my library path.  The files that define the class are "Progress.cpp" and "Progress.h".  In my projects that use it, I #include "Progress.h", declare a global variable CProgress *dlg, and create (try to create) the dialog with the following:

 

CAcModuleResourceOverride resOverride;

dlg = new CProgress(acedGetAcadFrame());

dlg->Create(IDD_DIALOG_PROGRESS);

 

The ARX modules compile fine (no errors or warnings), but when I get to the code above when running the routines, I get an error about an unsupported operation.  The IDD_DIALOG_PROGRESS is defined in the resource.h file in the library project.

 

Any suggestions would be appreciated.

 

Thanks,

Ed

 

 

4 REPLIES 4
Message 2 of 5
owenwengerd
in reply to: EMD1954

You need to add the dialog resource to your ARX module's resources.

--
Owen Wengerd
ManuSoft
Message 3 of 5
EMD1954
in reply to: EMD1954

I tried it.  I added the resourse to my project's .rc file, made sure the #defines were in my project's resource.h file, recompiled without errors or warnings and got "Attempted an Unsupported Operation" then -> crash. Dumps me at

dlg->Create(IDD_DIALOG_PROGRESS);

 

Message 4 of 5
Balaji_Ram
in reply to: EMD1954

Hi Ed,

 

Sorry for the delay.

 

Can you please try the solution from this Devnote. We have converted most of such Devnotes as Devblog posts but I think this one has somehow got missed out. So, I have pasted it contents here for your reference.

 

Using a dialog resource from a resource-only DLL

Issue
I've created two projects and will use together. Project A is an resource-only
DLL file that has a dialog resource and other resources. Project B is an ARX
application that uses MFC in an extension DLL file and doesn't have any
resources. 
I use a LoadLibraryEx() function to provide temporary resource override before I
used my resources. However, when I use MyDialog::DoModal(), it causes an
"Unhandled Exception" error. Why?
Solution
An MFC extension DLL file usually has its own resource embedded into the same
DLL file so you know where to apply the temporary resource override. (This
assumes you know how to use a MFC extension DLL file in an ObjectARX
application). If it is from a different DLL file, you will have to loaded
explicitly and add the following code.
In the resource-only DLL - project A, append AFX_RESOURCE_DLL to the project
settings symbols list.
In the ARX module, project B, that uses the resource, do everything else you
normally do and then do the following. Notice the default dialog constructor is
used and InitModalIndirect() is called before DoModal().

//
// assuming that your project A has a dialog resource with the ID IDD_DIALOG1 
// and the dll name is resourceDll.dll.
//
void testDialog()
{
    HMODULE h = LoadLibraryEx("resourceDll.dll", NULL,
LOAD_LIBRARY_AS_DATAFILE);
    if(h)
    {

        CAcModuleResourceOverride temp;
        
        HRSRC hr = FindResource(h, MAKEINTRESOURCE(IDD_DIALOG1),
RT_DIALOG);
        HGLOBAL hg = LoadResource(h, hr);

        CTestDialog dlg; 
        dlg.InitModalIndirect(hg, acedGetAcadFrame());
        dlg.DoModal();
    }
}

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 5 of 5
EMD1954
in reply to: Balaji_Ram

I tried it.  I have an MFC Resource Only DLL called "EMD13__Resource.dll".  In my "B" program, I've #included it's header file "EMD13__Resource.h", and added a command as follows:

 

// ----- EMD13_Analysis.TestDialog command (do not rename)

staticvoid EMD13_AnalysisTestDialog(void)

{

HMODULE h = LoadLibraryEx(_T("C:\\My path\\EMD13__Resource.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE);

   

if(h)

{

CAcModuleResourceOverride temp;

       

HRSRC hr = FindResource(h, MAKEINTRESOURCE(IDD_EMDTEST), RT_DIALOG);

HGLOBAL hg = LoadResource(h, hr);

CEMDTest dlg;

dlg.InitModalIndirect(hg, acedGetAcadFrame());

dlg.m_csTest = _T("To Resource?");

if(dlg.DoModal() == IDOK) acedAlert(dlg.m_csTest); // From Resourse?

// if h

}// end of function EMD13_AnalysisTestDialog()

 

The resource file has a dialog with ID = IDD_EMDTEST.  It's class is CEMDTest and it has a single static text element whose variable is "m_csTest".

 

Both projects compile without errors or warnings but when I arxload project "B" into autocad (successfully) and call the command with TestDialog, nothing happens.

 

Do you see anything obviously wrong?

 

Thanks,

Ed

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost