Results 1 to 3 of 3

Thread: waiting for dialog form??? (in dll, aye?)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    102
    hi.

    so my module class (dll),
    is calling form1.show,
    which have ok and cancel buttons,
    (the reason i made form for that is i wanted it topmost).
    how do i get which button was pressed?
    (and ofcourse the dll "waits" until button click)

    thanks.
    itay.

  2. #2
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810
    In your DLL form, add the code to the Click event of the buttons:

    Code:
    Private Sub cmdOK_Click()
      'If OK was clicked
      Me.Tag = "OK"
      Me.Hide
    End Sub
    
    Private Sub cmdCancel_Click()
      'If Cancel was clicked
      Me.Tag = "Cancelled"
      Me.Hide
    End Sub
    Then in your DLL class the following function will initiate the form, then return the button text.
    Code:
    Public Function ShowMyForm(ByVal strText As String) As String
      
      '// Form1 is the form with an OK & Cancel button
      Set mForm = New Form1
      With mForm
        .Tag = "Loaded"
        .Label1.Caption = "strText" 'message to display"
        .Show vbModal 'your topmost routine in Form_Load event
        ShowMyForm = .Tag
      End With
      Unload mForm
      Set mForm = Nothing
    End Function
    This function should return "OK" or "Cancelled"

    Hope that this helps
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    102
    thanks.
    very simple indeed.
    my original (wrong) thought was to put public variable
    on the module and update it from the form,
    but the correct solution is the other way around
    -i.

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