Setting a C# Form to a Negative Location

懵懂的女人 提交于 2020-01-03 10:43:26

问题


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.

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:

http://img.paronity.com/KsiA

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!


回答1:


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.

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!



来源:https://stackoverflow.com/questions/13372617/setting-a-c-sharp-form-to-a-negative-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!