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. exit, minimize, maximize buttons on the form title bar

exit, minimize, maximize buttons on the form title bar

Scheduled Pinned Locked Moved C#
tutorialquestion
4 Posts 2 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.
  • Q Offline
    Q Offline
    quiteSmart
    wrote on last edited by
    #1

    hi, how can i hide the exit, minimize and maximize buttons that appear on the top right side of the scree inside the title bar of the form. And if it is possible, also tell me how to modify the code and the action that those button do when clicked. thanks in advance jamil abou khalil

    J 1 Reply Last reply
    0
    • Q quiteSmart

      hi, how can i hide the exit, minimize and maximize buttons that appear on the top right side of the scree inside the title bar of the form. And if it is possible, also tell me how to modify the code and the action that those button do when clicked. thanks in advance jamil abou khalil

      J Offline
      J Offline
      jiugarte
      wrote on last edited by
      #2

      to remove. go to publishing Designer selects the form and change the property ControlBox to false. to intercept. public const int WM_SYSCOMMAND = 0x0112; public const int SC_CLOSE = 0xF060; protected override void WndProc(ref Message m) { if( m.Msg == WM_SYSCOMMAND) { if( (int) m.WParam.ToInt32() == SC_CLOSE ) { if (ProjectIsOpen) { return; } else { this.Close(); Application.Exit(); } } } base.WndProc (ref m); } :)

      Q J 2 Replies Last reply
      0
      • J jiugarte

        to remove. go to publishing Designer selects the form and change the property ControlBox to false. to intercept. public const int WM_SYSCOMMAND = 0x0112; public const int SC_CLOSE = 0xF060; protected override void WndProc(ref Message m) { if( m.Msg == WM_SYSCOMMAND) { if( (int) m.WParam.ToInt32() == SC_CLOSE ) { if (ProjectIsOpen) { return; } else { this.Close(); Application.Exit(); } } } base.WndProc (ref m); } :)

        Q Offline
        Q Offline
        quiteSmart
        wrote on last edited by
        #3

        hi, first thanks for your reply. second i want to ask you a more detailed question. what if i want to hide only the close button and the maximize button and keep the minimize button. The property ControlBox when set to false hides the three buttons together even if i try to set the maximizebox to true it want appear. i hope u have a solution for that. jamil abou khalil

        1 Reply Last reply
        0
        • J jiugarte

          to remove. go to publishing Designer selects the form and change the property ControlBox to false. to intercept. public const int WM_SYSCOMMAND = 0x0112; public const int SC_CLOSE = 0xF060; protected override void WndProc(ref Message m) { if( m.Msg == WM_SYSCOMMAND) { if( (int) m.WParam.ToInt32() == SC_CLOSE ) { if (ProjectIsOpen) { return; } else { this.Close(); Application.Exit(); } } } base.WndProc (ref m); } :)

          J Offline
          J Offline
          jiugarte
          wrote on last edited by
          #4

          try it. private const int SC_CLOSE = 0xF060; private const int SC_MAXIMIZE = 0xF030; private const int SC_MINIMIZE = 0xF020; private const int SC_RESTORE = 0xF120; private const int MF_GRAYED = 0x1; [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern int EnableMenuItem(IntPtr hMenu, int wIDEnableItem, int wEnable); private void Disable_opt() { EnableMenuItem(GetSystemMenu(this.Handle, false), SC_CLOSE, MF_GRAYED); EnableMenuItem(GetSystemMenu(this.Handle, false), SC_MAXIMIZE, MF_GRAYED); EnableMenuItem(GetSystemMenu(this.Handle, false), SC_MINIMIZE, MF_GRAYED); EnableMenuItem(GetSystemMenu(this.Handle, false), SC_RESTORE, MF_GRAYED); } :)

          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