Results 1 to 24 of 24

Thread: How to detect when a form is minimized/maximized

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    How to detect when a form is minimized/maximized

    how do i achieve this?
    \m/\m/

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    There should be events that fires when the form is minimized or maximized.
    Dont gain the world and lose your soul

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    simply do this
    VB Code:
    1. Private Sub Form1_Resize(ByVal sender As Object, ByVal e As _
    2. System.EventArgs) Handles MyBase.Resize
    3.  
    4.  MsgBox(Me.WindowState.ToString)
    5.  
    6. End Sub

  4. #4

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    well though pirate ty ill try it right now
    \m/\m/

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i am using a notify icon that is always in the systray and i want that when i double click it will show back the form..(im using C# but i think it's easy to see):

    Code:
    private void notifyIcon1_DoubleClick(object sender, System.EventArgs e) {
    	if (this.WindowState == FormWindowState.Minimized) {
    	this.WindowState = FormWindowState.Maximized;
    	this.Show();
    	this.ShowInTaskbar = true;
    	this.TopLevel = true;
    }
    }
    this is the code i've put in the double click of the notify icon...the problem is that i only seem to can put the form back to the maximized state , i cant put it as normal..anyone knows why? it just shows up in systray but i can do nothing with it..
    \m/\m/

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You're getting maximized form ,because you are using "Maximized" method to show your form , rather use "Normal" method as so :
    Code:
    private void notifyIcon1_DoubleClick(object sender, System.EventArgs e) {
    	if (this.WindowState == FormWindowState.Minimized) {
    	this.WindowState = FormWindowState.Normal;
    	this.Show();
    	this.ShowInTaskbar = true;
    	this.TopLevel = true;
    }
    }

  7. #7

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    lol read the post carefully i said i couldnt put normal so i tryed maximized because that was working lol but i want it normal
    \m/\m/

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by PT Exorcist
    lol read the post carefully i said i couldnt put normal so i tryed maximized because that was working lol but i want it normal
    Did you try the code I posted , it shows your form in normal size . That was your question I guess .

  9. #9

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    problem is that i only seem to can put the form back to the maximized state , i cant put it as normal..anyone knows why? it just shows up in systray but i can do nothing with it..
    \m/\m/

  10. #10
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    put this.Show(); before
    this.WindowState = FormWindowState.Normal;
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  11. #11
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    put this.Show(); before
    this.WindowState = FormWindowState.Normal;
    This won't make any difference. a good technique is to set the properties of a from first and then use show method .
    The problem already solved I guess .

  12. #12
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Did you test what i said?????!!!!!

    We are not talking about a GOOD technique here, we are talking about a method that does not work properly and the solution of it, that for me was putting
    this.show;
    before
    this.WindowState = FormWindowState.Normal;
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  13. #13
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    Did you test what i said?????!!!!!

    We are not talking about a GOOD technique here, we are talking about a method that does not work properly and the solution of it, that for me was putting
    this.show;
    before
    this.WindowState = FormWindowState.Normal;
    Yes I did . It results the same thing .

  14. #14

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    pirate is right, the result is the same thing...strange "bug" of this..how da hell i am suposed to put the form back again without putting max state?

    ......
    \m/\m/

  15. #15
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Simply by using my code lol

  16. #16

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    lol...ive already said ive tried that code and still doesnt work..but as u want that i put that again i've put ur code again and still doesnt work..it shows in the tray but the interface of the program itself isnt showed up

    ..
    \m/\m/

  17. #17
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You're missing something in your code I'm sure! .I've tried my code it's just working fine

  18. #18
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Pirate
    You're missing something in your code I'm sure! .I've tried my code it's just working fine
    try this !
    Attached Files Attached Files

  19. #19

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    jsut 5 min ago i copy pasted ur code and the result was that extrange "bug"...


    \m/\m/

  20. #20
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by PT Exorcist
    jsut 5 min ago i copy pasted ur code and the result was that extrange "bug"...
    What bug did you get ?

  21. #21

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i only see the program in the taskbar and when i click it nothing happens..
    \m/\m/

  22. #22
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by PT Exorcist
    i only see the program in the taskbar and when i click it nothing happens..
    lol , do you call this a bug ?? The program is running fine , and stop posting bull**** .

  23. #23
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    First:
    Pirate's code works for me fine

    Second:
    I am sorry, I was wrong, what i said was about VB.NET and I thought it might be the same for C#, but it wasn't.

    Third:
    Try this and see what i meant:
    VB Code:
    1. Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
    2.         If Me.WindowState = FormWindowState.Minimized Then
    3.             Me.Hide()
    4.             nt1.Visible = True
    5.         End If
    6. End Sub
    7.  
    8. Private Sub nt1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles nt1.MouseDown
    9.         Me.WindowState = FormWindowState.Normal
    10.         Me.Show()
    11.         nt1.Visible = False
    12. End Sub

    VB Code:
    1. Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
    2.         If Me.WindowState = FormWindowState.Minimized Then
    3.             Me.Hide()
    4.             nt1.Visible = True
    5.         End If
    6. End Sub
    7.  
    8. Private Sub nt1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles nt1.MouseDown
    9.         Me.Show()
    10.         Me.WindowState = FormWindowState.Normal
    11.         nt1.Visible = False
    12. End Sub
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  24. #24
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    First:
    Pirate's code works for me fine

    Second:
    I am sorry, I was wrong, what i said was about VB.NET and I thought it might be the same for C#, but it wasn't.

    Third:
    Try this and see what i meant:
    VB Code:
    1. Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
    2.         If Me.WindowState = FormWindowState.Minimized Then
    3.             Me.Hide()
    4.             nt1.Visible = True
    5.         End If
    6. End Sub
    7.  
    8. Private Sub nt1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles nt1.MouseDown
    9.         Me.Show()
    10.         Me.WindowState = FormWindowState.Normal
    11.         nt1.Visible = False
    12. End Sub
    Your're right Lunatic3 . I was coding in C# when I tried setting the "Normal" method before "show" . That's weird . I thought they are similar but it seems not at least in some controls.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width