Disabling Restore button of a window
-
Hi I am dyanamically creating a class inherited from CScrollView. The restore button of this view should be disabled so that the user may not be able to click on it. Please help me. Thanks and regards Deepu.
-
Hi I am dyanamically creating a class inherited from CScrollView. The restore button of this view should be disabled so that the user may not be able to click on it. Please help me. Thanks and regards Deepu.
-
You can use the EnableWindow Function[^] to disable input on the button. Best Wishes, -David Delaune
I have dynamically created the window.Now I want to disable/remove the Restore button ie (Minimize,Maximize ,Close) of the window title bar. I wish to disable/remove the restore button so that the user cannot resize the window. The window should be in maximized state intially and if user want,he can minimize it ,but window should not be resized. please help me
-
I have dynamically created the window.Now I want to disable/remove the Restore button ie (Minimize,Maximize ,Close) of the window title bar. I wish to disable/remove the restore button so that the user cannot resize the window. The window should be in maximized state intially and if user want,he can minimize it ,but window should not be resized. please help me
Hi,
Deepu Antony wrote:
I have dynamically created the window.Now I want to disable/remove the Restore button
For making non-sizable MDI window and removing maximize button:
//In your OnCreate() WM_CREATE handler CWnd *pParent = GetParent(); CMenu* pMenu = pParent->GetSystemMenu(FALSE); if (NULL != pMenu) { pParent->ModifyStyle(WS_CAPTION|WS_MAXIMIZEBOX ,0,0); pParent->ModifyStyle(WS_THICKFRAME, 0, 0); pParent->ModifyStyle(0,WS_CAPTION,SWP_FRAMECHANGED); }
Best Wishes, -David Delaune -
Hi,
Deepu Antony wrote:
I have dynamically created the window.Now I want to disable/remove the Restore button
For making non-sizable MDI window and removing maximize button:
//In your OnCreate() WM_CREATE handler CWnd *pParent = GetParent(); CMenu* pMenu = pParent->GetSystemMenu(FALSE); if (NULL != pMenu) { pParent->ModifyStyle(WS_CAPTION|WS_MAXIMIZEBOX ,0,0); pParent->ModifyStyle(WS_THICKFRAME, 0, 0); pParent->ModifyStyle(0,WS_CAPTION,SWP_FRAMECHANGED); }
Best Wishes, -David DelauneThanks for the reply. I have tried it.And aslo i have tried in childframe precreate function in CREATRSTRUCT structure . CREATRSTRUCT cs; cs ~=WS_MAXIMIZEBOX which disables the maximize box. But both the ways gives me the same result.That intially window is maximised and the user can press the restore button. Once the restore button is pressed, the maximize button is disabled.But this is not the actual requirment that the user should not be able to pres the restore button in initial case also. Is there is any method so that initially also restore button should be disabled
-
Thanks for the reply. I have tried it.And aslo i have tried in childframe precreate function in CREATRSTRUCT structure . CREATRSTRUCT cs; cs ~=WS_MAXIMIZEBOX which disables the maximize box. But both the ways gives me the same result.That intially window is maximised and the user can press the restore button. Once the restore button is pressed, the maximize button is disabled.But this is not the actual requirment that the user should not be able to pres the restore button in initial case also. Is there is any method so that initially also restore button should be disabled
-
Hi, Sorry for the late reply. The code that I showed you is working for me in VS2008 on MDI child windows. If you show me how and where you are attempting to remove the buttons I may be able to help. Best Wishes, -David Delaune
Thank you very much David for showing intrest. I tried to do it in MDI child frame window PreCreateWindow by modifying the CREATESTRUCT it was not working. Also i pasted the code which you have posted in View class OnCreate function . both was showing the same result. Initailly the window will be displayed as maximized and restore dowm button will be enabled. But once the user press the restore down button, the window will be resized and then the Maximize button will be disabled. After that the user cannot click on the maximize button. But what i want to do it is to disable\remove the restore down button in the begining itself so that the user may not be able to resize the window. The reason is that i am displaying a graph which should be always displayed in a full window. Is there any solution.
-
Thank you very much David for showing intrest. I tried to do it in MDI child frame window PreCreateWindow by modifying the CREATESTRUCT it was not working. Also i pasted the code which you have posted in View class OnCreate function . both was showing the same result. Initailly the window will be displayed as maximized and restore dowm button will be enabled. But once the user press the restore down button, the window will be resized and then the Maximize button will be disabled. After that the user cannot click on the maximize button. But what i want to do it is to disable\remove the restore down button in the begining itself so that the user may not be able to resize the window. The reason is that i am displaying a graph which should be always displayed in a full window. Is there any solution.
Deepu Antony wrote:
Is there any solution.
First lets try to get into the same code. If you have Visual Studio 2008 and have installed the samples navigate to the following folder: Microsoft Visual Studio 9.0\Samples\1033\AllVCLanguageSamples\C++\MFC\advanced\mtmdi Open this project and find the Bounce.cpp file. In the OnCreate function add:
CWnd *pParent = GetParent(); CMenu* pMenu = pParent->GetSystemMenu(FALSE); if (NULL != pMenu) { pParent->ModifyStyle(WS_CAPTION|WS_MAXIMIZEBOX ,0,0); pParent->ModifyStyle(WS_THICKFRAME, 0, 0); pParent->ModifyStyle(0,WS_CAPTION,SWP_FRAMECHANGED); }
And in the PreCreateWindow function add:cs.style &= ~WS_THICKFRAME;
This should cause the MDI window to be non-resizable and the Maximize/Restore grayed out. If you have another version of Visual Studio let me know and we can change samples. Best Wishes, -David Delaune