Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Maximized center screen Form1 after being minimized no 2

Posted on 2011-09-22
5
Medium Priority
?
337 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
[X]
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
  • 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

670 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