Print Page | Close Window

Disable Close Button at Runtime

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Skin Framework
Forum Description: Topics Related to Codejock Skin Framework
URL: http://forum.codejock.com/forum_posts.asp?TID=9384
Printed Date: 28 September 2024 at 3:34pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Disable Close Button at Runtime
Posted By: pijnappel
Subject: Disable Close Button at Runtime
Date 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



Replies:
Posted By: Oleg
Date 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


Posted By: pijnappel
Date 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



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