Click to See Complete Forum and Search --> : show modeless form from dll
Scott Penner
Jan 30th, 2001, 07:58 PM
Hey,
Is there a way to show a modeless form from an ActiveX dll that stays on top of the main application's form?
I can't pass the main form as a parameter to the wrapper class for displaying the form. And, If I try to pass the form as an object and then use this object to be the parent of the form I'm trying to display, I get an error saying that this object cannot be the parent of the form I'm trying to load...
any ideas?
simonm
Jan 31st, 2001, 06:27 AM
You could try using the 'SetWindowPos' API call to force the window to stay on top.
Scott Penner
Jan 31st, 2001, 12:55 PM
Thanks,
That was a good idea. I tried this with two forms in the same project and it worked great. Unfortunately, when showing this form from the dll I no longer get a form Deactivate event!?
So, this is what I did, but it's not working from the dll.
Private Sub Form_Deactivate()
' Force this form to the top of the window list
' Emulates modeless form operation with main app's form as parent
Debug.Print "frmPartSetup Deactivated"
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE
End Sub
Any more ideas?
MrGTI
Jan 31st, 2001, 03:00 PM
I'm looking for a way to display a form from a DLL and make it vbModal of the main form that it was called from, but i haven't been able to figure it out either.
Scott Penner
Jan 31st, 2001, 08:58 PM
I had this working...
If you show the form modally, it should automatically be modal to the main application because the dll is in the same process as the calling form.
That's how I had my app running, but I now need to show the form while allowing the user to access the underlying form as well.
simonm
Feb 1st, 2001, 02:48 AM
Why did you put the API call in the form_deactivate event?
It seems like you are using it to 'Rescue' your form when it gets deactivated but why not call immediately after the form.Show method?
Scott Penner
Feb 1st, 2001, 12:55 PM
Well,
I was passing a class into the form at startup, so I made a Display method to receive the class and show the form. It didn't work to call the SetWindowPos in this method, so I tried other things, albeit some squirrelly things.
Anyway, to make a long story short, I simplified the way I displayed the form and everything works.
Thanks for the help,
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.