0

In my application I have my Main Form and other borderless forms that sit on top. When I minimize the main form, I want to minimize all forms, but ONLY show the main form in the taskbar. Currently what is happening is that the Main Form goes into the task bar, but all the other open forms create mini rectangles in the bottom left corner just above the taskbar.

Is there a way I can hide these ugly rectangles? Clicking on each rectangle will bring up that particular window (which I wish to prevent). I only want to give the user the option of clicking the main form in the taskbar to bring up all windows automatically.

Thanks

Edit

To hide all forms, I have added the following code to my Resize event in the Main Form:

Private Sub frmDashBoard_Resize(sender As Object, e As EventArgs) Handles Me.Resize
        If Me.WindowState = FormWindowState.Minimized Then
            If focusedForm IsNot Nothing Then
                If focusedForm.Tag Is "StorePage" Then
                    focusedForm.WindowState = FormWindowState.Minimized
                End If
            End If
        End If

        If Me.WindowState = FormWindowState.Maximized Then
            If focusedForm IsNot Nothing Then
                If focusedForm.Tag Is "StorePage" Then
                    focusedForm.WindowState = FormWindowState.Maximized
                End If
            End If
        End If
End Sub

Basically, I set my StorePage to focusedForm when it is open. So focusedForm will reference the topmost form within my application.

Riples
  • 1,167
  • 2
  • 21
  • 54
  • What did you entered for the [ShowInTaskBar](http://msdn.microsoft.com/en-us/library/system.windows.forms.form.showintaskbar(v=vs.110).aspx) Property of your Borderless Forms? – j_s_stack Jan 15 '15 at 01:06
  • hide the minimized windows (aka ugly rectangles) with `ShowInTaskBar = True` – Ňɏssa Pøngjǣrdenlarp Jan 15 '15 at 01:06
  • I have the `ShowInTaskBar` property set to False. If I set it to True, then I get an entry in the taskbar for that individual window which I don't want. I only want a single taskbar entry for the Main Form...if possible. – Riples Jan 15 '15 at 01:19
  • Can you please post the code you use to hide the forms – j_s_stack Jan 15 '15 at 01:23
  • It Looks like you want to devlop some Kind of Dashboard, did you though about creating a MDI Application – j_s_stack Jan 15 '15 at 01:55
  • Yes I did venture down that path, but I had to scrap my code and revert to SDI. I had a requirement to continuously move forms to the front and have them maximised but MDI couldn't support that nicely. I ran into a lot of trouble so I decided to revert. But turns out I'm having just as many issues with focusing now with SDI. I can't win. – Riples Jan 15 '15 at 01:58

1 Answers1

0

Don't minimize your forms, make them invisible instead, which if you don't want to see them, nor have them show in the taskbar, is really what you want:

If focusedForm.Tag Is "StorePage" Then
    focusedForm.Visible = (Me.WindowState <> FormWindowState.Minimized)
End If

etc.

HeyHeyJC
  • 2,627
  • 1
  • 18
  • 27
  • HeyHeyJC - works great on Minimize, but when I restore, for some reason it is adding an entry to the Taskbar for the borderless forms....strange – Riples Jan 15 '15 at 01:38
  • Hmm. I'm not seeing that here. Is ShowInTaskBar still False? – HeyHeyJC Jan 15 '15 at 01:40
  • Yes it is, but I have just re-added it into the `WindowState = FormWindowState.Maximed` code and it seems to have fixed it. Looks like it's resetting that property when the form is restored (well in my application anyway). – Riples Jan 15 '15 at 01:42
  • Cool. Could you maybe mark my answer? Hate to ask, but I lost my previous login, and I'm completely handicapped with no rep. – HeyHeyJC Jan 15 '15 at 01:52
  • Yeah absolutely...thanks for your help! I would've marked it anyway, so no stress about asking. – Riples Jan 15 '15 at 01:53
  • Thanks. Keep the questions coming :) – HeyHeyJC Jan 15 '15 at 02:04