Click to See Complete Forum and Search --> : DialogBox Procedure


Ten
June 11th, 2005, 06:52 AM
Hi all,

i'm trying to use a dialogbox and its dialog procedure from a dll.

For example :

HINSTANCE hDll = LoadLibrary("Dialog.dll");
DialogBoxParam(hDll, (LPCTSTR)101,NULL, reinterpret_cast<DLGPROC>(&AppDlgProc), 0);

but i don't want to use 'AppDlgProc' but the procedure of the dialog which is in the dll.

Is it possible ? i know that it's possible by calling a function in the dll that launch the dialog but if i don't have the dll's source code, i can't.

In spy++ there is a property : 'Window Proc', can i use it ?

Thanks.

NoHero
June 11th, 2005, 07:35 AM
Does the DLL export the dialog procedure? If not, it's is nearly impossible... Otherwise - if the DLL exports its dialog procedure - you can obtain the dialog procedure from the DLL using GetProcAddress() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getprocaddress.asp).

Ten
June 11th, 2005, 07:59 AM
No, the Dll does not export the procedure.

So it's definitely impossible :(

SuperKoko
June 11th, 2005, 08:43 AM
It is impossible, because even, if you find the real address of the DialogProc, it is very probable that the dialog box needs some non-null lParam.
And this lParam must be probably a pointer to an object allocated by the program's own allocater, and constructed.
And the construction mechanism is possibly very complex.
But, what you can do, is to use your own DialogProc with the dialog box template of the DLL.
That is the only thing that you can do.

Ten
June 11th, 2005, 09:30 AM
But, what you can do, is to use your own DialogProc with the dialog box template of the DLL.
That is the only thing that you can do.

Ok, i'll do that, Thanks.