aboutbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cj

    aboutbox

    I had found some code I used in VB2005 to show an about box. The about
    box itself was just a windows form with a button on it. The button had
    no code behind it but it's dialogresult property is set to cancel. The
    help about menu item showed the form like this:

    Private Sub AboutToolStripM enuItem_Click(B yVal sender As
    System.Object, ByVal e As System.EventArg s) Handles
    AboutToolStripM enuItem.Click
    Try
    Dim myAboutDialog As New About
    myAboutDialog.S howDialog()
    If myAboutDialog.D ialogResult =
    System.Windows. Forms.DialogRes ult.OK Then
    myAboutDialog.D ispose()
    End If
    Catch ex As Exception
    System.Console. WriteLine(ex.Me ssage.ToString( ))
    End Try
    End Sub

    I'm playing with VB2008 now and I was dupliating this application in
    2008 and I noticed it has an about box template form to use. I notice
    it's ok button had the code me.close behind it.

    Can anyone tell me which way I should do this in 2008?

    Should I still call the form by saying

    Private Sub AboutToolStripM enuItem_Click(B yVal sender As
    System.Object, ByVal e As System.EventArg s) Handles
    AboutToolStripM enuItem.Click
    Try
    Dim myAboutDialog As New AboutBox1
    myAboutDialog.S howDialog()
    If myAboutDialog.D ialogResult =
    System.Windows. Forms.DialogRes ult.OK Then
    myAboutDialog.D ispose()
    End If
    Catch ex As Exception
    System.Console. WriteLine(ex.Me ssage.ToString( ))
    End Try
    End Sub

    What are the differences in how the about form is being handled?
  • zacks@construction-imaging.com

    #2
    Re: aboutbox

    On May 13, 4:28 pm, cj <c...@nospam.no spamwrote:
    I had found some code I used in VB2005 to show an about box.  The about
    box itself was just a windows form with a button on it.  The button had
    no code behind it but it's dialogresult property is set to cancel.  The
    help about menu item showed the form like this:
    Just how did the About form close if the OK button's Click event
    handler had no code?
    >
         Private Sub AboutToolStripM enuItem_Click(B yVal sender As
    System.Object, ByVal e As System.EventArg s) Handles
    AboutToolStripM enuItem.Click
             Try
                 Dim myAboutDialog As New About
                 myAboutDialog.S howDialog()
                 If myAboutDialog.D ialogResult =
    System.Windows. Forms.DialogRes ult.OK Then
                     myAboutDialog.D ispose()
                 End If
             Catch ex As Exception
                 System.Console. WriteLine(ex.Me ssage.ToString( ))
             End Try
         End Sub
    >
    I'm playing with VB2008 now and I was dupliating this application in
    2008 and I noticed it has an about box template form to use.  I notice
    it's ok button had the code me.close behind it.
    FYI, VS2005 also had an About form template.
    >
    Can anyone tell me which way I should do this in 2008?
    >
    Should I still call the form by saying
    >
         Private Sub AboutToolStripM enuItem_Click(B yVal sender As
    System.Object, ByVal e As System.EventArg s) Handles
    AboutToolStripM enuItem.Click
             Try
                 Dim myAboutDialog As New AboutBox1
                 myAboutDialog.S howDialog()
                 If myAboutDialog.D ialogResult =
    System.Windows. Forms.DialogRes ult.OK Then
                     myAboutDialog.D ispose()
                 End If
             Catch ex As Exception
                 System.Console. WriteLine(ex.Me ssage.ToString( ))
             End Try
         End Sub
    >
    What are the differences in how the about form is being handled?
    IMHO, there is no reason to check the dialogresult from an about form.
    In the code you have, all it does is dispose of the form object if the
    dialog result is OK. Why not just let the garbage collector handle the
    object's disposition? All you really need to do is instantiate the
    form object and show the form, again, IMHO.

    Comment

    • Armin Zingler

      #3
      Re: aboutbox

      <zacks@construc tion-imaging.comschr ieb
      On May 13, 4:28 pm, cj <c...@nospam.no spamwrote:
      I had found some code I used in VB2005 to show an about box. The about
      box itself was just a windows form with a button on it. The button had
      no code behind it but it's dialogresult property is set to cancel. The
      help about menu item showed the form like this:
      Just how did the About form close if the OK button's Click event
      handler had no code?

      ====

      By pushing the button, the Form's dialogresult property is set
      automatically because the button's dialogresult property is set. In
      addition, as soon as the property is set, the Showdialog function
      returns. Therefore it works without writing additional code.



      Armin

      Comment

      Working...