Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Disable close(X) button
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Disable close(X) button

 Post Reply Post Reply
Author
Message
homaas View Drop Down
Newbie
Newbie


Joined: 26 September 2008
Location: Vietnam
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote homaas Quote  Post ReplyReply Direct Link To This Post Topic: Disable close(X) button
    Posted: 06 October 2008 at 6:07am
My app sometimes need to disable/enable the (X) button (the top-right button on screen), it worked correctly with the following code:

    HMENU hMenu = ::GetSystemMenu(m_hWnd,FALSE);
    if (hMenu)
        EnableMenuItem(hMenu,SC_CLOSE,bEnable ? MF_ENABLED : MF_GRAYED);


  But when I apply skin for this form, the close button is not enable or disable as I expected (always enable or disable).

 Plz help me,

 Thanks a lot!
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 899
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Posted: 15 October 2008 at 6:18pm

I have not used skins but I do use the command ribbon with one of the word styles. For me to disable the close icon I first have to find the control and change the update flag. I do this:
 
if (CXTPControl* pCloseControl = pRibbonBar->GetControls()->FindControl(XTP_ID_MENUBAR_CLOSE))

{

pCloseControl->SetFlags( pCloseControl->GetFlags() & ~xtpFlagManualUpdate );

}

Then I went into my OnCmdMsg handler and looked for the control with an id of XTP_ID_MENUBAR_CLOSE. Then simply set the enabled flag of the update UI object passed in.
I do the same thing you do to disable the original windows SC_CLOSE object and I get the menu item and examine its enabled/grayed state to base my setting of the flag. So you are almost there.
Back to Top
homaas View Drop Down
Newbie
Newbie


Joined: 26 September 2008
Location: Vietnam
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote homaas Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2008 at 12:51am
First, thanks rdhd,
but "Then I went into my OnCmdMsg handler and looked for the control with an id of XTP_ID_MENUBAR_CLOSE. Then simply set the enabled flag of the update UI object passed in." I don't know how to do this, can you show me how to do this task?
Thanks a lot!
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2008 at 4:36am
Hi,
 
Its not CommandBars issue :(. Its from SkinFramework.
will be fixed for 12.1 release.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.