Solved

Modless dialog box puzzlement....

Posted on 2001-07-03
5
674 Views
Last Modified: 2013-11-20
Have a DLL class dynamically linked to the MFC.
This class is nothing more than a processing class so has no window associated with it.
I would however like a dialog & progress bar to display visually what is going on as some of the data files that will be loaded are big and time consuming.
I tried to use a modeless dialog box but keep getting the error:

ERROR: Cannot find dialog template with IDD 0x2713.

I've double checked the directories and all files are there , included in the project and the dialog box is available for editing.

Here are some relevant code snippets?. Any suggestions as to where I could have screwed up???

Resource .h
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by SimplyClass.rc
//
#define IDC_PROGBAR                     10000
#define IDD_PROGDLG                     10000
#define IDC_PROGRESS1                   10003
#define IDD_SHOWACTS                    10003

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        10004
#define _APS_NEXT_COMMAND_VALUE         32772
#define _APS_NEXT_CONTROL_VALUE         10004
#define _APS_NEXT_SYMED_VALUE           10000
#endif
#endif

Declaration:

class CModless : public CDialog
{
// Construction
public:
     CModless(CWnd* pParent = NULL);   // standard constructor

// Dialog Data
     //{{AFX_DATA(CModless)
     enum { IDD = IDD_SHOWACTS };
          // NOTE: the ClassWizard will add data members here
     //}}AFX_DATA
}

Constructor:
CModless::CModless(CWnd* pParent /*=NULL*/)
     : CDialog(CModless::IDD, pParent)
{
     //{{AFX_DATA_INIT(CModless)
          // NOTE: the ClassWizard will add member initialization here
     //}}AFX_DATA_INIT
     if (Create (CModless::IDD,pParent) )
          ShowWindow(SW_SHOW);
}

Implementation:
CModless* WinShow = new CModless();

Thanks..

0
Comment
Question by:dooley090698
5 Comments
 
LVL 3

Expert Comment

by:aphillips
ID: 6251435
In the DLL I think you need to use
AfxSetResourceHandle(AfxGetInstanceHandle());

You night also have to save the current resource handle using AfxGetResourceHandle() and restore it later.
0
 

Author Comment

by:dooley090698
ID: 6251479
Checked that out but...the resource is in the DLL project itself,and included in the project directories,
Should I move it??
I'm confused about the Cannot find dialog template message as the files are all there.
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 100 total points
ID: 6251839
With respect to resources, the DLL is considered a part of the EXE, so the system will first look in the EXE unless you use...

  AfxSetResourceHandle(AfxGetInstanceHandle());

You also need to use...

   AFX_MANAGE_STATE(AfxGetStaticModuleState());

upon any entry into the DLL.  For instance if the EXE calls a DLL fn DoThatDllProcessing(), which, in turn creates the dialog box, then be sure that the first line in DoThatDllProcessing() is:

AFX_MANAGE_STATE(AfxGetStaticModuleState());

-- Dan
0
 

Expert Comment

by:lil_elvis2000
ID: 6254027
Since it appears that you did not make the DLL an extension DLL, the AFX_MANAGE_STATE(...) approach is the way to go.

Place this line as the first line in any function that access a resource. It will take care to reset the resource handle back when the function ends.
0
 
LVL 3

Expert Comment

by:romanm
ID: 6278183
Q: is the error a compilation, link or run-time error?
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now