CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2011
    Posts
    2

    problem in minimizing form in c#

    hi everyone

    i want to minimize my form to system tray in my C# windows application and hide it from taskbar

    my main problem is that when i click on minimize it goes to system tray and hide from taskbar

    but it goes to the top of start menu

    please find the attached what i mean.

    1- i want to know where is the minimize button action in my application

    my code is as follow

    private void Form1_Resize(object sender, EventArgs e)
    {
    if (WindowState == FormWindowState.Minimized)
    {
    this.Hide();
    this.Visible = false;
    this.ShowInTaskbar = false;
    this.Opacity = 0;


    }
    }




    so how to disable viewing my form in top of start menu button?
    Attached Images Attached Images  

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: problem in minimizing form in c#

    This is usually all you need with a NotifyIcon :
    Code:
          private void Form1_Resize(object sender, EventArgs e)
            {
                if (WindowState == FormWindowState.Minimized)
                {
                    this.Hide();
    
                    notifyIcon1.Visible = true;
                }
    
            }
    
            private void notifyIcon1_click(object sender, EventArgs e)
            {
                MessageBox.Show("You got me");
            }
    Tell me, what properties did you set for your form object, in other words, what is your FormBorderStyle property set to etc.?

  3. #3
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: problem in minimizing form in c#

    Re: NotifyIcon, I seem to remember having to explicitly assign an icon (NotifyIcon.Icon property) to get it to show up. Otherwise it would never appear in the system tray.
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

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

Featured