CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: ACtiveX DLL

  1. #1
    Join Date
    Jul 1999
    Posts
    20

    ACtiveX DLL

    Hi

    I have created an ActiveX DLL in VB6. In the test environment (ie. if the ActiveX Dll project is loaded) then this works properly,
    but if i create the DLL and use the reference of this DLL in some other project then the EVENTS ARE NOT INVOKED.

    Can anybody figgure out why?

    thanks
    Praba



  2. #2
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: ACtiveX DLL

    Are you adding the reference to the typelib of the dll from "Projects->References"?

    Does the Object browser show the "Events" that are supposed to exists for your objects of the dll?

    If you are dynamically creating an instance of the object, then are you declaring it with "With Events" identifier?

    RK

    Life is a comedy for those who think and a tragedy for those who feel

  3. #3
    Join Date
    Jul 1999
    Posts
    20

    Re: ACtiveX DLL

    Thanks for responding

    All the 3 above mentioned points are True,
    but the same result

    rgds
    Praba


  4. #4
    Join Date
    Aug 1999
    Posts
    11

    Re: ACtiveX DLL

    Could u Please post a small code snipet as to what u r doing maybe then it might be clear what or where the prob is.

    Thanks


  5. #5
    Join Date
    Jul 1999
    Posts
    20

    Re: ACtiveX DLL

    Hi

    Here is the program snippet

    The active X dll Contains
    1 form (has 1 ms flex gird, i datacontrol, 2 command buttons)
    1 bas file
    1 class module

    To call this Dll
    Create one more vbp with a form (one text box and a commnd button), Snippet of this also present.


    To Test this
    Create a VBP with the first form, bas file and the class module
    Add a second VBP with the senond form.
    Make the second 2nd VBP as the start up project.
    Run it. click the button, When u double click in the grid the name of author should appear in the text box.

    Now create a DLL (eg. popHelp.dll)
    Create a new project with the 2nd form. Run it.

    I have used biblio.mdb. It should be in ur hard disk, Copy it as biblio97.mdb

    Sorry i haven't put any in line comments.

    If u need the project (zip file) send me a mail directly


    Regards
    Praba



    ''' The form
    VERSION 5.00
    Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
    Begin VB.Form HelpGrid
    Caption = "Dialog Box"
    ClientHeight = 4425
    ClientLeft = 60
    ClientTop = 345
    ClientWidth = 4680
    LinkTopic = "Form2"
    ScaleHeight = 4425
    ScaleWidth = 4680
    StartUpPosition = 3 'Windows Default
    Begin VB.Data datHelp
    Caption = "Data1"
    Connect = "Access"
    DatabaseName = ""
    DefaultCursorType= 0 'DefaultCursor
    DefaultType = 2 'UseODBC
    Exclusive = 0 'False
    Height = 375
    Left = 960
    Options = 0
    ReadOnly = 0 'False
    RecordsetType = 2 'Snapshot
    RecordSource = ""
    Top = 360
    Visible = 0 'False
    Width = 3015
    End
    Begin MSFlexGridLib.MSFlexGrid grdHelp
    Bindings = "PopHelp_HelpGrid.frx":0000
    Height = 2655
    Left = 480
    TabIndex = 2
    Top = 720
    Width = 3615
    _ExtentX = 6376
    _ExtentY = 4683
    _Version = 393216
    FixedCols = 0
    BackColorFixed = -2147483638
    BackColorBkg = 16777215
    End
    Begin VB.CommandButton cmdCancel
    Caption = "Cancel"
    Height = 375
    Left = 3360
    TabIndex = 1
    Top = 3840
    Width = 1095
    End
    Begin VB.CommandButton cmdOk
    Caption = "OK"
    Height = 375
    Left = 2160
    TabIndex = 0
    Top = 3840
    Width = 1095
    End
    End
    Attribute VB_Name = "HelpGrid"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Option Explicit
    Event dblClick(rowData() As String) 'new

    Private Sub cmdCancel_Click()
    Me.Visible = False
    End Sub

    Private Sub cmdOk_Click()
    grdHelp_DblClick
    End Sub

    Private Sub Form_Load()
    'new
    SetGridBoundary
    End Sub

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If UnloadMode = vbFormControlMenu Then
    Cancel = True
    Me.Visible = False
    End If
    End Sub


    Private Sub SetGridBoundary()
    'new
    With grdHelp
    .Left = 0
    .Width = Width - 100
    .Top = 0
    .Height = Height - 1000
    End With

    cmdOk.Top = Me.Height - 900
    cmdCancel.Top = Me.Height - 900

    End Sub

    Private Sub Form_Resize()
    'new
    SetGridBoundary
    End Sub

    Private Sub grdHelp_DblClick()
    'new
    Dim i As Integer
    Dim j As Integer
    j = grdHelp.Cols - 1
    For i = 1 To j
    ReDim garrCurrentRow(j) As String
    garrCurrentRow(i) = grdHelp.TextMatrix(grdHelp.RowSel, j)
    Next i
    RaiseEvent dblClick(garrCurrentRow())
    Me.Visible = False

    'Unload Me
    End Sub

    Private Sub grdHelp_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyEscape Then cmdCancel.Value = True
    End Sub


    ''' Bas file
    Attribute VB_Name = "Module1"
    Option Explicit
    Public garrCurrentRow() As String
    Public Sub main()
    Debug.Print " "
    End Sub

    ''''Class Module
    VERSION 1.0 CLASS
    BEGIN
    MultiUse = -1 'True
    END
    Attribute VB_Name = "ContextHelp"
    Attribute VB_GlobalNameSpace = True
    Attribute VB_Creatable = True
    Attribute VB_PredeclaredId = False
    Attribute VB_Exposed = True
    'new
    Option Explicit

    Private WithEvents mHelp As HelpGrid
    Attribute mHelp.VB_VarHelpID = -1
    Event dblClick(rowData() As String)

    Public Property Get RecordSource() As Variant
    RecordSource = mHelp!datHelp.RecordSource
    End Property

    Public Property Let RecordSource(ByVal vNewValue As Variant)
    mHelp!datHelp.RecordSource = vNewValue
    mHelp!datHelp.Refresh
    mHelp.grdHelp.Refresh
    End Property

    Public Property Get FixedCols() As Variant
    FixedCols = mHelp!grdHelp.FixedCols
    End Property

    Public Property Let FixedCols(ByVal vNewValue As Variant)
    mHelp!grdHelp.FixedCols = vNewValue
    End Property

    Public Property Get DatabaseName() As Variant
    DatabaseName = mHelp!datHelp.DatabaseName
    End Property

    Public Property Let DatabaseName(ByVal vNewValue As Variant)
    mHelp!datHelp.DatabaseName = vNewValue
    End Property

    Public Property Get FormCaption() As Variant
    FormCaption = mHelp.Caption
    End Property

    Public Property Let FormCaption(ByVal vNewValue As Variant)
    mHelp.Caption = vNewValue
    End Property

    Public Property Get Cols() As Variant
    ' 1 based
    Cols = mHelp!grdHelp.Cols
    End Property

    Private Sub Class_Initialize()
    Set mHelp = New HelpGrid
    End Sub

    Private Sub Class_Terminate()
    Unload mHelp
    Set mHelp = Nothing
    End Sub

    Private Sub mhelp_dblClick(rowData() As String)
    Dim i As Integer
    Dim j As Integer
    j = mHelp.grdHelp.Cols - 1
    ReDim garrCurrentRow(j) As String
    For i = 0 To j
    garrCurrentRow(i) = mHelp!grdHelp.TextMatrix(mHelp!grdHelp.RowSel, i)
    Next i
    RaiseEvent dblClick(garrCurrentRow())
    End Sub

    Public Sub ShowHelp()
    mHelp.Show vbModal
    End Sub


    ''' Form to call the Dll or the Help object

    VERSION 5.00
    Begin VB.Form Form2
    Caption = "Form2"
    ClientHeight = 3195
    ClientLeft = 60
    ClientTop = 345
    ClientWidth = 4680
    LinkTopic = "Form2"
    ScaleHeight = 3195
    ScaleWidth = 4680
    StartUpPosition = 3 'Windows Default
    Begin VB.CommandButton Command1
    Caption = "show Help"
    Height = 375
    Left = 1200
    TabIndex = 1
    Top = 2040
    Width = 2295
    End
    Begin VB.TextBox Text1
    Height = 495
    Left = 1080
    TabIndex = 0
    Text = "Text1"
    Top = 720
    Width = 2895
    End
    End
    Attribute VB_Name = "Form2"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Option Explicit
    Private WithEvents mHlp As contexthelp
    Attribute mHlp.VB_VarHelpID = -1
    Private Sub Command1_Click()
    If mHlp Is Nothing Then Set mHlp = New contexthelp
    mHlp.DatabaseName = "c:\Progra~1\DevStu~1\vb\biblio97.mdb"
    mHlp.RecordSource = "select * from authors "
    mHlp.FixedCols = 1
    mHlp.FormCaption = "Help"
    mHlp.ShowHelp
    Set mHlp = Nothing
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    If Not mHlp Is Nothing Then Set mHlp = Nothing
    End Sub

    Private Sub mHlp_dblClick(rowData() As String)
    Text1 = rowData(1)
    End Sub



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