Form Location on single/dual monitors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nilam2477
    New Member
    • Feb 2008
    • 38

    Form Location on single/dual monitors

    I have wizard kind of windows application with many forms. I have set the form Location this.Location = new Point(100, 100);
    This works fine with single monitor. If the user connects to multiple monitors i want the form to be displayed in both the monitors. How can set the form Location? Also also if the user switches back to single monitor the Form should display in one monitor?
  • dip_developer
    Recognized Expert Contributor
    • Aug 2006
    • 648

    #2
    Originally posted by Nilam2477
    I have wizard kind of windows application with many forms. I have set the form Location this.Location = new Point(100, 100);
    This works fine with single monitor. If the user connects to multiple monitors i want the form to be displayed in both the monitors. How can set the form Location? Also also if the user switches back to single monitor the Form should display in one monitor?
    I didnt understand your query....please clearly state your problem....

    Comment

    • Shashi Sadasivan
      Recognized Expert Top Contributor
      • Aug 2007
      • 1435

      #3
      Use the Screens.AllScre ens to get a Screen array.

      if the number of screens are more than one, then with Scheen.Primary you willg et to know if it is the main / primary screen.

      To set the location of the form to any particular screen use the
      myForm.Location = screen.WorkingA rea.Location; //which is the 0,0 for that screen

      you might have to manually check the number of screens and then decide accordingly. Unless i am missing something. I implemented a 4 screen application, and had to make sure that it would run for 1 to 4 screens, and hence had 4 cases, might look for a way to reducce that code

      Comment

      • Nilam2477
        New Member
        • Feb 2008
        • 38

        #4
        Thanks for your answer,
        My requirement is to display the same Form in both the monitors. It should occupy both the monitors (half of the form in one monitor and other half in the 2nd monitor) Is it possible?

        Comment

        • Shashi Sadasivan
          Recognized Expert Top Contributor
          • Aug 2007
          • 1435

          #5
          You may want to iterate through all the screens, and compare which has the least point (ie, screen location)
          and use that for the location of form.
          and then find the max position of the right hand corner, and then you would have to give the size to the form.

          however the form should not be maximized as it would revert itself to the bounds of only one screen.

          Good luck with that

          Comment

          • Nilam2477
            New Member
            • Feb 2008
            • 38

            #6
            Thank you for your suggestions but i still cant get this working.
            My form size is fixed. I dont want to change the Form size. I just need to change the Form Location.
            For one monitor i set the Form location as this.Location = new Point(100, 100);
            how can get the location in case of 2 monitors.

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              Why would you want it to start out split like that? Seems like it would be very obnoxious to have a big plastic bar or two (and possibly some air) between the form.
              You will have to do some deciphering to discover which orientaion the monitors are in, (They don't have to be linked left-right, they could top-bottom) then determine the master viewable area dimensions and computer where the center point is. Then compute the offset of the center point in your form to the top-left corner of your form and apply that offset to the center of the viewable area and set your form there.


              As an alternative, you could try one of the windows standard locations of "center"

              Comment

              Working...