Solved

Maximized center screen Form1 after being minimized no 2

Posted on 2011-09-22
5
297 Views
Last Modified: 2012-05-12
Hello all

Let's open this topic again.

Maximized center screen Form1 after being minimized


Idle Mind was right on this:
"It's only when i minimize it with the code, then when i maximize it, it goes in top corner."

The instance of Form1 that you minimized is NOT the same instance that you are dealing with in QuitterToolStripMenuItem_Click().

Do you want the original instance to un-minimize when Form2 is closed?


Yes, i would like to unminimized the original form.

How can i do this?

Me.Close()
        Dim f As New Form1
        f.Left = (Screen.PrimaryScreen.Bounds.Width \ 2) - (f.Width \ 2)
        f.Top = (Screen.PrimaryScreen.Bounds.Height \ 2) - (f.Height \ 2)

        f.StartPosition = FormStartPosition.CenterScreen
        f.WindowState = FormWindowState.Normal
        f.Show()

Open in new window


Thanks again.

0
Comment
Question by:Wilder1626
  • 3
  • 2
5 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 36583272
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 36583386
Hello  Idle Mind,

Still have the same result.

It open a second Form1.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 36583448
You didn't follow the code closely enough then.

In your QuitterToolStripMenuItem() menu handler, remove the code that creates another instance of Form1.  It should only have "Me.Close()" i n there:
Private Sub QuitterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitterToolStripMenuItem.Click
        Me.Close()

        ' Remove the lines below!
        ' Dim f As New Form1
        ' f.Left = (Screen.PrimaryScreen.Bounds.Width \ 2) - (f.Width \ 2)
        ' f.Top = (Screen.PrimaryScreen.Bounds.Height \ 2) - (f.Height \ 2)
        '
        ' f.StartPosition = FormStartPosition.CenterScreen
        ' f.WindowState = FormWindowState.Normal
        ' f.Show()
    End Sub

Open in new window

0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 36583537
Oh, you are right.

Now it's working great.

But i have change this.
Private Sub Form2_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Me.WindowState = FormWindowState.Normal
    End Sub

Thanks again
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 36583550
=)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now