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. Minimize button event

Minimize button event

Scheduled Pinned Locked Moved C#
helpquestioncsharp
3 Posts 3 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.
  • N Offline
    N Offline
    ngensys
    wrote on last edited by
    #1

    Hi guys, Does anyone know how I can capture the event when a user clicks the Minimize button on the control box in C#? I want to issue a warning messagebox when they click on it. And why does the message box show nothing on it, even though I have set all the parameters in the messagebox function properly? There are nothing on it except an empty button with no caption. Please help...:confused:

    S B 2 Replies Last reply
    0
    • N ngensys

      Hi guys, Does anyone know how I can capture the event when a user clicks the Minimize button on the control box in C#? I want to issue a warning messagebox when they click on it. And why does the message box show nothing on it, even though I have set all the parameters in the messagebox function properly? There are nothing on it except an empty button with no caption. Please help...:confused:

      S Offline
      S Offline
      Stanciu Vlad
      wrote on last edited by
      #2

      In order to catch the minimize event of an window you moust intercet the WM_SYSCOMMAND message and check that the WParam is SC_MINIMIZE. How can you do this? Simple, override the WndProc of your form :

      protected override void WndProc(ref Message m)
      {
      if(m.Msg == 0x112) // if WM_SYSCOMMAND
      {
      if(m.WParam.ToInt32() == 0xf020) //if SC_MINIMIZE
      {
      // process here what you want
      return; // if you want to not to minimize, or call base.WndProc (ref m) if you do not
      }
      }

      base.WndProc (ref m);
      

      }

      I hope you understand...because is a rough world out there...

      1 Reply Last reply
      0
      • N ngensys

        Hi guys, Does anyone know how I can capture the event when a user clicks the Minimize button on the control box in C#? I want to issue a warning messagebox when they click on it. And why does the message box show nothing on it, even though I have set all the parameters in the messagebox function properly? There are nothing on it except an empty button with no caption. Please help...:confused:

        B Offline
        B Offline
        Bojan Rajkovic
        wrote on last edited by
        #3

        Hook the Resized event of the form and then check that the WindowState is equal to FormWindowState.Minimized. If it is, issue your messagebox and do anything else that you want to.

        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