Disable Close Button at Runtime |
Post Reply |
Author | |
pijnappel
Groupie Joined: 30 November 2007 Status: Offline Points: 13 |
Post Options
Thanks(0)
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
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
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 |
|
pijnappel
Groupie Joined: 30 November 2007 Status: Offline Points: 13 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |