901026-C#中的ClientToScreen等效项 [英] 901026 - ClientToScreen equivalent in C#

查看:105
本文介绍了901026-C#中的ClientToScreen等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有一个停靠在窗体中的图片框.表格有4个面.通过拖动每一边可以调整大小.由于图片框已停靠在窗体中,因此调整窗体的大小也会调整图片框的大小.图片在框内显示.我想每次调整图片框的大小以使其不显示任何新图像.哦,对不起,我必须尽力描述它.假设表单是一个窗口,其中有一个静态背景图片,例如房间墙纸将要显示.换句话说,假设图片框是显示器上的一个孔,您可以在其中看到显示器后面的内容.现在,通过调整表格大小,您可能会看到更多的墙.在这种情况下,图片框所显示的内容不会通过调整其大小而改变,而是静态图像.这就是我所需要的.
我怎样才能做到这一点?我认为第一步是找到一种方法来找到屏幕上图片框的位置.我该怎么办?
thx

解决方案

您始终可以使用System.Windows.Forms.Control.PointToClientSystem.Windows.Forms.Control.PointToScreenhttp://msdn.microsoft.com/zh-CN/library/system.windows.forms.control.aspx [ < a href ="http://www.codeproject.com/Answers/201863/capture-the-drawing-on-a-panel#answer1">在面板上捕获图形</a> [< a href ="http://www.codeproject.com/Answers/201863/capture-the-drawing-on-a-panel#answer1" target ="_ blank" title =新窗口"> ^</a> ].

甚至甚至不需要< code> PointToClient/PointToScreen. :-)

—SA


hi i''ve a picture box docked in a form. a form has 4 sides. by dragging each side it may be resized. since the picture box is docked in the form, resizing form also resizes the picture box. a picture is showing in the picture box. i want to make the new image for the picture box each time it gets resized so that no change in the screen appears. oh sorry, i must try my best to describe it. suppose that the form is a window in which a static background image eg. room wallpaper is going to be shown. in another words, suppose that the picture box is a hole in the monitor in which u may see what is behind the monitor. now by resizing the form u may see more of the wall. in such a case, what picture box is showing doesn''t change by resizing it and it''s a static image. this is what i need.
how can i do this? i think the first step is to find a way to find the location of the picture box in screen. how can i do this?
thx

You can always use System.Windows.Forms.Control.PointToClient, System.Windows.Forms.Control.PointToScreen, http://msdn.microsoft.com/en-us/library/system.windows.forms.control.aspx[^].

—SA


Now, a completely different advice, because this is something totally unrelated to the title of your question.

Why do you think you need to use PictureBox? You are trying to abuse it, because for your purpose it presents only the hassles for implementation and does not add any value. It also eat up additional resources offering nothing in return. Even though you can solve the problem with <codepicturebox>, it is worse than totally useless. You should do very different thing — use a custom control derived from <code>System.Windows.Forms.Control.

Please see my past solutions where I explain exactly what to do:
<a href="http://www.codeproject.com/Answers/194885/How-do-I-clear-a-panel-from-old-drawing#answer2">How do I clear a panel from old drawing</a>[<a href="http://www.codeproject.com/Answers/194885/How-do-I-clear-a-panel-from-old-drawing#answer2" target="_blank" title="New Window">^</a>],
<a href="http://www.codeproject.com/Answers/176000/What-kind-of-playful-method-is-Paint-DataGridViewI#answer2">What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))</a>[<a href="http://www.codeproject.com/Answers/176000/What-kind-of-playful-method-is-Paint-DataGridViewI#answer2" target="_blank" title="New Window">^</a>],
<a href="http://www.codeproject.com/Answers/195499/Drawing-Lines-between-mdi-child-forms#answer3">Drawing Lines between mdi child forms</a>[<a href="http://www.codeproject.com/Answers/195499/Drawing-Lines-between-mdi-child-forms#answer3" target="_blank" title="New Window">^</a>],
<a href="http://www.codeproject.com/Answers/201863/capture-the-drawing-on-a-panel#answer1">capture the drawing on a panel</a>[<a href="http://www.codeproject.com/Answers/201863/capture-the-drawing-on-a-panel#answer1" target="_blank" title="New Window">^</a>].

Maybe even <code>PointToClient/PointToScreen won''t be needed. :-)

—SA


这篇关于901026-C#中的ClientToScreen等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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