CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14
  1. #1
    Join Date
    Jun 2001
    Posts
    25

    How to remove close button?

    I'm trying to remove the close button from the top right of my dialog with no luck. I want to keep the icon on the top right of the window and I don't want to just disable the close button, I need to remove it. Is there any way of doing this? I can't find a solution anywhere.

    Thanks.
    Dan.


  2. #2
    Join Date
    Jun 2001
    Posts
    25

    Re: How to remove close button?

    That should read "icon on the top left of the window"

    Dan.



  3. #3
    Join Date
    Jul 2001
    Location
    Florida, USA
    Posts
    107

    Re: How to remove close button?

    Uncheck the System Menu box under the Style tab of the properties of your dialog box.


  4. #4
    Join Date
    Jun 2001
    Posts
    25

    Re: How to remove close button?

    That doesn't work. It removes the icon from the top left. I need to keep the icon.

    Dan.


  5. #5
    Join Date
    Oct 2000
    Location
    India
    Posts
    4,620

    Re: How to remove close button?

    Hi,

    Use this code.
    CMenu *pMenu = GetSystemMenu(FALSE);

    // To disable the close icon and the system close menu
    pMenu->DeleteMenu(SC_CLOSE,MF_BYCOMMAND);

    All Luck.

    http://www.geocities.com/contactgirish/homepage.html >>> VC++ Links, Code, Downloads & Notes.
    All luck and have a great day.

    Regards,
    V.Girish

    Visit www.geocities.com/contactgirish for Source code, Tutorials, FAQs and Downloads.

  6. #6
    Join Date
    Jun 2001
    Posts
    25

    Re: How to remove close button?

    That doesn't work either. It only disables the button. I need to remove it.

    Dan.


  7. #7
    Join Date
    Dec 2001
    Posts
    1

    Re: How to remove close button?

    ModifyStyle( WS_SYSMENU, 0, 0 );


  8. #8
    Join Date
    May 2001
    Location
    Toronto
    Posts
    85

    Re: How to remove close button?

    In Resource editor, open Dialog property dialog,
    in "Styles" tab, uncheck out "System Menu".


    HI, :-)....
    Nice to meet u.
    If i am senseless and i could answer your question, i will.

  9. #9
    Join Date
    Sep 2003
    Location
    M...N
    Posts
    220
    The key point is keeping the icon on.

    It seems there is no solution to remove "X" (close button) while keeping the icon.....

    None of the above solution work.


  10. #10
    Join Date
    Nov 2002
    Location
    Los Angeles, California
    Posts
    3,863
    Well there may be an easier way, but I am not aware of it.
    Follow VGirish's suggestion and then handle the WM_NCPAINT
    message and paint the caption yourself including the sysmenu
    icon, but don't paint the close button.
    Wakeup in the morning and kick the day in the teeth!! Or something like that.

    "i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."

  11. #11
    Join Date
    Nov 2003
    Location
    Central Florida
    Posts
    44
    There's no magic solution that will keep the system menu but remove the X button; you'll have to do what souldog suggests and owner-draw the title bar. Its not too difficult, really; just a nuisance.
    But... but... I'll set the building on fire.

    How many keys do YOU press?

  12. #12
    Join Date
    Feb 2000
    Posts
    13

    Wink

    wndclass.style = CS_HREDRAW | CS_VREDRAW ;//| CS_NOCLOSE
    wndclass.lpfnWndProc = WndProc;
    wndclass.cbClsExtra = 0 ;
    wndclass.cbWndExtra = 0 ;
    wndclass.hInstance = hInstance ;
    wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
    wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
    wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
    wndclass.lpszMenuName = NULL ;
    wndclass.lpszClassName = szAppName ;

    if (!RegisterClass (&wndclass))

  13. #13
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917
    Originally posted by souldog
    Well there may be an easier way
    You are right. Unfortunately, there is no easier way and VGirish (Hi VGirish) solution is the only one that will achieve desired results.
    I wish one day responders would test answers before posting
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  14. #14
    Join Date
    Sep 2004
    Posts
    1

    Re: How to remove close button?

    Why dont you set the form style so that both the icon and close button are not visible, then BitBlt the icon and caption text onto the caption of the form. This is possible in VB so it MUST be possible in C++

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured