问题一:请问我使用Graphics的 DrawLine画线,目前已经实现从一个form的顶部一直画到底部。但是,如果中间遇到控件就会被遮住。如何让所画的线在所有控件之上???问题二:请问,我用Graphics的 DrawString属性写字,如何实现输出的字是竖排的。而不是普通的横排?????

解决方案 »

  1.   

    答1:
        在屏幕绘制
    答2:
       StringFormat Sform = new StringFormat();
       Sform.FormatFlags = StringFormatFlags.DirectionVertical;   g.DrawString(m_Content, m_Font, new SolidBrush(PenColor), Pos.X, Pos.Y, Sform);
      

  2.   

    你可以用如下的代码在窗体上画线而不会被其它控件挡住:
    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);
      

  3.   

    让控件挡住是正常的,除非画图的操作是在整个Windows的.可以参见GetWindowDC,通过GetWindowDC可以建立一个对整个窗体起做用的画图设置,然后通过Graphics.FromHDC()来建立一个Graphics,这样就不会有挡住的情况了.
      

  4.   

    比如如下的代码就可以在窗体上画一个在任何子控件之上的图(线):
    [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);
    }