Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Event for the release of a menu item

Event for the release of a menu item

Scheduled Pinned Locked Moved C#
helpquestionannouncement
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    manustone
    wrote on last edited by
    #1

    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

    L D W A 4 Replies Last reply
    0
    • M manustone

      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

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      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).


      M 1 Reply Last reply
      0
      • M manustone

        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

        D Offline
        D Offline
        Dr Walt Fair PE
        wrote on last edited by
        #3

        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's Click event, then check it in the parent's DropDownClosed 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

        M 1 Reply Last reply
        0
        • M manustone

          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

          W Offline
          W Offline
          William Winner
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • M manustone

            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

            A Offline
            A Offline
            AspDotNetDev
            wrote on last edited by
            #5

            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.

            [Forum Guidelines]

            1 Reply Last reply
            0
            • L Luc Pattyn

              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).


              M Offline
              M Offline
              manustone
              wrote on last edited by
              #6

              Thanks! Simple solution that works nice. It is true..i was not able to find such event AFG

              L 1 Reply Last reply
              0
              • D Dr Walt Fair PE

                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's Click event, then check it in the parent's DropDownClosed 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

                M Offline
                M Offline
                manustone
                wrote on last edited by
                #7

                Yes and it doesn't work. I solved doing the screenshot 50 ms after the click.

                1 Reply Last reply
                0
                • M manustone

                  Thanks! Simple solution that works nice. It is true..i was not able to find such event AFG

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  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).


                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups