0

When I'm changing windows(forms), my application's icon disappears from taskbar. So for opening the application, users need to click ALT+TAB to select the form which is hidden from taskbar. After users choose application, icon comes to taskbar again. I don't want my applcation icon disappears from taskbar.

My codes are below:

//Program.cs
[STAThread]
static void Main()
{
    Application.Run(new LoginPage());
}

Login Page is application's first screen that gets username and password. After clicking submit button application is going to main page.

//LoginPage.cs  
private void submitBtn_Click(object sender, EventArgs e)
{
    MainPage mainPage= new MainPage();                   
    mainPage.Show();
    this.Hide();
}

Lets say I have a button on main page for going to another form. Here when I click the page1 button taskbar icon disappears.

//MainPage.cs
private void page1Btn_Click(object sender, EventArgs e)
{
    Page1 page1 = new Page1();
    page1.Show();
    this.Hide();
}

After some research I found one solution for that but there is another problem which I cannot minimize the form correctly.

When I change the codes above with below

//MainPage.cs
private void page1Btn_Click(object sender, EventArgs e)
{
    Page1 page1= new Page1();
    page1.ShowInTaskbar = false;
    page1.Owner = this;
    page1.ShowDialog();
    this.Hide();     
}

Here, I also need to modify Page1 as below

//Page1.cs
private void Page1_FormClosed(object sender, FormClosedEventArgs e)
{
    MainPage mainPage = new MainPage();
    mainPage.Show();
}

Here I can successfully go to page1 step by step (without disappearing the taskbar icon). When I minimize the page1, it minimizes the application as expected but when I maximize the application from taskbar, I expect Page1 should maximizes but MainPage maximizes with an minimized Page one like below image.

MainPage

I only want to correct these problems. I hope there is experts which experienced these things there.

8
  • 4
    Dont hide the form! Commented Jan 22, 2018 at 9:15
  • There is another problem on that case. MainPage should be hidden for user experience. Commented Jan 22, 2018 at 9:17
  • Thats then a design issue - but the reason it goes from the bar is you are hiding the main form. Commented Jan 22, 2018 at 9:20
  • i suggest to use MDI forms How To USE it is a professional and pretty cool thing Commented Jan 22, 2018 at 9:26
  • Thanks for your suggestion but as I can see MDI container opens the new form inside of the parent. This is not suitable for me. The pages are irrelevant. I think you suggest this with looking the image that I shared. The menu item is not exist at Page1 Commented Jan 22, 2018 at 19:02

2 Answers 2

1

In MetroFramework, I have the same problem. When my application starts (in the FORM_LOAD) , I programmatically maximize and the icon disappears. Checking the MetroFramework code, the problem is caused by ShadowType. If you change the ShadowType to None:

this.ShadowType= MetroFormShadowType.None;

the issue is resolved. I hope the solution works

Sign up to request clarification or add additional context in comments.

Comments

0

Problem is solved.

The problem was, I was maximizing the form from properties of the page.

Instead of maximizing it from properties, I do it manually from Page Load and its solved.

this.Bounds = Screen.PrimaryScreen.WorkingArea;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.