Solved

Modless dialog box puzzlement....

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sameEnds challenge 3 187
difference between String.subString() and String.subSequence() 6 265
has22 challenge 11 107
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 1,279
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 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