Solved

Dialog of DLL not found

Posted on 2008-06-10
4
355 Views
Last Modified: 2013-12-14
Hello Everybody

I have created a DLL for an already existing project and have a problem when displaying its dialog. There are already DLLs with dialogs in the project, which work perfectly. So I tryed to do the same procedure, my dialog just doesn't display.

What I did:
1. I created MFC AppWizard (dll), the name is Scanner.dll
2. I added the following:
#ifdef DLLDIR_EX
   #define DLLDIR  __declspec(dllexport)
#else
   #define DLLDIR  __declspec(dllimport)
#endif
and set DLLDIR_EX in the preporcessor definitions

3. I commented out all the App-Stuff including the Message maps
4. I pressed "Insert"--->"Form" for a new Dialog
5. My class has to inherit from CMyDialog instead of from CDialog. CMyDialog works with all the other dialogs of the project.

My new dll Scanner.dll compiles and links fine, but when running my exe programm, the dialog of Scanner.dll is not shown. When I run it in the debugger, I find that the call
"HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);"
is failing in DLGCORE.CPP. The Parameters are hInst=0x00001b58 (this is the number of the dialog in the rc-file) and m_lpszTemplateName=0x00400000 (I don't know what that is).

Can anybody help me display my dialog ?

Thank you so much !

Sonja
//Scanner.h:
//------------
#ifdef SCANNER_DLLDIR_EX
   #define SCANNER_DLLDIR  __declspec(dllexport)   // export DLL information
#else
   #define SCANNER_DLLDIR  __declspec(dllimport)   // import DLL information
#endif 
 
 
 
#pragma comment(lib, "Scanner.lib")
 
class SCANNER_DLLDIR CScannerApp
{
public:
	CScannerApp();
  static int RunThisScanDlg();
};
 
 
//Scanner.cpp:
//------------
int CScannerApp::RunThisScanDlg()
{
  CScanDialog ScanDialog;
  ScanDialog.DoModal(); //in here it fails but the programm continues to the next line !!!
  return 1;             
}
 
 
 
//ScanDialog.h
#include "resource.h"
#include "MyDialog.h"
 
class CScanDialog : public CMyDialog
{
// Construction
public:
	CScanDialog(CWnd* pParent = NULL);   // standard constructor
 
// Dialog Data
	//{{AFX_DATA(CScanDialog)
	enum { IDD = IDD_SCANDIALOG_DIALOG };
		// NOTE: the ClassWizard will add data members here
	//}}AFX_DATA
 
 
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CScanDialog)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL
 
// Implementation
protected:
 
	// Generated message map functions
	//{{AFX_MSG(CScanDialog)
	afx_msg void OnScan();
	afx_msg void OnCancel();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};
 
 
//ScanDialog.cpp
//--------------
 
#include "stdafx.h"
#include "Scanner.h"
#include "ScanDialog.h"
 
void CScanDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CScanDialog)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}
 
 
BEGIN_MESSAGE_MAP(CScanDialog, CDialog)
	//{{AFX_MSG_MAP(CScanDialog)
	ON_BN_CLICKED(IDC_SCAN, OnScan)
	ON_BN_CLICKED(IDC_CANCEL, OnCancel)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
 
CScanDialog::CScanDialog(CWnd* pParent /*=NULL*/)
	: CMyDialog(CScanDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CScanDialog)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}
 
void CScanDialog::OnScan() 
{
	// TODO: Add your control notification handler code here
	
}
 
void CScanDialog::OnCancel() 
{
	// TODO: Add your control notification handler code here
	
}

Open in new window

0
Comment
Question by:Sonja_M
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 19

Accepted Solution

by:
alb66 earned 499 total points
ID: 21757391
May be you are loading dialog from applicatione resource instead that from dll resource.
Look at the following:
http://www.eggheadcafe.com/forumarchives/vcmfc/feb2006/post25611987.asp
0
 

Author Comment

by:Sonja_M
ID: 21761805
Hi alb66,

Thank you for answer. i tried differend things based on your suggestion, but no resulotion yet. I am curious about the "CDialog *NewDialog(CWnd *parent)", where should i put that?

Because of i did not do very much with the dll yet i would also recreate it. Do you know a good "How to" to start a dialog-DLL from scratch?

Tanks

Sonja
0
 

Author Comment

by:Sonja_M
ID: 21763311
Hi Again!

I belief my answer was not very usefull. So I will comment again:
1. The dialog is for certainly part of the dll
2. Yes, I think, but do not know, that my exe files is trying to load the dialog from its own resources. I use a Extension DLL so it should find the resource itself, shouldnt it? I found this http://www.codeguru.com/cpp/cpp/cpp_mfc/tutorials/article.php/c4023/ but it also did not help me.
3. In a book I found that I should put the following at the beginning of every exported function that uses MFC Classes, but it could not compile:
AFX_MANAGE_STATE(AfxGetStaticModuleState()));

I will also open a new question for a "How to do a MFC V6 dll with a dialog" for a complete "restart"

greedings
Sonja
0
 

Author Comment

by:Sonja_M
ID: 21781838
My problem is solved. Look at my other question. I probably did something wrong in the Setup.

Sonja
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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
sum67 challenge 35 128
either24  challenge 19 107
source code to scan multiple images 6 113
How to debug Angular JS in Visual Studio 2013 2 295
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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
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.

737 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