Results 1 to 28 of 28

Thread: Minimize Form1 With MainForm Code [SOLVED]

Hybrid View

  1. #1
    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

  2. #2

    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?

  3. #3
    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...

  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

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

  5. #5

    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

  6. #6
    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

  7. #7

    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?

  8. #8

    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

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