Solved

Maximized center screen Form1 after being minimized no 2

Posted on 2011-09-22
5
308 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

25 Experts available now in Live!

Get 1:1 Help Now