Difference between Form.DesktopLocation() and Form.Location() ??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akshaycjoshi
    New Member
    • Jan 2007
    • 153

    Difference between Form.DesktopLocation() and Form.Location() ??

    The code below shows the same values for both
    private void mainform_Move(o bject sender, EventArgs e)
    {
    lbllocation.Tex t = "location" + this.Location.T oString();
    lbldesktoplocat ion.Text = "location" + this.DesktopLoc ation.ToString( );
    }

    what exactly is the difference ?
  • PRR
    Recognized Expert Contributor
    • Dec 2007
    • 750

    #2
    i guess they are same ...
    "In lieu of using the Location property, the DesktopLocation property can be used to set the location of your form. This property sets the location of your form relative to the taskbar and is useful if the taskbar has been docked to the top or left of the user's monitor. Docking the taskbar in this fashion obscures the desktop coordinates (0,0)." -MSDN
    Desktoplocation : A Point that represents the location of the form on the desktop.
    Location :The Point that represents the upper-left corner of the Form in screen coordinates
    Desktop Location

    Comment

    • akshaycjoshi
      New Member
      • Jan 2007
      • 153

      #3
      Hmm there must be atleast some minor difference, will wait for others for answer.

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        DesktopLocation is exactly that...where it is on the desktop. So if you have extra toolbars or you have your task bar moved to the side or the top, your DesktopLocation will be different than your Location.

        Location is always relative to (0,0) of the screen. But if you move your windows taksbar to the top, your Y coordinates will differ by about 34, because the DesktopLocation starts where the Desktop actually starts...after the taskbar.

        If you want to try it out, make a form with a label. Handle the form's Move event. In the handler, do something like this:
        Code:
        'VB code, because I already had a vb project open:
        Dim m As String = String.Format("Loc: {0},{1}  |  Des: {2},{3}", Me.Location.X, Me.Location.Y, Me.DesktopLocation.X, Me.DesktopLocation.Y)
        Label2.Text = m
        And you'll see the difference...if there is any for you. If there isn't, unlock your taskbar and move it to the top. Then you will see a difference.

        Comment

        • akshaycjoshi
          New Member
          • Jan 2007
          • 153

          #5
          Originally posted by insertAlias
          DesktopLocation is exactly that...where it is on the desktop. So if you have extra toolbars or you have your task bar moved to the side or the top, your DesktopLocation will be different than your Location.

          Location is always relative to (0,0) of the screen. But if you move your windows taksbar to the top, your Y coordinates will differ by about 34, because the DesktopLocation starts where the Desktop actually starts...after the taskbar.

          If you want to try it out, make a form with a label. Handle the form's Move event. In the handler, do something like this:
          Code:
          'VB code, because I already had a vb project open:
          Dim m As String = String.Format("Loc: {0},{1}  |  Des: {2},{3}", Me.Location.X, Me.Location.Y, Me.DesktopLocation.X, Me.DesktopLocation.Y)
          Label2.Text = m
          And you'll see the difference...if there is any for you. If there isn't, unlock your taskbar and move it to the top. Then you will see a difference.
          Ohh thanks for the explaination insertAlias!

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            I would guess it probably plays into if you have multiple screens too

            Comment

            • Curtis Rutland
              Recognized Expert Specialist
              • Apr 2008
              • 3264

              #7
              That doesn't seem to affect it, Plater. Just things that take up desktop space that don't belong to the desktop, like toolbars.

              Comment

              • akshaycjoshi
                New Member
                • Jan 2007
                • 153

                #8
                Originally posted by Plater
                I would guess it probably plays into if you have multiple screens too
                let me content with one screen as of now hahhaha (what is multiple screen now ?)

                Comment

                • Curtis Rutland
                  Recognized Expert Specialist
                  • Apr 2008
                  • 3264

                  #9
                  Originally posted by akshaycjoshi
                  what is multiple screen now ?
                  ....more than one monitor connected to the same PC?

                  Comment

                  • akshaycjoshi
                    New Member
                    • Jan 2007
                    • 153

                    #10
                    hmmm what is the use of connecting multiple monitore to the same PC when all will display the same thing.
                    Anyways this is out-of-topic so you can ignore this question :)

                    Comment

                    • Curtis Rutland
                      Recognized Expert Specialist
                      • Apr 2008
                      • 3264

                      #11
                      No, I'll answer.

                      They don't have to both show the same thing...you can extend your desktop across both of them, making it act like one large display, except maximizing still only fills one window. It's especially nice for coding, if you have to look at your database at the same time. Have your code up in one, your DB up in the other. Or if you have to compare documents...or anything that requires more than one window at a time.

                      So, for example, I have two 19 inch monitors right now. They're both at 1280x1024 resolution. My desktop is actually 2560x1024 pixels, because it treats them as one big screen.

                      Also, there are some good uses for the "cloned view" where both show the same thing...like for projectors. Also, I saw a setup in a photographer's place, where they had a monitor facing forward and backwards, so that the client could sit on the other side of the desk, and preview pics with them.

                      Comment

                      • balabaster
                        Recognized Expert Contributor
                        • Mar 2007
                        • 798

                        #12
                        Originally posted by insertAlias
                        So, for example, I have two 19 inch monitors right now. They're both at 1280x1024 resolution. My desktop is actually 2560x1024 pixels, because it treats them as one big screen.
                        I have 3 and some days I still wonder if I could have more. I'm working my way up to the 6 that John Travolta has in Operation: Swordfish.

                        Comment

                        • Curtis Rutland
                          Recognized Expert Specialist
                          • Apr 2008
                          • 3264

                          #13
                          IIRC that was seven, and that would be all kinds of neat...having them all wall mounted....
                          /drools


                          Anyway, I think you can go up to nine without specialized hardware...I heard that somewhere from someone, so I have no idea if that's true.

                          Comment

                          • balabaster
                            Recognized Expert Contributor
                            • Mar 2007
                            • 798

                            #14
                            Originally posted by insertAlias
                            IIRC that was seven, and that would be all kinds of neat...having them all wall mounted....
                            /drools
                            I doubt very much my boss would let me have all that equipment and if I "wasted" that kind of money my home computer, my wife would kill me. hehe. I guess I should've married a woman that's as into computers as I am :o)

                            Comment

                            • Curtis Rutland
                              Recognized Expert Specialist
                              • Apr 2008
                              • 3264

                              #15
                              No, because then you'd be buying her those monitors ;)

                              But seriously, I'm picking up a 24" over the holidays....it' s going to be great.

                              At home I like to have one big monitor, because I play games. Working, I like multiples.

                              Comment

                              Working...