richTextBox.DrawToBitmap Does Not Draw Containing Text?

后端 未结 6 1409
盖世英雄少女心
盖世英雄少女心 2021-01-15 14:34

If I have a richTextBox and run DrawToBitmap on it, it doesn\'t draw any of the text inside of the richTextBox.

Bitmap b = new Bitmap(rtb.Width, rtb.Height         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-15 15:21

    For what it's worth, the later version of the RichTextBox control supports the DrawToBitmap method properly; it also improves performance and has more features.

    internal class RichTextBox5: RichTextBox
    {
        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
        static extern IntPtr LoadLibrary(string lpFileName);
    
        protected override CreateParams CreateParams
        {
            get
            {
               CreateParams cparams = base.CreateParams; 
               if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
               {
                  cparams.ClassName = "RICHEDIT50W";
               }
               return cparams;
             }
        }
    }
    

提交回复
热议问题