0

I'm trying to make an image file from a control using CopyFromScreen, and it fails unless I set the scale to 100%. With a larger scale the image is progressively offset left and up, the further right and down the window is on the screen. (Unfortunately my eyes struggle at 100%)

I initially tried using DrawToBitmap but that fails as there's a rich text box in the control and it's documented that that won't paint.

I've read articles on this forum and followed the suggestion of including the dpiAware setting in the manifest, but that has no effect. I'm no expert and I'm wondering if it's because I only have VS 2012 and my manifest declaration starts with asmv1 rather than asmv3 so I had to amend the example code?

Any suggestions most welcome.

ad absurdum
  • 19,498
  • 5
  • 37
  • 60
  • Does this answer your question? [Creating a DPI-Aware Application](https://stackoverflow.com/questions/4075802/creating-a-dpi-aware-application) – Alejandro Feb 18 '21 at 19:28
  • [Visual Studio Community Edition](https://visualstudio.microsoft.com/downloads/) is a free download. -- a `DrawToBitmap()` *replacement* that renders the content of RichTextBox controls and nested containers in correct order [here](https://stackoverflow.com/a/57309095/7444103). Note that, as described in the notes, to make use of the `DeviceDpi` values you need at least -Net Framework 4.7+ (actually 4.8). -- You have to design at 100%. – Jimi Feb 18 '21 at 19:38
  • @Jimi What has that to do with this question? – Alejandro Feb 18 '21 at 19:39
  • @Alejandro *I only have VS 2012* => doesn't need to be that way (do you want to work in Windows 10, DpiAwareness included, as it's meant to be?). -- *...DrawToBitmap fails as there's a RichTextBox...* => `DrawToBitmap()` replacement. + A suggestion: *You have to design at 100%* & .Net Framework min requirements (to make it work properly). – Jimi Feb 18 '21 at 19:43
  • Thanks for the quick replies.Some good ideas at that link and I may try the community edition too. Many thanks – Shaun L Feb 18 '21 at 19:53
  • Since you have to design at 100%, note that the VS Environment is completely customizable: e.g, you can set a Font size that makes the interface more readable, change the Colors used to highlight keywords and the code editor has a quick tool to rescale the text content, on the lower bottom-left side of each editor pane. See the available Options in this department. – Jimi Feb 18 '21 at 19:59
  • Hi Jimi. Big thank you for the advice. I installed the community edition last night and this morning did the initial design with scale at 100% and copyfromscreen for a Table layout panel containing rich text edits now works perfectly at any scale! Really appreciate the help. I may actually make some progress today ! – Shaun L Feb 19 '21 at 07:20

0 Answers0