Reapz Posted August 5, 2003 Posted August 5, 2003 Hi guys, I got my app' to minimize to the tray ok that was easy enuff and I've got a doubleclick event for the trayicon to restore the form using windowstate.normal and this was all working fine. Now I've added a couple of lines of code so that when the form is open form1.showintaskbar = true and trayicon.visible = false and then when the form gets minimized form1.showintaskbar = false and trayicon.visible = true. The problem I'm having since I made these changes is that double clicking on the trayicon restores the app' but only to the taskbar and assumes that as being its 'normal' state. The only way I can see the form after that is to maximize it. Can't find anything about this specific prob' on the forums or on the MSDN examples or the Forms FAQ. Anyway here's the code... Private Sub TrayIcon_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrayIcon.DoubleClick Me.ShowInTaskbar = True TrayIcon.Visible = False Me.WindowState = FormWindowState.Normal Me.Activate() End Sub Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize If Me.WindowState = FormWindowState.Minimized Then Me.ShowInTaskbar = False TrayIcon.Visible = True End If End Sub Cheers, Andy! Quote I'm getting the hang of this now... No really I am!
*Experts* Volte Posted August 5, 2003 *Experts* Posted August 5, 2003 Just set Visible = False when you minimize it, and Visible = True when you maximize it. Quote
jorge Posted August 5, 2003 Posted August 5, 2003 i thing .show() and .hide() are faster, than .visible = treu, hide/show is less code and look nicer, but that personal opinion i gess Quote Jorge - http://www.blackdot.be/?page=apache.htm
*Experts* Volte Posted August 5, 2003 *Experts* Posted August 5, 2003 I don't see how one can be faster than the other... all either of them do is remove WS_VISIBLE from the list of window styles applied to the form. Quote
jorge Posted August 5, 2003 Posted August 5, 2003 yes, but hide is typed faser, espacialu when you type slow like me :s Quote Jorge - http://www.blackdot.be/?page=apache.htm
Reapz Posted August 6, 2003 Author Posted August 6, 2003 Aah I see... no need for the showintaskbar at all. That will teach me to try and be clever :D. Cheers VF! Quote I'm getting the hang of this now... No really I am!
_SBradley_ Posted August 8, 2003 Posted August 8, 2003 TrayIcon is now called NotifyIcon. There is actually a subtleish difference between the ShowInTaskbar and Visible methods. If you set Visible to false, then, when you Alt+Tab between applications, your application will not be in the list. With the ShowInTaskbar method, your application will still be there (although it turns out to be a "blank window" icon -- this seems like a bug...?). I didn't have a problem with either method, though: you just have to make sure to reset the rest of the state (make it visible or whatever) before resizing the form. Quote
vishu020 Posted August 27, 2008 Posted August 27, 2008 Hi guys, i have a problem, I have written the code exactly the same which you have posted. the following is the ccode, Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Resize If Me.WindowState = FormWindowState.Minimized Then Me.Hide() 'Me.ShowInTaskbar = False TrayIcon.Visible = True TrayIcon.Text = "Hide Me" End If End Sub Private Sub TrayIcon_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TrayIcon.MouseDoubleClick Me.ShowInTaskbar = True Me.Show() TrayIcon.Text = "Show Me" Me.Enabled = True Me.WindowState = FormWindowState.Normal *******'Me.Activate()***** End Sub The Problem is i do not know where the activate method is there for the form. and when i minimize the form, it is perfectly getting invisible and as well as from the taskbar too. but i cannot see the icon in the System Tray. please help. Thanks Vish Quote
Administrators PlausiblyDamp Posted August 27, 2008 Administrators Posted August 27, 2008 Have you assigned an icon to the tray icon? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.