No announcement yet.

Using multiple DLL's

  • Filter
  • Time
  • Show
Clear All
new posts

  • Using multiple DLL's

    Hi all,

    I think I read somewhere that forms are created as Private
    so this might not be possible, but here goes anyway:

    Is it possible to create a form using one DLL/EXE and then
    have another DLL put a button on that form..??? When the
    button was clicked the second DLL would handle the event..

    I am looking at developing a suite of modules which would
    all use a common interface (form), but were able to be
    dynamically loaded and unloaded...



  • #2
    I remember making a program some time ago in PB/DLL that did just that.
    I can't remember if I used DDT or SDK to accomplish that but I do remember
    that it was faulty and I got a few GPF's. You do need to know the
    window handle though.

    Hope that helps.

    [email protected]


    • #3
      Torben --
      do you talk about the same process or different ?

      I don't beleive that there are problems to add/delete child windows in different DLL, which are running in the same process.
      Simple sample:
         #Compile Exe
         #Register None
         #Dim All
         #Include "win32api.INC"
         Declare Sub Cntrl Lib "A.DLL" (hWnd As Long)
         Function PbMain
             Local hDlg As Long
             Dialog New 0, "Test", , , 200, 85, %WS_SYSMENU Or %WS_CAPTION To hDlg
             Control Add Button, hDlg, %IDOK, "&Create", 5, 20, 90, 14
             Control Add Button, hDlg, %IDCANCEL, "&Delete", 5, 40, 90, 14
             Cntrl hDlg: Dialog Show Modal hDlg
         End Function
      and DLL (a.bas)

         #Compile Dll
         #Register None
         #Dim All
         #Include "win32api.INC"
         Global oldproc As Long
         CallBack Function Subclass
            Function = CallWindowProc(oldproc, CbHndl, CbMsg, CbWparam, CbLparam)
            Static n As Long
            Select Case CbMsg
               Case %WM_COMMAND
                  Select Case CbCtl
                     Case %IDOK
                        If n < 5 Then Incr n: Control Add Button, _
                           CbHndl, 100 + n, Format$(n), 105, 15 * n - 10, 90, 15
                     Case %IDCANCEL
                        If n > 0 Then DestroyWindow GetDlgItem(CbHndl, 100 + n): _
                           Decr n
                     Case 101 To 105
                        MsgBox "Button" + Str$(CbCtl - 100)
                  End Select
               Case %WM_DESTROY
                  SetWindowLong CbHndl, %GWL_WNDPROC, OldProc
            End Select
         End Function
         Sub Cntrl (hWnd As Long) Export
            OldProc = SetWindowLong(hWnd, %GWL_WNDPROC, CodePtr(subclass))
         End Sub
      Here form is created by Exe, but DLL has full control.
      By the same way one DLL can create Button, another DLL - to subclass this child window.

      Another question, if parent window is created in one process, childs in another.
      For example, you started Notepad and try to declare it as parent of your DDT (or reverse).

      [This message has been edited by Semen Matusovski (edited July 29, 2000).]


      • #4

        Just what I was looking for.
        Thanks Semen, I owe you a beer...