Solved

Modless dialog box puzzlement....

Posted on 2001-07-03
5
680 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 131
no14 challenge 14 69
Problem to open Excel file 15 136
Problem to App source 6 41
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

831 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