咨询两个关于Graphics画图的问题 问题一:请问我使用Graphics的 DrawLine画线,目前已经实现从一个form的顶部一直画到底部。但是,如果中间遇到控件就会被遮住。如何让所画的线在所有控件之上???问题二:请问,我用Graphics的 DrawString属性写字,如何实现输出的字是竖排的。而不是普通的横排????? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 答1: 在屏幕绘制答2: StringFormat Sform = new StringFormat(); Sform.FormatFlags = StringFormatFlags.DirectionVertical; g.DrawString(m_Content, m_Font, new SolidBrush(PenColor), Pos.X, Pos.Y, Sform); 你可以用如下的代码在窗体上画线而不会被其它控件挡住:Point start = this.PointToScreen(new Point(0, 0));Point end = this.PointToScreen(new Point(this.ClientRectangle.Width, this.ClientRectangle.Height));ControlPaint.DrawReversibleLine(start, end, Color.Black); 让控件挡住是正常的,除非画图的操作是在整个Windows的.可以参见GetWindowDC,通过GetWindowDC可以建立一个对整个窗体起做用的画图设置,然后通过Graphics.FromHDC()来建立一个Graphics,这样就不会有挡住的情况了. 比如如下的代码就可以在窗体上画一个在任何子控件之上的图(线):[DllImport("user32.dll", EntryPoint = "GetWindowDC", CharSet = CharSet.Auto, ExactSpelling = true)]private static extern IntPtr GetWindowDC(IntPtr hWnd);private void button3_Click(object sender, EventArgs e){ Graphics g = Graphics.FromHdc(GetWindowDC(this.Handle)); g.DrawLine(SystemPens.ControlText, 0, 0, this.Width, this.Height);} 为什么实现不了删除功能 如何自由拼运算式啊 基于Socket编写C/S ERP恩路问题 电脑发手机短信问题 汗……问一个关于第三方dll的怪问题,进来有分 ++++++++++++如何利用sql存储过程,删除一条符合条件的数据记录??? "未将对象引用设置到对象的实例"这错误是什么意思? 关于reporting service的问题 null和""是否相同 新手 c++ 结构 与 C# 互转 求一正则表达式,两行字符串,将不同的字符列出来,如: RequiredFieldValidator控件的使用问题
在屏幕绘制
答2:
StringFormat Sform = new StringFormat();
Sform.FormatFlags = StringFormatFlags.DirectionVertical; g.DrawString(m_Content, m_Font, new SolidBrush(PenColor), Pos.X, Pos.Y, Sform);
Point start = this.PointToScreen(new Point(0, 0));
Point end = this.PointToScreen(new Point(this.ClientRectangle.Width, this.ClientRectangle.Height));
ControlPaint.DrawReversibleLine(start, end, Color.Black);
[DllImport("user32.dll", EntryPoint = "GetWindowDC", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern IntPtr GetWindowDC(IntPtr hWnd);private void button3_Click(object sender, EventArgs e)
{
Graphics g = Graphics.FromHdc(GetWindowDC(this.Handle));
g.DrawLine(SystemPens.ControlText, 0, 0, this.Width, this.Height);
}