CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2004
    Location
    India , Chennai
    Posts
    90

    Replace Title/Caption bar min,max,close buttons

    Actually i want to place my own bitmap instead of windows xp default close button bitmap.

    -> How can i Replace Default Close button without disabling SYS_MENU property ( or )
    -> how can i hide the close button in the title bar without changing the System Menu property.

    Thanks in Advance

  2. #2
    Join Date
    Jun 2005
    Location
    Chennai , India
    Posts
    1,375

    Thumbs up Re: Replace Title/Caption bar min,max,close buttons

    Quote Originally Posted by venkatapathiraju_t
    Actually i want to place my own bitmap instead of windows xp default close button bitmap.

    -> How can i Replace Default Close button without disabling SYS_MENU property ( or )
    -> how can i hide the close button in the title bar without changing the System Menu property.

    Thanks in Advance
    I guess you can't hide it, but you can disable it by disabling the SC_CLOSE item in the system menu for the window.
    Code:
    EnableMenuItem (hMenu, SC_CLOSE, MF_GRAYED);
    It takes seconds for rating…that actually compensates the minutes taken for giving answers
    The biggest guru-mantra is: Never share your secrets with anybody. It will destroy you.
    Regards, Be generous->Rate people
    Jayender!!

  3. #3
    Join Date
    Sep 2004
    Location
    India , Chennai
    Posts
    90

    Re: Replace Title/Caption bar min,max,close buttons

    EnableMenuItem disables the close button, but i want to replace close button[X] image with my own bitmap, something like skin based applications.

  4. #4
    Join Date
    Aug 2004
    Location
    Bucharest, Romania... sometimes
    Posts
    1,039

    Re: Replace Title/Caption bar min,max,close buttons

    Override OnEraseBkgnd or process WM_ERASEBKGND to draw your own caption using DrawCaption(), and repainting the buttons as you like.
    Process WM_NC* (non-client messages), or in MFC, override OnNc* (non-client overrides).
    Removing WS_SYSMENU style will remove the close button, but also the system menu of that window.
    Disabling close button can be achieved with:
    ModifyMenu(hMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED, SC_CLOSE, "Close");
    Removing it can be achieved with:
    RemoveMenu(hMenu,SC_CLOSE,MF_BYCOMMAND);
    Regards,
    Bogdan Apostol
    ESRI Developer Network

    Compilers demystified - Function pointers in Visual Basic 6.0
    Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.

    Customize your R2H
    The unofficial board dedicated to ASUS R2H UMPC owners.

  5. #5
    Join Date
    Jun 2005
    Location
    Tirunelveli-Tamil Nadu-India
    Posts
    354

    Smile Re: Replace Title/Caption bar min,max,close buttons

    use this code to disable the close button and remove the close menu in the dialog box(click on the left top of the dialog box).

    Code:
    BOOL bEnable = TRUE;    
    UINT menuf = bEnable ? (MF_BYCOMMAND) : (MF_BYCOMMAND | MF_GRAYED | MF_DISABLED);
    CMenu* pSM = GetSystemMenu(FALSE);
    if(pSM)
    {
    	pSM->RemoveMenu(SC_CLOSE,menuf);
    }
    If I Helped You, "Rate This Post"

    Thanks
    Guna

  6. #6
    Join Date
    Sep 2004
    Location
    India , Chennai
    Posts
    90

    Re: Replace Title/Caption bar min,max,close buttons

    I want to disable the close button only (not close menu).
    I want to have the close menu in the dialog box.

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