Pass form from a standard exe to an activex dll

Posted on 2010-03-31
Medium Priority
Last Modified: 2012-05-09

Quite Strange. I am tryting to pass the form from a standard exe to an activex dll.

The reason I am doing this to take the handle of the form being passed to apply a skin to the form and all the controls on it in one go. I have many other vb 6.0  projects so i am trying to create a generic dll so as not to repeat the same code everywhere.

the dll code is written inside a class called 'CommonAPIs'

In the form I create a reference of the above dll and in form load, I call the loadskin method as below:

Private Sub Form_Load()

Dim objAvataar As AvataarCommonAPI.CommonAPIs

Set objAvataar = New AvataarCommonAPI.CommonAPIs
objAvataar.Loadskin Me

end sub

If I add both the standard exe and the dll project within the same group, it works but if I create a dll and reference it separately, nothing happens (the skin is not applied which it should).

What is the mistake I am doing ??

Shall appreciate a quick reply !!
Public Function Loadskin(frm As Object)

    On Error GoTo Err_LoadSkin

    Dim frmskin As VB.Form

    If TypeOf frm Is VB.Form Then
        Set frmskin = frm
        frmmain.SkinFramework.Loadskin SKINPATH + "\" + SKINNAME, ""
        frmmain.SkinFramework.ApplyWindow frmskin.hwnd
    End If
    Exit Function
     Err.Raise Err.Number, "LoadSkin", Err.Description
End Function

Open in new window

Question by:acpt
LVL 29

Accepted Solution

nffvrxqgrcfqvvc earned 400 total points
ID: 29215353
I don't see a problem with passing a form object to an activex component (from a DLL reference) .
frmmain.SkinFramework.Loadskin SKINPATH & "\" & SKINNAME, ""
Can you see the hWnd and the Caption of the form you pass into the method?

Public sub LoadskinFromObject(frm As Object)
    Dim frmskin As VB.Form
    If TypeOf frm Is VB.Form Then
        Set frmskin = frm
        MsgBox frmskin.hWnd
        MsgBox frmskin.Caption
    End If
End Function

Open in new window


Author Comment

ID: 29312760

Both the form handle and form caption is retained in the LoadSkin subroutine.
That is not the problem...

If i compare frmskin.hwnd=frm.hwnd I get true..

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

594 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question