473,804 Members | 3,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Difference between Form.DesktopLoc ation() and Form.Location() ??

153 New Member
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 ?
Dec 3 '08 #1
14 5024
PRR
750 Recognized Expert Contributor
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
Dec 3 '08 #2
akshaycjoshi
153 New Member
Hmm there must be atleast some minor difference, will wait for others for answer.
Dec 3 '08 #3
Curtis Rutland
3,256 Recognized Expert Specialist
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:
Expand|Select|Wrap|Line Numbers
  1. 'VB code, because I already had a vb project open:
  2. Dim m As String = String.Format("Loc: {0},{1}  |  Des: {2},{3}", Me.Location.X, Me.Location.Y, Me.DesktopLocation.X, Me.DesktopLocation.Y)
  3. 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.
Dec 3 '08 #4
akshaycjoshi
153 New Member
@insertAlias
Ohh thanks for the explaination insertAlias!
Dec 3 '08 #5
Plater
7,872 Recognized Expert Expert
I would guess it probably plays into if you have multiple screens too
Dec 3 '08 #6
Curtis Rutland
3,256 Recognized Expert Specialist
That doesn't seem to affect it, Plater. Just things that take up desktop space that don't belong to the desktop, like toolbars.
Dec 3 '08 #7
akshaycjoshi
153 New Member
@Plater
let me content with one screen as of now hahhaha (what is multiple screen now ?)
Dec 3 '08 #8
Curtis Rutland
3,256 Recognized Expert Specialist
@akshaycjoshi
....more than one monitor connected to the same PC?
Dec 3 '08 #9
akshaycjoshi
153 New Member
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 :)
Dec 3 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
50433
by: saiho.yuen | last post by:
Hi, Is anyone know what is the difference between Location.href and Window.location.href Thanks you very much:) Saiho
3
1172
by: Jarek Mielcarek | last post by:
hi, I've problem to locate form on screen. I'd like to show modal form near a textbox after user click on it. here is the code: Private Sub myTextBox_MouseDown(ByVal sender As Object, ByVal e As (...) Dim r As New Rectangle(TextBox.Width, 1, 16, 18) If r.Contains(New Point(e.X, e.Y)) Then With popUp .DesktopLocation = PointToScreen(New Point(r.Right - popUp.Size.Width, r.Bottom + 2))
4
3161
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps further away, completely leaving the selector box area. Any ideas? VS 2003 and VB.Net This is a simple application at the moment but the form is inherited from a
4
1715
by: Philip Wagenaar | last post by:
I have made a form with a tab that containts groupboxes and those contain checkboxes. When I run the application sometimes the outlining for some groupboxes are not shown, if I switch tabs and back sometimes all outlining is shown and sometimes are not shown. I have no idea what is going wrong. What also is weird is that when I open the form from my main application I can resize the form, even though it is locked, and that when I cut...
14
3437
by: Galen Somerville | last post by:
My current screen resolution is set to 1024 x 768. My form size always comes up as 1032 x 748. I have tried the help sample ' Retrieve the working rectangle from the Screen class ' using the PrimaryScreen and the WorkingArea properties. Dim workingRectangle As System.Drawing.Rectangle = _ Screen.PrimaryScreen.WorkingArea ' Set the size of the form slightly less than size of
2
4290
by: Rich | last post by:
Greetings. I have a child form inside an MID parent form. The child form is wider than the MID parent form. The child form contains a number of textboxes which are positioned from left to right on the child form where the textbox on the right is not viewable because it extends beyond the right border of the MDI parent form. What I need to happen is when I tab through the textboxes - when I tab into the textbox on the right side of...
8
3593
by: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a picture box, lots of text boxes (for input).. you get the idea. All of a sudden everything on the form has disappeared, it looks like a blank, newly created form. I can still get to the properties of every item on the form using the drop-down box in...
1
9459
by: Marc the Demi-Programmer | last post by:
I am overriding WncProc to make sure my form's location stays within specified parameters. Basically, it has to stay at the top of the screen and not be off to either of the sides. All that works when the form is in its minimal size. However, when the form is maximized using the appropriate button the code that is supposed to set the location is ignored. When the form is switched back to the standard dimensions through the restore...
2
2172
by: Steve Richter | last post by:
I am using ShowDialog to show a popup form and want to position the popup relative to the control on the form the popup is pertinent to. For this, I am using FormStartPosition.Manual to set the position of the form relative to the desktop. I can calc the location of a control relative to the client rect of a form. But since I am positioning the popup form relative to the desktop, I need to know the DesktopLocation of controls on the...
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.