Maximize screen without edge without hiding the Windows taskbar

Asked

Viewed 2,794 times

1

When I put the window to FormBorderStyle = None and maximize it, it sits in full screen, hiding the taskbar.

I’d like to know how to make it maximized, but without hiding the taskbar.

  • I don’t know about c#, but in Delphi this is solved by leaving the Align property, from Form, to Allclient. There is no need for any POG,.

2 answers

1


With the property FormBorderStyle set as None, you will have to handle it manually. That is, if you are going to use WindowState = FormWindowState.Maximized, the taskbar will stand behind the form.

My tip is you manually set the size of the form, disregarding the size of the taskbar (which is by default 40px since Windows 7). Obviously the size and location of the taskbar can be changed by the user settings - there is the option to use "small icons" which decreases the size of the toolbar and also the option to put it on any end of the monitor (up, down, right, left). This is not to mention that the taskbar can be automatically hidden.

The code below maximizes the form based on the width of the screen and the height of the screen (minus the 40px of the standard taskbar).

Obviously it is possible to get the information from the task bar, such as location and size, but for that you would need to call some Windows API. Depending on your idea, this is a lot of work for a not very good result, maybe this fits into another more specific question.

Private Sub BtMaximizar_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Width = Screen.PrimaryScreen.Bounds.Width //Largura igual a largura da tela
    Height = Screen.PrimaryScreen.Bounds.Height - 40 // Altura da tela, menos a barra

    Location = New Point() //New Point() cria um point com x = 0 e y = 0
    StartPosition = FormStartPosition.Manual
End Sub
  • Thank you! : ) <completing missing characters>

-2

Formatando na marra o tamanho do form

Sometimes a little POG is better than an extensive :D code

  • You have yet to explain the code.

  • Very simple code: I created a function where I take as parameter the Form that wants to perform this function. When Windowstate is different to maximized, it will not apply this action, when it is not it will do the following: 1° takes the free distance from the work area to the left -3; 2° takes the free distance from the work area from the top -3; 3° takes the free distance from the work area width +3; 4° takes the free distance from the work area height +3; //-3 to not appear.

  • Thank you! I will test here.

  • ah, hang on.... : v Not visual Basic! (I will try to convert the code)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.