Form.DesktopLocation()和Form.Location()之间的区别? [英] Difference between Form.DesktopLocation() and Form.Location() ??

查看:300
本文介绍了Form.DesktopLocation()和Form.Location()之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码显示了两个相同的值

private void mainform_Move(object sender,EventArgs e)

{

lbllocation.Text =位置 + this.Location.ToString();

lbldesktoplocation.Text =" location" + this.DesktopLocation.ToString();

}


究竟有什么区别?

The code below shows the same values for both
private void mainform_Move(object sender, EventArgs e)
{
lbllocation.Text = "location" + this.Location.ToString();
lbldesktoplocation.Text = "location" + this.DesktopLocation.ToString();
}

what exactly is the difference ?

推荐答案

我猜他们是一样的...

"而不是使用Location属性,DesktopLocation属性可用于设置表单的位置。此属性设置表单相对于任务栏的位置,如果任务栏已停靠在用户监视器的顶部或左侧,则此属性非常有用。以这种方式对接任务栏会遮挡桌面坐标(0,0)。 -MSDN

Desktoplocation:一个Point,表示桌面上表单的位置。

位置:代表屏幕坐标中表格左上角的点
桌面位置
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


嗯,必须至少有一些细微的差别,会等待其他人回答。
Hmm there must be atleast some minor difference, will wait for others for answer.


DesktopLocation就是它在桌面上的位置。因此,如果您有额外的工具栏或者您的任务栏移到侧面或顶部,您的DesktopLocation将与您的位置不同。


位置始终相对于(0,0 )屏幕。但是如果你将windows taksbar移动到顶部,你的Y坐标将相差大约34,因为DesktopLocation从 Desktop 实际启动的地方开始...在任务栏之后。

如果您想尝试一下,请制作带有标签的表格。处理表单'的移动事件。在处理程序中,执行以下操作:
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:
展开 | 选择 | Wrap | 行号


这篇关于Form.DesktopLocation()和Form.Location()之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆