Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Maximized center screen Form1 after being minimized no 2

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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