Print Page | Close Window

Remove close button from system menu

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=9242
Printed Date: 14 November 2025 at 7:17pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Remove close button from system menu
Posted By: Gonzo
Subject: Remove close button from system menu
Date Posted: 07 January 2008 at 5:15pm
I am currently using Office2007 theme with

CXTPDialogBase<CXTResizeDialog> and CXTPOffice2007FrameHook

I am trying to get rid of the close button in the system menu which is usually done like this; however, this does not seem to work. Any suggestions?

    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
        pSysMenu->RemoveMenu(SC_CLOSE,MF_BYCOMMAND);



Replies:
Posted By: Oleg
Date Posted: 08 January 2008 at 1:50am

HI,

You can remove whole sysmenu : remove style WS_SYSMENU


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Gonzo
Date Posted: 08 January 2008 at 9:15am
Hi,

I don't want to remove the whole system menu. I would just like to disable or remove the close button.


Posted By: Oleg
Date Posted: 08 January 2008 at 3:11pm
Hi,
 
to disable you can set MF_DISABLED state for SC_CLOSE command.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Gonzo
Date Posted: 08 January 2008 at 7:20pm
Hi,

The above solution functions as long as I do not have "EnableOffice2007Frame(pCommandBars)" in my code. I would like to maintain this frame for my look and feel. Here is a little more code to debug the problem.

#define CDialogDlgBase CXTPDialogBase<CXTResizeDialog>

BOOL CMyApp::OnInitDialog()
{
    CDialogDlgBase::OnInitDialog();

    // Init the menus

    VERIFY(InitCommandBars());

    CXTPCommandBars* pCommandBars = GetCommandBars();

    LoadCommandBars(_T("CommandBars"));

    // Set the Office 2007 theme

    CXTPPaintManager::SetCustomTheme(new    CXTPOffice2007Theme());
    EnableOffice2007Frame(pCommandBars);
    pCommandBars->RedrawCommandBars();

    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
        pSysMenu->EnableMenuItem(SC_CLOSE, MF_DISABLED);

     return TRUE;
}


Posted By: Oleg
Date Posted: 10 January 2008 at 11:51am
Hello,
It works for me.
Maybe your have older version and it was added after.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net