代码如下:
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern IntPtr GetDesktopWindow();
        [DllImport("user32.dll", EntryPoint = "GetDCEx", CharSet = CharSet.Auto, ExactSpelling = true)]
        private static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int flags);        private void button1_Click(object sender, EventArgs e)
        {
            IntPtr desk = GetDesktopWindow();
            IntPtr deskDC = GetDCEx(desk,IntPtr.Zero,0x403);
            Graphics g = Graphics.FromHdc(deskDC);
            g.DrawString("Lightning",new Font("宋体",50,FontStyle.Bold),Brushes.Red,new PointF(100,100));
            
        }
在桌面直接绘图后,被其他窗体遮住,如何进行重绘,谢谢.另外高手教下如何进行桌面绘图(不是窗体),多谢

解决方案 »

  1.   

    http://www.cnblogs.com/stg609/archive/2008/03/19/1113694.html
      

  2.   

    重写Onpaint方法。重绘事件就会调用它
      

  3.   

    学习双缓冲技术,在OnPaint事件中利用双缓冲进行重绘
      

  4.   

    可以调用如下的API来重绘桌面:[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
    public static extern IntPtr GetDesktopWindow();[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
    public static extern bool RedrawWindow(IntPtr hwnd, RECT rcUpdate, IntPtr hrgnUpdate, int flags);RedrawWindow(GetDesktopWindow(), null, IntPtr.Zero, 0x85);
      

  5.   

    由于不是在窗体中绘制,所以paint事件没用,但是onpaint...查查看了.7楼的,谢谢了,但是RedrawWindow的第二个参数是什么,我这里出错,想学习这方面的知识(windows桌面绘图),请问应该学哪些东西,多谢!
      

  6.   

    是不是windows桌面绘图只有用到win32 api,老师说C#里也有相应的方法,但是忘了...望高手解答,多谢!