Click to See Complete Forum and Search --> : how to show a Form in an ActiveX DLL?
noho
February 18th, 2000, 01:34 AM
For example.
There is a class "clsTest" with a method Create in the ActiveX DLL.
public sub Create()
load frmtest
frmtest.show
end sub
these code will always return -2146827882 as HRESULT.
why?
thanks for any suggestion.
noho
February 18th, 2000, 01:53 AM
In article "Displaying Forms from Code Components" of MSDN
Microsoft said "Modeless forms displayed by in-process components cannot function correctly unless they can communicate with the client's message loop.Therefore, in-process components created with Visual Basic can display modeless forms only in client processes that support such communication." and "Microsoft Office 97 or later support the display of modeless forms by in-process components"
Therefore, there must be a method to show modeless Form just like Office 97 dose.
Thanks for any suggestion.
Chris Eastwood
February 18th, 2000, 03:02 AM
I don't understand your problem here - I've been using forms stored in AX DLL's since you could create DLL's with VB.
Try this :
1. Start VB and create a new ActiveX DLL Project
2. Add a form (FORM1) to the project
3. In the Class1 module, paste the following code :
option Explicit
'
private moForm as Form1
'
public Sub Create()
set moForm = new Form1
Load moForm
moForm.Show
End Sub
'
public Sub Kill()
Unload moForm
set moForm = nothing
End Sub
4. On Form1, place a label or someother control so that it says 'From ActiveX DLL'
5. Now add a standard EXE project into VB (called Project2)
6. Goto Project->References and set a reference to Project1
7. Add a command button to Project2's Form and then paste in the following code :
option Explicit
'
private o as Project1.Class1
'
private Sub Command1_Click()
set o = new Project1.Class1
o.Create
End Sub
'
private Sub Form_Unload(Cancel as Integer)
'
o.Kill ' very important !!!!
'
set o = nothing
'
End Sub
now when you click the button, you'll see the form from the AX DLL displayed on your screen.
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
noho
February 18th, 2000, 03:30 AM
Thanks for suggestion at first.
Yes. Application create with VB can display modeless form in In-Process component.
In "Displaying Forms from Code Components" Microsoft said "The following applications support the display of modeless forms by in-process components:
Applications created with Visual Basic 5.0 or later.
Microsoft Office 97 or later.
Applications that have the Visual Basic Technology logo. (That is, that license Visual Basic for Applications version 5.0 or later.)
"
But when I create a application(consumer) with VC,
When I show the form, it return as -2146827882 HRESULT always.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.