901026-C#中的ClientToScreen等效项 [英] 901026 - ClientToScreen equivalent in C#
问题描述
我怎样才能做到这一点?我认为第一步是找到一种方法来找到屏幕上图片框的位置.我该怎么办?
thx
您始终可以使用System.Windows.Forms.Control.PointToClient
,System.Windows.Forms.Control.PointToScreen
,http://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 useSystem.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 usePictureBox
? 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屋!