I try to save the content of a simple RadForm to a Bitmap.The non client area of the form is not drawn at all (transparent value). If I disable Theming, it works.
Here is the code I used :
var form = newRadForm1();
//form.AllowTheming = false; --> Works is Theming is disabled ! Otherwise no.
var rect = newRectangle(0, 0, form.Bounds.Width, form.Bounds.Height);
var image = newBitmap(rect.Width, rect.Height);
How can I force the drawing of the NC area of the form ?
3 Answers, 1 is accepted
answered on 18 Jun 2018, 08:32 AM
The DrawToBitmap method comes from .NET and we do not have control over what is drawn. In this case, you can create your own method that saves a screenshot of the window. An example is available in the following post: c# - Get a screenshot of a specific application. Check the second answer and use the code from it. I have tested it on my side and it captures the entire form.
I hope this will be useful. Let me know if you have additional questions.
Thanks for your answer and the link but I would like to avoid doing a screenshot because of some other reasons (some side effects in our test pipeline)
How do you explain that the theme is correctly applied to the client area of the form. Do you guys intercept and implement WM_PRINT messages for NC areas ? (https://msdn.microsoft.com/fr-fr/library/windows/desktop/dd145216(v=vs.85).aspx)
No, the WM_PRINT message is not causing this. We are intercepting the most of the NC area messages (WM_NCUAHDRAWCAPTION, WM_NCUAHDRAWFRAME, WM_NCPAINT, WM_NCCALCSIZE) and performing various actions instead of painting the default NC area.
Could you share more inforation about your exact case? Why do you need such functionality (taking image on NC area)?
The suggested solution uses a similar to the DrawToBitmap method code. However is just gets the screen rectangle. Why exactly is it not possible to use it? I have attached a small example that shows how you can use this approach.