Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Maximized center screen Form1 after being minimized no 2

Posted on 2011-09-22
5
Medium Priority
?
343 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 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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 86

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 86

Expert Comment

by:Mike Tomlinson
ID: 36583550
=)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

885 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