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
Solved

resources in extension dll's

Posted on 2000-04-12
12
143 Views
Last Modified: 2013-11-20
Here is my problem.  I have an extension DLL that has some dialog boxes inside of it.  I want to use those dialog boxes inside of an exe program how would I do that?  Is there a way that the exe can use the DLL's dialogs just like it was its own?
0
Comment
Question by:simongod
  • 7
  • 5
12 Comments
 
LVL 5

Expert Comment

by:vachooho
ID: 2708769
-copy your dialog's h file into the exe's project
- add AFX_EXT_CLASS after class declaration
class AFX_EXT_CLASS CMyDialog: public CDialog...
{
}
- instantiate as usual
CMyDialog dlg(OWNERWINDOW_HERE)
dlg.DoModal();
- before constructing CMyDialog above
use AfxSetResourceHandle(YOUR_DLL_HANDLE_HERE) ;
after calling DoModal() of dialog use AfxSetResourceHandle(BACK_TO_PREVIOUS_HANDLE);

- do not forget to link exe with Dialog DLL's Obj module.

Hope this helps

 
0
 
LVL 5

Expert Comment

by:vachooho
ID: 2708788
ups

forget to say
that your Dialogs DLL should define dialogs as following

class __declspec(dllexport) CMyDialog : public ...
{
}

I use the following #defines for exported classes

#ifdef __DIALOG_IMPLEMENTATION_
#define _DIALOG_EXT_CLASS_ __declspec(dllexport)
#else
#define _DIALOG_EXT_CLASS __declspec(dllimport)
#endif

class _DIALOG_EXT_CLASS_ CmyDialog:public CDIalog
{
}

I define __DIALOG_IMPLEMENTATION_ in stdafx.h of the dll module and use the same dialog class header for both projects (dll and exe).

0
 
LVL 2

Author Comment

by:simongod
ID: 2708847
i kind of understand what you are saying.  Let me show you the example that I am using and maybe you can help me to understand it.  Below is the link to that page at Code Guru.

http://codeguru.developer.com/dll/dialog_in_extdll.shtml
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 2

Author Comment

by:simongod
ID: 2708861
what is OWNERWINDOW_HERE ?
0
 
LVL 5

Expert Comment

by:vachooho
ID: 2708915
CDialog's constructor need the owner window pointer - OWNERWINDOW_HERE is the CWnd * to dialog's owner or NULL if dialog does not have owner window.


I looked over the URL you posted,
it is implemented exactly the way I told you about.

The main trick is to set resource handle so your exe will be able to find dialog resource in DLL.

What kind of help you need?
Article explains everything very clear.
just create two files  EXTDLLState.h and .cpp
#include them and change a call to DoModal();
that's it

If you have questions - post them together with source files (at least dll main module, dialog class, and exe's snippet with call to DLL's dialog)

0
 
LVL 2

Author Comment

by:simongod
ID: 2709007
another problem when I click on the close button (little x in the top right corner of the dialog box) the dialog box doesn't close.  How can I get rid of the dialog box?  The way that I am using it if I enter info in some edit controls in the dialog can the exe use that info?  How would that be done.
0
 
LVL 5

Expert Comment

by:vachooho
ID: 2709021
I need sources to answer that question

To pass entered text into main exe you can use member variables and DDX routines.

save entered  text into member variables in Dilaog

then in exe

Dialog dlg;
dlg.DoModal();
CString strEnteredText = dlg.m_strText1;


in dialog you need DDX_xxxx() Data exchange routines. Clas Wizard can do most work for you.
0
 
LVL 2

Author Comment

by:simongod
ID: 2709070
you need to see my source to figure out why I cannot close the DLL's dialog box?
0
 
LVL 2

Author Comment

by:simongod
ID: 2709073
let me have your email and I will send it to you.
0
 
LVL 5

Accepted Solution

by:
vachooho earned 200 total points
ID: 2709090
vachikh@hpl.com
0
 
LVL 2

Author Comment

by:simongod
ID: 2709143
the file is about 1.5 meg I hope that you can handle that.
0
 
LVL 2

Author Comment

by:simongod
ID: 2717791
Thanks for the help everything works and i have improved upon the concepts to fir my needs
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
Strange date stored 22 151
Question regarding Copy/Paste 16 96
substring method in java 1 129
bigDiff challenge 17 123
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

809 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