CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2000
    Location
    Indore (MP) INDIA.
    Posts
    356

    Callback Function ?

    Hello All Experts !!

    I want to register my VB function as a CallBack function in a DLL function.

    viz. :

    Declare Function lineInitialize Lib "tapi32.lib" (byref lphLineApp as Long, byval hInstance as Long, byval lpfnCallback as Long, byref lpszAppName as string, byref lpdwNumDevs as Double) as Long

    Rem: The 3rd Parameter is the Name of CALLBACK Function. Below is how i tried to call it -
    lineInitialize lphLineApp, App.hInstance, MyTapiCallback, App.EXEName, lpdwNumDevs




    This function is defined in "Tapi32.Lib" and is fairely easy to do it in Visual C++ to register a function as
    CALLBACK. but how can i register my one VB function as CALLBACK in the lineInitialze() function.

    Below is the entire code, have a look -



    Dim OriginalWidth as Integer, OriginalHeight as Integer
    Dim lphLineApp as Long, lpdwNumDevs

    private Sub cmdShutdown_Click()
    Unload me
    End Sub

    private Sub Form_Load()
    OriginalWidth = me.Width
    OriginalHeight = me.Height
    me.optCallType(0).Value = true ' 0=Voice, 1=Data, 2=Fax
    lphLineApp = 0
    lpdwNumDevs = 0
    lineInitialize lphLineApp, App.hInstance, MyTapiCallback, App.EXEName, lpdwNumDevs
    End Sub

    private Sub Form_Resize()
    If me.WindowState <> vbMinimized then
    me.Width = OriginalWidth
    me.Height = OriginalHeight
    End If
    End Sub

    public Function MyTapiCallback(byval hDevice as Long, byval dwMessage as Long, byval dwInstance as Long, byval Param1 as Long, byval Param2 as Long, byval Param3 as Long)
    Rem: This should be the CALLBACK function
    MsgBox "Hello Callback Event", vbOKOnly, "TAPI 1.4"
    End Function




    CAN SOMEONE HELP ??

    Thanks in Advance !!





    I am new to Windows Programming. I have Win32 API Programming in my studies at this Semester.
    So If I ask too much or Non-Sense, Please Ignore !

    -Vipul Pathak.
    Indore, (MP) INDIA.
    ICQ# 102045224
    (*Vipul)() ;

  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: Callback Function ?

    AddressOf operator is what you need. You need to declare the callback function in a module first.

    change this line
    lineInitialize lphLineApp, App.hInstance, MyTapiCallback, App.EXEName, lpdwNumDevs

    to lineInitialize lphLineApp, App.hInstance, AddressOf MyTapiCallback, App.EXEName, lpdwNumDevs

    hope this help.

    cksiow
    http://vblib.virtualave.net - share our codes


  3. #3
    Join Date
    Mar 2001
    Location
    Houston, Texas
    Posts
    12

    Re: Callback Function ?

    Just to clarify. Your callback function needs to reside in a standard module (*.bas) extension and not in a form. Then use the AddressOf operator with the 3rd argument when calling the DLL function.

    Good Luck.

    Kenny


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