15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Invoking a Dialog defined in a DLL

Bertrand Le Breton -- bertrand.lebreton@issy.cnet.fr
Friday, September 27, 1996

Hi, 

I'm trying to get over a little problem witch consist in calling a
DialogBox in a DLL.
My Dll exports a unique function named Traduire form where a Dialog Box
defined in the Dll is called ( DoModal() ). The problem is : when i call
this function form another application, the function Traduire runs OK but
not its call to the dialog Box.


Environment: MSVC 4.2/NT 4.0

  _/_/_/_/   FRANCE TELECOM
 _/_/_/_/    CENTRE NATIONAL D'ETUDES DES TELECOMMUNICATIONS
_/_/_/_/                                                      

Bertrand Le Breton
C N E T - Issy
PAA/TSA/TLR                |  e-mail :  lebreton@issy.cnet.fr  |
38, Rue du General Leclerc |  Telephone : + 33 1 45 29 63 69   |
92131 ISSY LES MOULINEAUX  |  Telecopie : + 33 1 45 29 40 36   |
FRANCE




alberto.gimenez@vlc.servicom.es
Sunday, September 29, 1996

[Mini-digest: 6 responses]

Use this technique in the "Traduire" function :

	// Get the actual resource handle.
	HINSTANCE OldInstance =3D AfxGetResourceHandle();

	// Set the resource handle to the DLL.
	AfxSetResourceHandle(DLLExtensionModule.hModule);

	// Create the dialog.
	...

	// Restore the resource handle.
	AfxSetResourceHandle(OldInstance);

A greeting.

Alberto Gim=E9nez G=F3mez
Canals - Valencia - Espa=F1a (Spain)
alberto.gimenez@vlc.servicom.es

----------
> De: Bertrand Le Breton 
> A: Faq MFC 
> Asunto: Invoking a Dialog defined in a DLL
> Fecha: viernes 27 de septiembre de 1996 9:18
>=20
> Hi,=20
>=20
> I'm trying to get over a little problem witch consist in calling a
> DialogBox in a DLL.
> My Dll exports a unique function named Traduire form where a Dialog Box
> defined in the Dll is called ( DoModal() ). The problem is : when i cal=
l
> this function form another application, the function Traduire runs OK b=
ut
> not its call to the dialog Box.
>=20
>=20

-----From: David.Lowndes@bj.co.uk

Bertrand,

Try using AFX_MANAGE_STATE at the start of your exported function.

Dave Lowndes
-----From: Frank Froelich 

Did you export your Dialog procedure?

Frank


-----From: Mario Contestabile

Did you try
 AFX_MANAGE_STATE(AfxGetModuleState());

mcontest@universal.com

-----From: Gonzalo Isaza 

Most likely your program is trying to load the resources for the dialog
from the executable and not from the DLL. If you are creating a regular
DLL, dynamically linked to MFC you need to include the following line in
the function loading resources:

AFX_MANAGE_STATE(AfxGetStaticModuleState));

See the documentation for AfxGetStaticModuleState.

Gonzalo

I speak for myself.  I am not speaking for Microsoft.

-----From: "Sanjay Chouksey" 

Hi Bertrand,

The DoModal() function looks for the dialog resource in the DLL.
Hence it requires the instance handle of the DLL( to get to the resource).
Now when you invoke the function calling DoModal() from another
application, the instance handle points to that application. Hence
the code in DoModal() fails to find the resource. You need to store
the instance handle of the DLL in it's LibMain, and before invoking
DoModal,
set the instance handle to the DLL by calling AfxSetReourceHandle()
 (Don't forget to restore the applications instance after the dialog has
exited)

_______________
Sanjay Chouksey
Software Engineer, MediaWay, Inc.
3080, Olcott Street, Suite 220C
Santa Clara, CA, 95054.
Tel: (408) 748-7405 (Off)
Res: (408) 243-8635 (Res)





| Вернуться в корень Архива |