Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
240
Print form with labels and editors
posted

I want to print the controls on a form. For that I have a panel on my form that have all necessary controls in the container. For this panel and for the controls in the controls collection I call recursive a print method in that I print the control to a bitmap.

-- definition
      static MethodInfo invokePaintInfo = typeof(Control).GetMethod("InvokePaint",
         BindingFlags.Instance | BindingFlags.NonPublic);

-- th call
invokePaintInfo.Invoke(control, paintArgs);
 
It works and it paints the control to the bitmap and I can print the bitmap. On Windows 7 I have the problem that with ‘Performance Options: Smooth edges of screen fonts’ the printed fonts are very bad. I found out that when I change UseOsThemes from Default to False

ctrl..UseOsThemes = DefaultableBoolean.False;

it works better. But now I have the problem that the border is not printed on the TextEditor Controls. For  UltraLabel it’s works.


Is their a better way to solve the problem?

Thanks

Parents
No Data
Reply
  • 48586
    Verified Answer
    posted

    Hello ,

     

    UseOsThemes indicates whether the elements of a control may be rendered using the operating system theme rendering. Maybe better approach is to draw what is already drawn on the screen to a bitmap. GDI has the BitBlt function which allows C# developers to do that efficiently. The BitBlt function is located in the GDI32.dll.

     

    I have created a small sample in order to demonstrate this approach. Please run the sample and press “Capture TextBox” in order to get bitmap of UltraTextEditor and to display it in the PictureBox.

     

    Please let me know if you have any further questions.

    WindowsFormsApplication50.zip
Children