Results 1 to 3 of 3

Thread: Limit forms to current screen

  1. #1

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    47

    Limit forms to current screen

    Hi,

    when i open a certain window on a multi-screen-computer, it opens across the different screens. Can i prevent this it opens only on one screen?

    Regards

    Erwin

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,754

    Re: Limit forms to current screen

    When the form opens, you can specify the StartPosition to manual and then manually specify the Location.

    In the Form's Load event, you can get every screen in an array by getting Screen.AllScreen or you can get the primary screen by calling Screen.PrimaryScreen. Regardless of if you pick one from the array or if you just get the primary screen, once you have a screen selected you can manually set the location of the form by getting the Location of the screen's bounds.

    Something similar to this:
    Code:
    Private Sub MyForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        With Me
            .StartPosition = FormStartPosition.Manual
            .Location = Screen.PrimaryScreen.Bounds.Location
        End With
    End Sub
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    Re: Limit forms to current screen

    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

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