1

I am beginner in MFC. I have created a window using MFC framework - CFrameWnd, CDocument and CView. For this window I need to disable Maximize button from system menu after window is created. But I am not able to find the solution for it. I have tried with below solution, but its not working:

  CWnd *poWnd= AfxGetMainWnd();
  HWND oHwnd = poWnd->GetSafeHwnd();
  SetWindowLong(oHwnd, GWL_STYLE, GetWindowLong(oHwnd, GWL_STYLE) & ~WS_MAXIMIZEBOX);

Can anyone please let me know how to achieve it?

xMRi
  • 14,982
  • 3
  • 26
  • 59
Sanjay Bhosale
  • 685
  • 2
  • 8
  • 18
  • 1
    Do it before Creaetion in PreCreateWindow. Or leave the button as it is and just protect the application against switching to maximized state. – xMRi Sep 15 '17 at 05:12
  • 1
    I think the reason is the same as in this case: https://stackoverflow.com/questions/45486327/using-modifystyle-with-ws-thickframe-on-a-cpropertysheet-cdialog – xMRi Sep 15 '17 at 05:25
  • Thanks for your reply but I can't do it before windows creation as I am using companies library. I will try to protect window from maximizing. – Sanjay Bhosale Sep 15 '17 at 09:27
  • 1
    See https://stackoverflow.com/questions/906116/how-do-you-disable-the-maximize-button-in-mfc – sergiol Sep 15 '17 at 13:48
  • 1
    See also https://stackoverflow.com/questions/27402297/creating-window-frame-without-maximize-button-and-without-resizing-options ; And I think, if it is possible, you have to do it in tour class' `CreateWindow` method, otherwise it would be too late. – sergiol Sep 15 '17 at 14:15
  • I copied/pasted your code into existing project of mine & it works. Maximise button is disabled. So there's either some other problem or placement of where you're putting this. – ReturnVoid Sep 16 '17 at 12:06
  • Hi I have existing library which using CDocument, so I can't change that library. I want to disable maximizing functionality for one of my window created through that library. And that's why I am doing it after window creation. – Sanjay Bhosale Sep 19 '17 at 09:32

0 Answers0