How to copy formsMap content into Clipboard (c#)

Within this forum we want to offer discussions all around our .NET based Map control including all .Net-language specific questions concerning calls of the xServer-API. Attention: xServer-relevant concepts can be found in further forums such as xRoute or xTour.
Post Reply
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

How to copy formsMap content into Clipboard (c#)

Post by Bernd Welter »

I tried to capture the formsMap content into the WIndows Clipboard via C# programming. Here's how I succeeded:

Code: Select all

private void btnMap2Clipboard_Click(object sender, EventArgs e)
{
    Bitmap bitmap = new Bitmap(formsMap1.Width, formsMap1.Height);
    formsMap1.DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
    Clipboard.SetImage(bitmap);
}
:!: Be aware that this approach copies not only the map itself but also all control connected "subcontrols" such as
  • Zoom slider
  • Magnifier
  • Coordinates...
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
Post Reply