[comp.windows.ms.programmer] Creating windows in DLLs

alan@comp.lancs.ac.uk (Alan Phillips) (05/20/91)

Has anyone had any experience of creating a window from inside a DLL? (The bit
that Petzold says 'is difficult...').

What I've tried to do is have a routine in the DLL call RegisterClass and
CreateWindow, and specify a message loop proc also in the DLL.  Windows uses it
OK, but whenever the message loop is called DS points to the _application's_
data segment and not to the DLL's (well, I assume so.  It certainly does not
point to the DLL's data segment).  Doesn't matter whether the instance handle I
give in RegisterClass is the app's or the DLL's. 

Only workround I can find is to have a small stub of code in the import library
that does the RegisterClass for the window, naming another small stub as the
window proc. This second routine simply passes all the arguments to the 'real'
window proc inside the DLL. That gets DS pointing the DLL's data seg as it
should.

Now, am I missing something totally obvious in all this? _Should_ I be able
to do what I want _entirely_ in the DLL code? If anyone can send me any hints
or code fragments I'd be grateful.