微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将winform放置在屏幕的左下angular

我试图在屏幕的左下angular放置一个表单(在开始button上)我有下面的代码,试图做到这一点,但只考虑到屏幕的工作区域 – 所以窗体位于就在开始button的上方:

int x = Screen.PrimaryScreen.WorkingArea.Left + this.Width; int y = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height; this.Location = new Point(x,y);

演示/屏幕如下,以进一步说明我正在尝试做什么:

sql Server Compact Edition数据库部署策略

当应用程序是服务时,SetWinEventHookcallback不起作用

服务无法启动。 服务进程无法连接到服务控制器

Microsoft.CSharp库中的BadImageFormatexception

如何确定给定COM库的线程模型?

我应该在Windows消息框中使用警告图标还是问号图标?

存储XML本地直到networking连接恢复

我如何移动粘贴/贴紧wpf窗口

有关从Windows服务打印的第三方库/组件的build议

输出到C#中的文本文件输出

使用Screen.PrimaryScreen.Bounds属性并设置this.TopMost = true 。 这工作:

int y = Screen.PrimaryScreen.Bounds.Bottom - this.Height; this.Location = new Point(0,y); this.TopMost = true;

工作区域通常不包括任何任务栏,停靠窗口和停靠工具栏。 使用Screen.PrimaryScreen.Bounds为您提供完整的屏幕高度和宽度。

示例代码如下所示:

public Form1() { InitializeComponent(); Rectangle r = Screen.PrimaryScreen.WorkingArea; this.StartPosition = FormStartPosition.Manual; this.Location = new Point(0,Screen.PrimaryScreen.Bounds.Height - this.Height); this.TopMost = true; }

这很可能会显示在任务栏下方,因为通常任务栏认设置为最高。 我记得有一个选项,在Windows XP中关闭该选项,但不知道。

编辑:

在Windows XP中,您可以将任务栏放在窗口后面。 按照链接: 始终在顶部的任务栏上

正如Ria所指出的那样,将这个this.TopMost设置为true,这是一个更好的选择。

你可以试试这个代码

Rectangle workingArea = Screen.GetWorkingArea(this); this.Location = new Point(0,workingArea.Bottom - Size.Height);

Ria的答案是正确的,但没有添加任务栏高度。

如果您想要显示图片中的内容,则应使用以下代码

int nTaskBarHeight = Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom; Rectangle workingArea = Screen.GetWorkingArea(this); this.Location = new Point(0,workingArea.Bottom - Size.Height + nTaskBarHeight); this.TopMost = true;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐