CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2000
    Posts
    20

    how to show a Form in an ActiveX DLL?

    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.


  2. #2
    Join Date
    Jan 2000
    Posts
    20

    How to show modeless VB form in In-Process Component?

    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.


  3. #3
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: How to show modeless VB form in In-Process Component?

    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

  4. #4
    Join Date
    Jan 2000
    Posts
    20

    Re: How to show modeless VB form in In-Process Component?

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured