Results 1 to 28 of 28

Thread: Minimize Form1 With MainForm Code [SOLVED]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Resolved Minimize Form1 With MainForm Code [SOLVED]

    This does not work...

    VB Code:
    1. Private MainFormResize(blah blah)
    2. If Me.WindowState.Minimized = True Then
    3.     Form1.WindowState.Minimized = True
    4. Else
    5.     Form2.WindowState.Normal = True
    6. End If
    7. End Sub
    All I want to do is minimize a modeless (toolbox window) form when I minimize the MainForm.

    How do I minimize a 2nd visible form from the Main form??

    Thanks
    Last edited by epixelman; Mar 17th, 2005 at 05:04 PM.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code

    Quote Originally Posted by epixelman
    This does not work...

    VB Code:
    1. Private MainFormResize(blah blah)
    2. If Me.WindowState.Minimized = True Then
    3.     Form1.WindowState.Minimized = True
    4. Else
    5.     Form2.WindowState.Normal = True
    6. End If
    7. End Sub
    All I want to do is minimize a modeless (toolbox window) form when I minimize the MainForm.

    How do I minimize a 2nd visible form from the Main form??


    Thanks
    you just arent setting the properties right... check the other post you made in here.. i answered it there

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code

    This is a different question on minimizing a form, not displaying.

    The other post is a mistake... duplicate

    Thanks

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code

    yeah but what I am saying is that you are not using those properties right..

    Me.WindowState.Minimized will not evaluate to a boolean like you are trying.. I can tell you are coding without option strict on. I recommend putting it on.
    VB Code:
    1. Private MainFormResize(blah blah)
    2.         If Me.WindowState = FormWindowState.Minimized Then
    3.             Form1.WindowState = FormWindowState.Minimized
    4.         Else
    5.             Form2.WindowState = FormWindowState.Normal
    6.         End If
    7. End Sub

    see what i mean

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code

    I'm just getting into this .NET...

    Is Option Strict like Option Explicit??

    And where does it go?

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code

    Quote Originally Posted by kleinma
    VB Code:
    1. Private MainFormResize(blah blah)
    2.         If Me.WindowState = FormWindowState.Minimized Then
    3.             Form1.WindowState = FormWindowState.Minimized
    4.         Else
    5.             Form2.WindowState = FormWindowState.Normal
    6.         End If
    7. End Sub
    Does this minimize both forms when I minimize the Main Form??

    I am getting an error on line... (ref to non-standard member requires obj ref)

    Private MainFormResize(blah blah)
    If Me.WindowState = FormWindowState.Minimized Then
    ------>> Form1.WindowState = FormWindowState.Minimized
    Else
    ------>> Form1.WindowState = FormWindowState.Normal
    End If
    End Sub

    I'm only trying to minimize Form1 (toolbox) when I minimize MainForm (that is the name)

    Thanks

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code

    Quote Originally Posted by epixelman
    I'm just getting into this .NET...

    Is Option Strict like Option Explicit??

    And where does it go?
    yes and no..

    they work together really, but you can have one on and one off vice versa..

    your best bet is to put option strict and option explicit both on. This will ensure your code is as clean and correct as possible from a syntax point of view.

    Option Strict requires explicit conversions of datatypes..

    for example

    Dim b As Boolean = "true"
    this is setting a string datatype to a boolean (it converts it in the background), but if you had option strict on.. it would not let you do this.. you would have to do
    Dim b As Boolean = true

    maybe thats a bad example.. but i hope you get the idea..

    here is a better example
    VB Code:
    1. Dim i As Integer = 100
    2. MessageBox.Show(i)

    with option strict, you need to make the integer a string.. because technically, the messagebox.show method needs a string, not an integer
    VB Code:
    1. Dim i As Integer = 100
    2. MessageBox.Show(i.ToString)

    you can turn on option strict and explict in the options so by default they are always on.. and you always have the option to specify them on or off in a specific class/form/module by coding it at the very top like option explicit in VB6

    hope that helps...

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code

    well where are Form1 and Form2 declared? what form are you calling the code from?

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code

    It all comes from the MainForm...

    VB Code:
    1. Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
    2.     Dim fForm1 As New Form1()
    3.     fForm1.Show()
    4. End Sub
    5.        
    6. Private Sub MainFormResize(sender As System.Object, e As System.EventArgs)
    7. If Me.WindowState = FormWindowState.Minimized Then
    8.     Form1.WindowState = FormWindowState.Minimized
    9. Else
    10.     Form1.WindowState = FormWindowState.Normal
    11. End If
    12. End Sub

    I am using SharpDevelop for my IDE. I do not have an option to set the "Option Explicit" and "Option Strict" on.

    Where in raw code does it go?
    Above the namespace section?

    Thanks

  10. #10
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code

    yes at the very top of everything... same place you would put option explicit

    Option Explicit On
    Option Strict On

    your problem is that the scope of your form variables are limited to the subs you create them in... move the declarations for the forms to the module level...
    VB Code:
    1. Private fForm1 as Form1
    2.  
    3. Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
    4.     fForm1 = New Form1()
    5.     fForm1.Show()
    6. End Sub
    7.  
    8. Private Sub MainFormResize(sender As System.Object, e As System.EventArgs)
    9. If Me.WindowState = FormWindowState.Minimized Then
    10.     Form1.WindowState = FormWindowState.Minimized
    11. Else
    12.     Form1.WindowState = FormWindowState.Normal
    13. End If
    14. End Sub

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code

    Module Level???

    Where and how would I call them?

  12. #12
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code

    i did the code for you..

    basically what i mean is if you do this:
    VB Code:
    1. Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
    2.     Dim fForm1 As New Form1()
    3.     fForm1.Show()
    4. End Sub
    only this sub routine can see or access fForm1

    if you put outside a routine (in the general declarations section) you can access it anywhere as long as there is a new instance created (which I do in the button click code i posted)

    to put something at the entire form level, you declare it at the top, below the Class defenition, and below and inheritence or implements statements...

    VB Code:
    1. Public Class MyForm
    2. Inherits System.WIndows.Forms.Form
    3. Private fForm1 as Form1
    4.  
    5. Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
    6.     fForm1 = New Form1()
    7.     fForm1.Show()
    8. End Sub
    9.  
    10. Private Sub MainFormResize(sender As System.Object, e As System.EventArgs)
    11. If Me.WindowState = FormWindowState.Minimized Then
    12.     Form1.WindowState = FormWindowState.Minimized
    13. Else
    14.     Form1.WindowState = FormWindowState.Normal
    15. End If
    16. End Sub

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code

    Here is my entire code...

    VB Code:
    1. Option Explicit On
    2. Option Strict On
    3.  
    4. Imports System
    5. Imports System.Drawing
    6. Imports System.Windows.Forms
    7.  
    8. Namespace DisplayForms
    9.    
    10.     Public Class MainForm
    11.         Inherits System.Windows.Forms.Form
    12.         Private button1 As System.Windows.Forms.Button
    13.        
    14.         Public Shared Sub Main
    15.             Dim fMainForm As New MainForm
    16.             fMainForm.ShowDialog()
    17.         End Sub
    18.        
    19.         Public Sub New()
    20.             MyBase.New
    21.             ' The Me.InitializeComponent call is required for Windows Forms designer support.
    22.             Me.InitializeComponent
    23.             ' Add constructor code after InitializeComponents
    24.         End Sub
    25.        
    26.         #Region " Windows Forms Designer generated code "
    27.         ' This method is required for Windows Forms designer support.
    28.         ' Do not change the method contents inside the source code editor. The Forms designer might
    29.         ' not be able to load this method if it was changed manually.
    30.         Private Sub InitializeComponent()
    31.             Me.button1 = New System.Windows.Forms.Button
    32.             Me.SuspendLayout
    33.             '
    34.             'button1
    35.             '
    36.             Me.button1.Location = New System.Drawing.Point(40, 28)
    37.             Me.button1.Name = "button1"
    38.             Me.button1.Size = New System.Drawing.Size(120, 40)
    39.             Me.button1.TabIndex = 0
    40.             Me.button1.Text = "button1"
    41.             AddHandler Me.button1.Click, AddressOf Me.Button1Click
    42.             '
    43.             'MainForm
    44.             '
    45.             Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    46.             Me.ClientSize = New System.Drawing.Size(560, 396)
    47.             Me.Controls.Add(Me.button1)
    48.             Me.Name = "MainForm"
    49.             Me.Text = "MainForm"
    50.             AddHandler Resize, AddressOf Me.MainFormResize
    51.             Me.ResumeLayout(false)
    52.         End Sub
    53.         #End Region
    54.        
    55.         Private fForm1 as Form1
    56.  
    57.         Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
    58.             fForm1 = New Form1()
    59.             fForm1.Show()
    60.         End Sub
    61.    
    62.         Private Sub MainFormResize(sender As System.Object, e As System.EventArgs)
    63.             If Me.WindowState = FormWindowState.Minimized Then
    64.                 Form1.WindowState = FormWindowState.Minimized
    65.             Else
    66.                 Form1.WindowState = FormWindowState.Normal
    67.             End If
    68.         End Sub
    69.        
    70.     End Class
    71.    
    72. End Namespace

  14. #14
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code

    move the

    Private fForm1 As Form1 to below Inherits System.Windows.Forms.Form and you should be ok

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code

    This is what I have...

    VB Code:
    1. Public Class MainForm
    2.             Inherits System.Windows.Forms.Form
    3.             Private fForm1 As Form1
    4.         End Class
    5.        
    6.         Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
    7.             fForm1 = New Form1()
    8.             fForm1.Show()
    9.         End Sub
    10.    
    11.         Private Sub MainFormResize(sender As System.Object, e As System.EventArgs)
    12.             If Me.WindowState = FormWindowState.Minimized Then
    13.                  Form1.WindowState = FormWindowState.Minimized
    14.             Else
    15.                  Form1.WindowState = FormWindowState.Normal
    16.             End If
    17.         End Sub

    I get error....

    "fForm1 is not declared"

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code

    I moved the "Private fForm As Form" to the top. I had two MainForm Classes.

    Now I get the error... for lines...

    ---> Form1.WindowState = FormWindowState.Minimized
    ---> Form1.WindowState = FormWindowState.Normal

    ERROR..

    Ref to non-shared member requires an object ref.

  17. #17
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code

    man I dont know what you are doing.. but it sure is wacky...

    you have a public sub main in your MainForm class.. that declares a variable of type MainForm....
    VB Code:
    1. Option Explicit On
    2. Option Strict On
    3.  
    4. Imports System
    5. Imports System.Drawing
    6. Imports System.Windows.Forms
    7.  
    8. Namespace DisplayForms
    9.     Public Class MainForm
    10.         Inherits System.Windows.Forms.Form
    11.         Private button1 As System.Windows.Forms.Button
    12.         Private fForm1 As Form1
    13.  
    14.         Public Sub New()
    15.             MyBase.New()
    16.             ' The Me.InitializeComponent call is required for Windows Forms designer support.
    17.             Me.InitializeComponent()
    18.             ' Add constructor code after InitializeComponents
    19.         End Sub
    20. #Region " Windows Forms Designer generated code "
    21.         ' This method is required for Windows Forms designer support.
    22.         ' Do not change the method contents inside the source code editor. The Forms designer might
    23.         ' not be able to load this method if it was changed manually.
    24.         Private Sub InitializeComponent()
    25.             Me.button1 = New System.Windows.Forms.Button
    26.             Me.SuspendLayout()
    27.             '
    28.             'button1
    29.             '
    30.             Me.button1.Location = New System.Drawing.Point(40, 28)
    31.             Me.button1.Name = "button1"
    32.             Me.button1.Size = New System.Drawing.Size(120, 40)
    33.             Me.button1.TabIndex = 0
    34.             Me.button1.Text = "button1"
    35.             AddHandler Me.button1.Click, AddressOf Me.Button1Click
    36.             '
    37.             'MainForm
    38.             '
    39.             Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    40.             Me.ClientSize = New System.Drawing.Size(560, 396)
    41.             Me.Controls.Add(Me.button1)
    42.             Me.Name = "MainForm"
    43.             Me.Text = "MainForm"
    44.             AddHandler Resize, AddressOf Me.MainFormResize
    45.             Me.ResumeLayout(False)
    46.         End Sub
    47. #End Region
    48.  
    49.         Private Sub Button1Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    50.             fForm1 = New Form1
    51.             fForm1.Show()
    52.         End Sub
    53.         Private Sub MainFormResize(ByVal sender As System.Object, ByVal e As System.EventArgs)
    54.             If Me.WindowState = FormWindowState.Minimized Then
    55.                 fForm1.WindowState = FormWindowState.Minimized
    56.             Else
    57.                 fForm1.WindowState = FormWindowState.Normal
    58.             End If
    59.         End Sub
    60.     End Class
    61. End Namespace
    62. Module modMain
    63.     Public Sub Main()
    64.         Application.Run(New DisplayForms.MainForm)
    65.     End Sub
    66. End Module

  18. #18

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code

    This is what I have...
    The recent post I submitted code that was missing a section... Try this.

    VB Code:
    1. Option Explicit On
    2. Option Strict On
    3.  
    4. Imports System
    5. Imports System.Drawing
    6. Imports System.Windows.Forms
    7.  
    8. Namespace DisplayForms
    9.    
    10. Public Class MainForm
    11.     Inherits System.Windows.Forms.Form
    12.     Private button1 As System.Windows.Forms.Button
    13.     Private fForm1 As Form1
    14.        
    15.     Public Shared Sub Main
    16.         Dim fMainForm As New MainForm
    17.         fMainForm.ShowDialog()
    18.             End Sub
    19.        
    20.     Public Sub New()
    21.         MyBase.New
    22.         ' The Me.InitializeComponent call is required for Windows Forms designer support.
    23.         Me.InitializeComponent
    24.         ' Add constructor code after InitializeComponents
    25.     End Sub
    26.        
    27.     #Region " Windows Forms Designer generated code "
    28.     ' This method is required for Windows Forms designer support.
    29.     ' Do not change the method contents inside the source code editor. The Forms designer might
    30.     ' not be able to load this method if it was changed manually.
    31.     Private Sub InitializeComponent()
    32.         Me.button1 = New System.Windows.Forms.Button
    33.         Me.SuspendLayout
    34.         '
    35.         'button1
    36.         '
    37.         Me.button1.Location = New System.Drawing.Point(40, 28)
    38.         Me.button1.Name = "button1"
    39.         Me.button1.Size = New System.Drawing.Size(120, 40)
    40.         Me.button1.TabIndex = 0
    41.         Me.button1.Text = "button1"
    42.         AddHandler Me.button1.Click, AddressOf Me.Button1Click
    43.         '
    44.         'MainForm
    45.         '
    46.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    47.         Me.ClientSize = New System.Drawing.Size(560, 396)
    48.         Me.Controls.Add(Me.button1)
    49.         Me.Name = "MainForm"
    50.         Me.Text = "MainForm"
    51.         AddHandler Resize, AddressOf Me.MainFormResize
    52.         Me.ResumeLayout(false)
    53.     End Sub
    54.     #End Region
    55.        
    56.     Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
    57.         fForm1 = New Form1()
    58.         fForm1.Show()
    59.     End Sub
    60.    
    61.     Private Sub MainFormResize(sender As System.Object, e As System.EventArgs)
    62.     If Me.WindowState = FormWindowState.Minimized Then
    63.         Form1.WindowState = FormWindowState.Minimized
    64.     Else
    65.         Form1.WindowState = FormWindowState.Normal
    66.     End If
    67.     End Sub
    68.        
    69. End Class
    70.    
    71. End Namespace

  19. #19
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code

    come on man.. i think you can take the code i provided you, and work it into yours.. no?

  20. #20

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Resolved Re: Minimize Form1 With MainForm Code

    I got it!!!

    The two lines...

    Form1.WindowState = FormWindowState.Minimized
    Form1.WindowState = FormWindowState.Normal

    has to have fForm1 instead of just Form1

    Thanks
    Frank

  21. #21
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code

    Quote Originally Posted by epixelman
    I got it!!!

    The two lines...

    Form1.WindowState = FormWindowState.Minimized
    Form1.WindowState = FormWindowState.Normal

    has to have fForm1 instead of just Form1

    Thanks
    Frank
    great

  22. #22

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code

    Quote Originally Posted by kleinma
    come on man.. i think you can take the code i provided you, and work it into yours.. no?
    I'm trying to stick with what the IDE formats.

    The only error I was doings was...

    1) I left the Sub Main out on one post.
    2) I had two MainForm classes
    3) I put the "Private fForm As Form1" line in the upper class (which you said) but I put in the 2nd MainForm class. I deleted the 2nd class and put it where it goes... up top
    4) I forgot to change the Form1.WindowState to fForm1.WindowState

    Thanks Man!!

  23. #23
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code

    Quote Originally Posted by epixelman
    I'm trying to stick with what the IDE formats.

    The only error I was doings was...

    1) I left the Sub Main out on one post.
    2) I had two MainForm classes
    3) I put the "Private fForm As Form1" line in the upper class (which you said) but I put in the 2nd MainForm class. I deleted the 2nd class and put it where it goes... up top
    4) I forgot to change the Form1.WindowState to fForm1.WindowState

    Thanks Man!!
    yeah its harder to help when you dont use the microsoft IDE either.. it just makes certain things harder to explain...

  24. #24

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code [SOLVED]

    I've played with the Visual Studio... this SharpDevelop IDE is not that much different.

    Can you do me a favor Klien?

    Below is the most basic code that SharpDevelop creates when I create a new project. I have not edit it at all.

    Can you post a raw new project code for me so I can compare the difference and see if SharpDevelop is going to work?

    Thanks

    VB Code:
    1. Imports System
    2. Imports System.Drawing
    3. Imports System.Windows.Forms
    4.  
    5. Namespace NewProject
    6.    
    7. Public Class MainForm
    8.     Inherits System.Windows.Forms.Form
    9.        
    10.     Public Shared Sub Main
    11.         Dim fMainForm As New MainForm
    12.         fMainForm.ShowDialog()
    13.     End Sub
    14.        
    15.     Public Sub New()
    16.         MyBase.New
    17.         '
    18.         ' The Me.InitializeComponent call is required for Windows Forms designer support.
    19.         '
    20.         Me.InitializeComponent
    21.         '
    22.         ' TODO : Add constructor code after InitializeComponents
    23.             '
    24.     End Sub
    25.        
    26.     #Region " Windows Forms Designer generated code "
    27.     ' This method is required for Windows Forms designer support.
    28.     ' Do not change the method contents inside the source code editor. The Forms designer might
    29.     ' not be able to load this method if it was changed manually.
    30.     Private Sub InitializeComponent()
    31.                  '
    32.         'Form1
    33.         '
    34.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    35.         Me.ClientSize = New System.Drawing.Size(292, 266)
    36.         Me.Name = "MainForm"
    37.         Me.Text = "MainForm"
    38.     End Sub
    39.     #End Region
    40.        
    41. End Class
    42. End Namespace

  25. #25
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code [SOLVED]

    imports like system and system.drawing arent needed because they are automatically added for you on the project level when you create a new project

    VB Code:
    1. Public Class Form1
    2.     Inherits System.Windows.Forms.Form
    3.  
    4. #Region " Windows Form Designer generated code "
    5.  
    6.     Public Sub New()
    7.         MyBase.New()
    8.  
    9.         'This call is required by the Windows Form Designer.
    10.         InitializeComponent()
    11.  
    12.         'Add any initialization after the InitializeComponent() call
    13.  
    14.     End Sub
    15.  
    16.     'Form overrides dispose to clean up the component list.
    17.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    18.         If disposing Then
    19.             If Not (components Is Nothing) Then
    20.                 components.Dispose()
    21.             End If
    22.         End If
    23.         MyBase.Dispose(disposing)
    24.     End Sub
    25.  
    26.     'Required by the Windows Form Designer
    27.     Private components As System.ComponentModel.IContainer
    28.  
    29.     'NOTE: The following procedure is required by the Windows Form Designer
    30.     'It can be modified using the Windows Form Designer.  
    31.     'Do not modify it using the code editor.
    32.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    33.         components = New System.ComponentModel.Container()
    34.         Me.Text = "Form1"
    35.     End Sub
    36.  
    37. #End Region
    38.  
    39. End Class

  26. #26

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code [SOLVED]

    Klien..

    Here are the major differences I see...

    MY SHARPDEVELOP IDE
    =====================================

    VB Code:
    1. Public Shared Sub Main
    2.     Dim fMainForm As New MainForm
    3.     fMainForm.ShowDialog()
    4. End Sub
    YOUR VISUAL STUDIO IDE
    =====================================
    VB Code:
    1. 'Form overrides dispose to clean up the component list.
    2. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    3.     If disposing Then
    4.             If Not (components Is Nothing) Then
    5.                 components.Dispose()
    6.             End If
    7.         End If
    8.         MyBase.Dispose(disposing)
    9. End Sub


    Mine has the startup main, yours don't
    Yours has the Dispose sub, mine don't.

    Why, and what impact will my apps have?

    Thanks

  27. #27

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Minimize Form1 With MainForm Code [SOLVED]

    Klein,

    I would still like an answer from the question of my previous post about the diffrence bewteen the code.

    BTW... I have found something I do not like about .NET. If you care to know see this post...

    http://www.vbforums.com/showthread.php?t=329756

  28. #28
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Minimize Form1 With MainForm Code [SOLVED]

    the only differences there are that it appears your IDE creates a sub main to start up the app, but makes it shared in the form class itself.. generally from what I have seen, programmers usually make a module (which means all public things in it are shared already) and put a sub main there.

    the disposing thing is when the form is going to be disposed, it calls the dispose method on any components in the form to clean it up.. i imagine any of these components should get disposed of eventually anyway by the GC, so perhaps what the VS IDE adds in is just to speed up the process and get resources free as soon as possible...

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