c# - How to Display Only Minimize and Close Button on Caption Bar - Stack Overflow

1
sign up log in tour help stack overflow careers Take the 2minute tour × Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required. How to display only Minimize and Close button on caption bar I only want to display the Minimize and Close buttons on the caption bar, without the Maximize button using C#.net in WinForm Application. If I put this.MaximizeBox = false, the Maximize button is still displayed although it will be disabled. Any help will be appreciated. Please Provide me your excellent ideas Thanks in Advance. c# windows winforms controls edited Dec 24 '10 at 13:12 asked Dec 22 '10 at 14:37 SharpUrBrain 1,843 1 21 41 2 Answers What you need to do is paint your own window chrome. See this SO question for how to do so: Custom titlebars/chrome in a WinForms app answered Dec 22 '10 at 14:41 CodingGorilla 12.9k 16 42 If you don't mind losing the minimize button, you could use the forms FormBorderStyle to FixedToolWindow or SizableToolWindow. There are some side effects to this approach though (from MSDN): FixedToolWindow: A tool window border that is not resizable. A tool window does not appear in the taskbar or in the window that appears when the user presses ALT+TAB. Although forms that specify FixedToolWindow typically are not shown in the taskbar, you must also ensure that the ShowInTaskbar property is set to false, since its default value is true. SizableToolWindow: A resizable tool window border. A tool window does not appear in the taskbar or in the window that appears when the user presses ALT+TAB. You could set the control box property on the form to false (but then you lose the close button as well as the minimize button). It looks like you should also be able to use the windows API (in this link the guy is hiding the close button for a wpf app, but I would think you could repurpose it) http://winsharp93.wordpress.com/2009/07/21/wpfhidethewindowbuttonsminimizerestoreand closeandtheiconofawindow/ answered Dec 22 '10 at 16:19 Chris Clarke 11 2

description

sas

Transcript of c# - How to Display Only Minimize and Close Button on Caption Bar - Stack Overflow

  • 7/4/2015 c#HowtodisplayonlyMinimizeandClosebuttononcaptionbarStackOverflow

    http://stackoverflow.com/questions/4510250/howtodisplayonlyminimizeandclosebuttononcaptionbar 1/1

    signup login tour help stackoverflowcareers

    Takethe2minutetour StackOverflowisaquestionandanswersiteforprofessionalandenthusiastprogrammers.It's100%free,noregistrationrequired.

    HowtodisplayonlyMinimizeandClosebuttononcaptionbar

    IonlywanttodisplaytheMinimizeandClosebuttonsonthecaptionbar,withouttheMaximizebuttonusingC#.netinWinFormApplication.IfIputthis.MaximizeBox=false,theMaximizebuttonisstilldisplayedalthoughitwillbedisabled.Anyhelpwillbeappreciated.PleaseProvidemeyourexcellentideas

    ThanksinAdvance.

    c# windows winforms controls

    editedDec24'10at13:12 askedDec22'10at14:37SharpUrBrain1,843 1 21 41

    2Answers

    Whatyouneedtodoispaintyourownwindowchrome.SeethisSOquestionforhowtodoso:

    Customtitlebars/chromeinaWinFormsapp

    answeredDec22'10at14:41CodingGorilla12.9k 16 42

    Ifyoudon'tmindlosingtheminimizebutton,youcouldusetheformsFormBorderStyletoFixedToolWindoworSizableToolWindow.Therearesomesideeffectstothisapproachthough(fromMSDN):

    FixedToolWindow:Atoolwindowborderthatisnotresizable.AtoolwindowdoesnotappearinthetaskbarorinthewindowthatappearswhentheuserpressesALT+TAB.AlthoughformsthatspecifyFixedToolWindowtypicallyarenotshowninthetaskbar,youmustalsoensurethattheShowInTaskbarpropertyissettofalse,sinceitsdefaultvalueistrue.

    SizableToolWindow:Aresizabletoolwindowborder.AtoolwindowdoesnotappearinthetaskbarorinthewindowthatappearswhentheuserpressesALT+TAB.

    Youcouldsetthecontrolboxpropertyontheformtofalse(butthenyoulosetheclosebuttonaswellastheminimizebutton).

    ItlookslikeyoushouldalsobeabletousethewindowsAPI(inthislinktheguyishidingtheclosebuttonforawpfapp,butIwouldthinkyoucouldrepurposeit)http://winsharp93.wordpress.com/2009/07/21/wpfhidethewindowbuttonsminimizerestoreandcloseandtheiconofawindow/

    answeredDec22'10at16:19ChrisClarke11 2