Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Skin Framework
  New Posts New Posts RSS Feed - Disable Close Button at Runtime
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Disable Close Button at Runtime

 Post Reply Post Reply
Author
Message
pijnappel View Drop Down
Groupie
Groupie


Joined: 30 November 2007
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote pijnappel Quote  Post ReplyReply Direct Link To This Post Topic: Disable Close Button at Runtime
    Posted: 22 January 2008 at 10:32am
I'm trying to disable the Close Button of the window frame in runtime using the following code:
 

void EnableCloseButton(BOOL bEnable)

{

UINT menuf = bEnable ? (MF_BYCOMMAND) : (MF_BYCOMMAND |

MF_GRAYED | MF_DISABLED);

CMenu* pSM = GetSystemMenu(FALSE);

if(pSM)

{

pSM->EnableMenuItem(SC_CLOSE, menuf);

}

}
 
 
I call this function on a button click. It works for a dialog based test application. In my application project based on CXTPDialogBase<CXTResizeDialog> the button is not disabled. When I maximize it the new style i applied to the button.
 
Is there a workaround for this problem?
Thanks,
 
Timo
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: 22 January 2008 at 3:40pm
Hi,
 
Try call
 
SetWindowPos(0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_DRAWFRAME);
after.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
pijnappel View Drop Down
Groupie
Groupie


Joined: 30 November 2007
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote pijnappel Quote  Post ReplyReply Direct Link To This Post Posted: 23 January 2008 at 2:10am
That didn't work, but based on your answer I found the solution myself. I had to change the Window Style and then change it back to the old state to refresh the buttons. I chose the maximize button:
 
AfxGetMainWnd()->ModifyStyle(WS_MAXIMIZEBOX, 0, SWP_FRAMECHANGED);
AfxGetMainWnd()->ModifyStyle(0, WS_MAXIMIZEBOX, SWP_FRAMECHANGED);
 
Regards
 
Timo
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.250 seconds.