将 C# 表单设置为否定位置 [英] Setting a C# Form to a Negative Location
问题描述
我正在开发一种适用于 Windows 的工具,该工具将使用其 API 与 CloudApp 进行交互.我在这里找到了一些关于如何实现区域捕获的文章,我曾经修改过这些文章以满足我的确切需求.一切都很顺利,但我在多显示器设置方面遇到了问题.麻烦的原因是我在 1920x1080 中运行一台显示器,第二台是 1080x1920.
I am working on a tool for Windows that will interface with CloudApp using its API. I found some articles on here about how to achieve the Region capture which I used to modified to fit my exact needs. Everything is going very well, but I am having trouble with a multi-monitor setup. The reason for the trouble, is that I run one monitor in 1920x1080 and the second is 1080x1920.
整个流程是我创建整个屏幕(3000、1920)的图像,然后将其显示为表单中的背景.问题是我无法让该表格从负点开始,因此它会将所有内容向下移动.
The overall flow is that I create an image of the entire screen (3000, 1920), then I show it as the background in a form. The issue is I can't get that form to start at a negative point so it moves everything down.
如果我在选择区域之前查看我捕获的原始图像,一切都很好:
If I look at the raw image I capture before I do the region selection, all is well:
问题是我什么时候调出区域表格.为了使它成为表单的背景并位于正确的位置,我需要表单的左上角 X,Y 为 (0,-670).无论我尝试哪种方法,我都无法实现这一目标.
The issue is when I go to bring up the region form. In order for it to be the background of the form and be in the correct place, I would need the form's upper left X,Y to be (0,-670). No matter which method I try, I am unable to achieve this.
有什么办法可以达到我遗漏的消极点吗?为了完整起见,我制作了一个非常简单的表格,当你移动它时输出它的顶部"坐标,当我将它移动到垂直监视器的上部时,我得到负分,所以我知道它们是有效的.
Is there any way to achieve the negative point that I am missing? For sake of being complete, I made a very simple form which outputs its "top" coordinate when you move it, and when I move it to the upper portion of the vertical monitor, I get negative points for it so I know they are valid.
让我知道我的代码的任何部分是否有帮助,我会发布它.我只是不确定它是否有必要.提前致谢!
Let me know if any part of my code would be helpful and I will post it. I just wasn't sure it was going to be necessary. Thanks in advance!
推荐答案
抱歉发帖.这是可能的.问题是我在表单的构造函数中设置表单的大小.我不知道这行不通.一旦我将它设置在表单加载事件上,它就会将其移动到正确的位置.
Sorry for the post. It is possible to do. The issue was that I was setting the size of the form in the constructor for the form. I wasn't aware this wouldn't work. Once I set it on the form load event instead, it moved it into the right place.
谢谢@dognose!你说你的测试有效让我觉得这可能是一个范围/位置问题,它是!谢谢大家看这个问题!
Thanks @dognose! You saying your test worked made me think that is was probably a scope/placement issue and it was! Thanks for everyone looking at this question!
这篇关于将 C# 表单设置为否定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!