Reputation: 263
I have some map control and when I clicked on it, I open contextMenuStrip and then clicked for the snapshot of my map. Problem is that when I click for the snapshot, it's snapshot map including contextMenuStrip. I try with, "contextMenuStrip.Close()" but not work.
//on map click event
private void map1_Click(MouseEventArgs e)
{
System.Drawing.Point point = new System.Drawing.Point(e.X, e.Y + 160);
contextMenu.Show(this.contextMenu, point);
}
//item of contextMenu
private void contextMenuConvert_Click(object sender, EventArgs e)
{
contextMenu.Close();
map.CreateImage(ImageFormat.Jpeg);
}
Upvotes: 1
Views: 903
Reputation: 10327
Instead of trying to take a snapshot of the screen (which I'm assuming you're doing), can you add code to your map object that allows it to render itself to an off-screen Image? That way, the caller can save that Image to a file or do whatever else it wants to with it. You'll be able to reuse nearly all the current rendering code with some slight tweaks to support the idea of off-screen rendering.
Upvotes: 0
Reputation: 510
That just sends a message which is queued. If you want to make sure it is actually done use Application.DoEvents() between the Close call and the CreateImage call.
Upvotes: 2