Event for the release of a menu item
-
Hi All I did a function for doing a screenshot of the WinForm application I am doing now. This function is run when the user click on a item of the main menu of the form ( MenuStrip ). The point is that in doing this way the screenshot foo is called with the menu still open so the image includes also the open menu; because of this I need to call the function right after the menu item gets close. Do you know what could be the event? I tried Drop DropDownClosed but it doesn't work. Do you know what event fit my issue? Thank you very much. Regards Mn
-
Hi All I did a function for doing a screenshot of the WinForm application I am doing now. This function is run when the user click on a item of the main menu of the form ( MenuStrip ). The point is that in doing this way the screenshot foo is called with the menu still open so the image includes also the open menu; because of this I need to call the function right after the menu item gets close. Do you know what could be the event? I tried Drop DropDownClosed but it doesn't work. Do you know what event fit my issue? Thank you very much. Regards Mn
AFAIK there is no such event. What happens if you wait 50 msec before taking the snapshot? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
Hi All I did a function for doing a screenshot of the WinForm application I am doing now. This function is run when the user click on a item of the main menu of the form ( MenuStrip ). The point is that in doing this way the screenshot foo is called with the menu still open so the image includes also the open menu; because of this I need to call the function right after the menu item gets close. Do you know what could be the event? I tried Drop DropDownClosed but it doesn't work. Do you know what event fit my issue? Thank you very much. Regards Mn
Have you tried using the
DropDownClosed
event for the parent of the menu item in question? I'd probably set a flag in the item'sClick
event, then check it in the parent'sDropDownClosed
event and do your screen capture after the drop down menu has closed.CQ de W5ALT
Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software
-
Hi All I did a function for doing a screenshot of the WinForm application I am doing now. This function is run when the user click on a item of the main menu of the form ( MenuStrip ). The point is that in doing this way the screenshot foo is called with the menu still open so the image includes also the open menu; because of this I need to call the function right after the menu item gets close. Do you know what could be the event? I tried Drop DropDownClosed but it doesn't work. Do you know what event fit my issue? Thank you very much. Regards Mn
I'm a little confused. You say
manustone wrote:
The point is that in doing this way ... the image includes also the open menu;
Then you say
manustone wrote:
I need to call the function right after the menu item gets close
If you take the screenshot right after the menu is closed, how will the screenshot have the menu opened? Which do you want? Do you want the screenshot with the menu open or without the menu? If you want to include the menu in the screenshot, I would create the image during the MouseDown and then save it during the Item_Click like so:
private Bitmap bmpScreenShot;
private Graphics gfxScreenShot;private void takeScreenshotToolStripMenuItem_Click(object sender, EventArgs e)
{
bmpScreenShot.Save(@"D:\temp\screenshot.png", System.Drawing.Imaging.ImageFormat.Png);
}private void takeScreenshotToolStripMenuItem_MouseDown(object sender, MouseEventArgs e)
{
bmpScreenShot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);gfxScreenShot = Graphics.FromImage(bmpScreenShot); gfxScreenShot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
}
If, however, you're trying to do something after the menu is closed, you could handle its parents DropDownClosed event.
-
Hi All I did a function for doing a screenshot of the WinForm application I am doing now. This function is run when the user click on a item of the main menu of the form ( MenuStrip ). The point is that in doing this way the screenshot foo is called with the menu still open so the image includes also the open menu; because of this I need to call the function right after the menu item gets close. Do you know what could be the event? I tried Drop DropDownClosed but it doesn't work. Do you know what event fit my issue? Thank you very much. Regards Mn
So, the screenshot captures the drop down and you want to find a way to get the screenshot without the dropdown? But you want it to be taken right after an item in the drop down is captured? Perhaps you could try doing a Refresh() on the form to force it to redraw itself and then perform the screen capture. You might also initiate an asyncronous event via this.BeginInvoke and have that event take the screen capture.
-
AFAIK there is no such event. What happens if you wait 50 msec before taking the snapshot? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
Have you tried using the
DropDownClosed
event for the parent of the menu item in question? I'd probably set a flag in the item'sClick
event, then check it in the parent'sDropDownClosed
event and do your screen capture after the drop down menu has closed.CQ de W5ALT
Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software
-
Thanks! Simple solution that works nice. It is true..i was not able to find such event AFG
you're welcome. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).