画线c#(MDIParents) [英] drawing lines c# ( MDIParents)

查看:80
本文介绍了画线c#(MDIParents)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在MDIParents上画一条线??????

解决方案

感谢谢尔盖让我想起MDIParentForm的特殊性!



一旦你有一个有效的MdiClient表格参考...这在设计时是不可见的......如本(2014年1月3日)QA答案所示:[ ^ ]:



1.您可以使用Paint EventHandler在其上绘制线条,如OriginalGriff的代码所示:[ ^ ]。



2.或者,设置其BackgroundImage,我建议:[ ^ ]。



MdiClient是一个Form,并且不需要特殊的API调用来使用它的Paint事件,或者设置它的返回groundImage。



但是,请记住我在引用的关于为MdiParent表单定义Click EventHandler的问题的答案中所说的注意事项:使用MdiClient是一种黑客攻击除非绝对必要,否则我会避免使用它。


这是可能的,但非常困难。而且,我非常确定:使用纯 System.Windows.Forms ;这是不可能的。您需要使用P / Invoke(这将极大地损害您的代码的平台兼容性)。



一些背景:在幕后(并且在.NET FCL的功能之后),有一个与MDI子项一起使用的中间窗口。此窗口是MDI父级的子级,称为MDI客户端,其句柄不向.NET用户公开。您需要使用原始Windows API访问此窗口,使用 Form 包装器将其转换为对表单的引用并对其进行操作(或直接使用原始Windows API对其进行操作)。



我认真地建议你放弃这种适得其反的,毫无结果的想法。它会花费你的时间,并会给你相当难看的结果。为什么要打扰?以下是这个想法:谁需要MDI?为什么要折磨自己并吓跑你的用户?

帮自己一个大忙:根本不要使用MDI。没有它,您可以更轻松地实现设计,质量更好。 MDI甚至被微软高度劝阻,事实上,微软将其从WPF中删除并且很难支持它。更重要的是,如果您使用MDI,您将吓跑所有用户。只是不要。请参阅:

http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages [ ^ ],

如何在WPF中创建MDI父窗口? [ ^ ]。



我可以解释做什么。请看我过去的答案:

如何在WPF中创建MDI父窗口? [解决方案2 ],

关于在WPF中使用MDI窗口的问题 [ ^ ],

麦当劳给出错误 [ ^ ],

如何设置子窗体最大化,最后一个子窗体最小化 [ ^ ]。



-SA

how i draw a line on MDIParents??????

解决方案

Thanks to Sergey for reminding me of the special nature of the MDIParentForm !

Once you have a valid reference to the MdiClient Form ... which is not visible at design-time ... as shown in this (Jan. 3, 2014) QA answer: [^]:

1. You can draw lines on it using the Paint EventHandler, as shown by OriginalGriff's code: [^].

2. or, set its BackgroundImage, as I suggested in: [^].

The MdiClient is a Form, and no special API calls are needed to use its Paint Event, or set its BackgroundImage.

However, please keep in mind the cautions I stated in the cited answer to the question on defining a Click EventHandler for an MdiParent Form: that using the MdiClient is a kind of hack. I would avoid using it unless absolutely necessary.


This is possible but quite difficult. Moreover, I'm pretty much sure: this is impossible to do by using pure System.Windows.Forms; you would need to use P/Invoke (which will greatly compromise the platform compatibility of your code).

Some background: behind the scene (and behind the capabilities of .NET FCL), there is an intermediate window which works with MDI children. This window is a child of the MDI parent, is called "MDI client" and its handle is not exposed to a .NET user. You would need to access this window using raw Windows API, turn it a reference to a form using the Form wrapper and manipulate it (or manipulate it using raw Windows API directly).

I seriously advise you to abandon this counter-productive and fruitless idea. It will take your time and will give you quite ugly results. Why bothering? Here is the idea: who needs MDI, ever? Why torturing yourself and scaring off your users?
Do yourself a great favor: do not use MDI at all. You can do much easier to implement design without it, with much better quality. MDI is highly discouraged even by Microsoft, in fact, Microsoft dropped it out of WPF and will hardly support it. More importantly, you will scare off all your users if you use MDI. Just don't. Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
How to Create MDI Parent Window in WPF?[^].

I can explain what to do instead. Please see my past answers:
How to Create MDI Parent Window in WPF? [Solution 2],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to set child forms maximized, last childform minimized[^].

—SA


这篇关于画线c#(MDIParents)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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