|
-
Sep 27th, 2005, 05:32 AM
#1
Thread Starter
Lively Member
[RESOLVED] How to know when pressing minimize button?
I have a NotifyIcon that, when the main form is minimized, the user clicks in it and the form windowstate returns to normal, but the problem is knowing when the user minimizes the main form window... (The notifyicon is hide while the form is in normal state)
And how can I set the program running in background?
Thanks in advance
----------------------------------------------------
Centaurs were mythological creatures like chimeras and satyrs and they had a tendency to violence, except Chiron, who taught Greek heroes.
----------------------------------------------------
-
Sep 27th, 2005, 05:36 AM
#2
Re: How to know when pressing minimize button?
Use the WindowState property in the Resize event handler:
VB Code:
Private Sub Form1_Resize(...) Handles MyBase.Resize
Me.Notifyicon1.Visible = (Me.WindowState = FormWindowState.Minimized)
End Sub
This will hide and show the NotifyIcon as needed.
-
Sep 27th, 2005, 05:40 AM
#3
Thread Starter
Lively Member
Re: How to know when pressing minimize button?
WOW! This was a record reply! Thanks JMC!
Btw, do you know how to set an app running in background?
Thanks for the help.
----------------------------------------------------
Centaurs were mythological creatures like chimeras and satyrs and they had a tendency to violence, except Chiron, who taught Greek heroes.
----------------------------------------------------
-
Sep 27th, 2005, 05:54 AM
#4
Re: How to know when pressing minimize button?
I'm not sure what you mean by running in the background. An application is generally considered to be a foreground process and a service is considered to be a background process. If you want your app to continue processing while it's in the tray without affecting other running applications responsiveness, you could reduce the priority of its main thread:
VB Code:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
If Me.WindowState = FormWindowState.Minimized Then
Threading.Thread.CurrentThread.Priority = Threading.ThreadPriority.BelowNormal
Me.ShowInTaskbar = False
Me.NotifyIcon1.Visible = True
Else
Threading.Thread.CurrentThread.Priority = Threading.ThreadPriority.Normal
Me.ShowInTaskbar = True
Me.NotifyIcon1.Visible = False
End If
End Sub
This could reduce the responsiveness of your tray icon's menu though.
-
Sep 27th, 2005, 06:05 AM
#5
Thread Starter
Lively Member
Re: How to know when pressing minimize button?
Thank you JMC, I knew that and how to implement it, but I didn't express clearely... I was saying that I would like my app (When minimized) didn't showed on the minimized bar next to Start Menu in Windows.
----------------------------------------------------
Centaurs were mythological creatures like chimeras and satyrs and they had a tendency to violence, except Chiron, who taught Greek heroes.
----------------------------------------------------
-
Sep 27th, 2005, 07:22 AM
#6
Thread Starter
Lively Member
Re: How to know when pressing minimize button?
JMC, I found, nothing more EASY!!
What I wanted besides the help you gave me was hidding my application in taskbar...
I had only to do Me.ShowInTaskbar = False....
Thanks, this has been resolved.
----------------------------------------------------
Centaurs were mythological creatures like chimeras and satyrs and they had a tendency to violence, except Chiron, who taught Greek heroes.
----------------------------------------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|