Click to See Complete Forum and Search --> : How to make a form in a DLL - MDI child to another project


January 10th, 2000, 06:10 AM
I have a set of forms in a ActiveX DLL. This DLL is being referred in another standard EXE project.. in which i have a MDI form to which the forms in the DLL are to be made childs...

How I can achieve this..Please help..

MARY

Chris Eastwood
January 10th, 2000, 06:26 AM
You can't have MDI child forms in an ActiveX DLL - they need to reference an MDI Parent Form in the same project. There are several ways of accomplishing the same effect (most of which are very ropey, SetParent API call for instance).

By far the best way that I've seen is Dan Applemans method described at http://msdn.microsoft.com/library/periodic/period99/vbpj/da0399.htm. It's a complete framework (which means you need to read the whole article to understand it's design) that builds on ActiveX controls kept in separate OCX's.



Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

Clearcode
January 10th, 2000, 06:27 AM
<imho> Very dodgy thing to try.


Declare Function SetParent Lib "user32" Alias "SetParent" (byval hWndChild as Long, byval hWndNewParent as Long) as Long
'..use
Dim lPrevParent as Long

lRet = SetParent(hwndchild, frmMdi.hWnd)



might work, but be sure to set the parent back before closing the window and note that VB won't know about this child window...

You will also need to tell the MDI Child forms in the DLL that they are such, using:


Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (byval hwnd as Long, byval nIndex as Long, byval dwNewLong as Long) as Long
public Const WS_EX_MDICHILD = &H40
'...use
lRet = SetWindowLong(childHwnd,GWL_STYLE, WS_EX_MDICHILD)




but I'd consider spending a day thinking about another way to do this without the DLL windows being MDI children...sounds like a recipe for a GPF :-(.

January 10th, 2000, 06:54 AM
Thanks for the reply...
Can u please help me on modulerizing my application... I have very large forms. I have almost 75 forms in my application .. Now I wish to some how Modulerize the application as a set of ActiveX DLL's and ActiveX EXE's so as to enjoy all the advantages of COM services and to reduce memory footprint of my application..

As I am using lot of third party controls from LEAD and Sheriden i am getting lot of memory problems ... That's why I wish to modulerize my application ...

Please guide me in thinking Three-Tier for my application.... Give me links to any three-tier sample desingns...

Regards
Mary