6 Replies - 850 Views - Last Post: 17 July 2012 - 02:06 PM Rate Topic: -----

#1 KeedonKing  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 57
  • Joined: 12-July 12

Trouble with Returning Window Form back to normal State from Max

Posted 17 July 2012 - 11:59 AM

So I am creating my own Minimize Maximize and Exit buttons. I have both exit and Minimized done, but I am having a problem with my Maximize button. I want it to maximize on click, then if clicked again I want it to go back to normal state. The code I wrote for it is below, I must be missing something as it does maximize but quickly goes back to normal state without clicking it.

Private Sub MaxBtn_Click(sender As Object, e As EventArgs) Handles MaxBtn.Click
        Me.WindowState = FormWindowState.Maximized
        If Me.WindowState = FormWindowState.Maximized Then
            Me.WindowState = FormWindowState.Normal
        End If
    End Sub


Suggestions are welcome!

Is This A Good Question/Topic? 0
  • +

Replies To: Trouble with Returning Window Form back to normal State from Max

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4438
  • View blog
  • Posts: 12,310
  • Joined: 18-April 07

Re: Trouble with Returning Window Form back to normal State from Max

Posted 17 July 2012 - 12:51 PM

If you maximize it first and then go to the if statement, isn't that always going to be true? You are telling the window to be maximized and then saying "If you are maximized, go to normal".

You need it in an if/else statement. If windowstate is maximized, make it normal, else maximize it.

:)
Was This Post Helpful? 0
  • +
  • -

#3 KeedonKing  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 57
  • Joined: 12-July 12

Re: Trouble with Returning Window Form back to normal State from Max

Posted 17 July 2012 - 01:43 PM

View PostMartyr2, on 17 July 2012 - 12:51 PM, said:

If you maximize it first and then go to the if statement, isn't that always going to be true? You are telling the window to be maximized and then saying "If you are maximized, go to normal".

You need it in an if/else statement. If windowstate is maximized, make it normal, else maximize it.

:)


Private Sub MaxBtn_Click(sender As Object, e As EventArgs) Handles MaxBtn.Click
        NormBtn.Visible = True
        If Me.WindowState = FormWindowState.Normal Then
            Me.WindowState = FormWindowState.Maximized
        Else
            Me.WindowState = FormWindowState.Normal
        End If
    End Sub


Thanks a million Marty! I am still learning, self teaching. Trying to build this application but its painstaking When I haven't a clue how to approach most of the ideas I have for it. Figured this one out tho thanks for the direction mate!
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,500
  • Joined: 29-May 08

Re: Trouble with Returning Window Form back to normal State from Max

Posted 17 July 2012 - 01:52 PM

It also help to learn a few basic debugging skills.
Was This Post Helpful? 0
  • +
  • -

#5 KeedonKing  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 57
  • Joined: 12-July 12

Re: Trouble with Returning Window Form back to normal State from Max

Posted 17 July 2012 - 01:56 PM

View PostAdamSpeight2008, on 17 July 2012 - 01:52 PM, said:

It also help to learn a few basic debugging skills.


Will do that Adam Thanks. Like I said all new to me but rest assured I am wanting to learn it not have anyone do it for me. I will learn it as I go I guess as I cannot afford to school for it so here I am! Thanks for the support folks.
Was This Post Helpful? 0
  • +
  • -

#6 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,500
  • Joined: 29-May 08

Re: Trouble with Returning Window Form back to normal State from Max

Posted 17 July 2012 - 02:01 PM

Other members who have attend school, report that they ain't been taught about debugging skills.
Was This Post Helpful? 0
  • +
  • -

#7 KeedonKing  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 57
  • Joined: 12-July 12

Re: Trouble with Returning Window Form back to normal State from Max

Posted 17 July 2012 - 02:06 PM

View PostAdamSpeight2008, on 17 July 2012 - 02:01 PM, said:

Other members who have attend school, report that they ain't been taught about debugging skills.


No fun! Guess I'll have to learn through trial and error, which is pretty much what I am already doing lol. Thanks Adam
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1