Solved

resize and move.

Posted on 2004-04-29
8
483 Views
Last Modified: 2013-11-20
Hi,
   In a CFrameWnd, how do I disable the move and size option of the menu when the user clicks on the program icon on the top left hand corner.

I am trying to prevent the user from resizing and moving the window. The window should always be maximized.

Thanks.
0
Comment
Question by:pcssecure
  • 3
  • 3
  • 2
8 Comments
 
LVL 7

Expert Comment

by:vijay_visana
ID: 10956562
So what do you want
do not show menu at all
show minimize disable or
no action on minimize selection?
0
 

Author Comment

by:pcssecure
ID: 10956577
I just need to know how to disable the move and size option of the menu when the user clicks on the program icon on the top left hand corner..

0
 
LVL 3

Accepted Solution

by:
kklai72 earned 500 total points
ID: 10956623
First of all to disable item in sys menu you should insert this , where CMainForm is dervied from CFrameWnd,

int CMainForm::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
      CMenu* pSysMenu = GetSystemMenu(FALSE);
      if (pSysMenu != NULL)
      {
            pSysMenu->EnableMenuItem(SC_MOVE, MF_GRAYED);
            pSysMenu->EnableMenuItem(SC_SIZE, MF_GRAYED);
      }
}

Then, you should have correct parameter when you Create this CFrameWnd in your CWinApp, such that user cannot resize the window by pointing at the edge of the window,

BOOL CYourApp::InitInstance()
{
      pMainForm->Create(strWndClass, strApplicationName,
                  WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU);
}


Finally, you should override OnMove OnSize such that it retains its size and location.
0
 
LVL 7

Expert Comment

by:vijay_visana
ID: 10956664

Hi
kklai72
your code is not working in my test programme


>> pcssecure
you can do following  and no action will be taken when use select minimize button

BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
    if(pMsg->message == WM_SYSCOMMAND && (pMsg->wParam == SC_MINIMIZE))
        return TRUE;
    return CMDIFrameWnd::PreTranslateMessage(pMsg);
}
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:pcssecure
ID: 10956697
Have to use the above with OnInitMenu(CMenu* pMenu) rather then OnCreate.

Thanks.
0
 
LVL 3

Expert Comment

by:kklai72
ID: 10956709
as you know, doubling click the title bar will minimize the window, and you can move the window by press and hold the title bar and move the mouse

Therefore, you should add this code also

BOOL CMainForm::PreTranslateMessage(MSG* pMsg)
{
      // TODO: Add your specialized code here and/or call the base class
      if ((pMsg->message==WM_NCLBUTTONDOWN) && (pMsg->wParam==HTCAPTION))
            return TRUE;
      if (pMsg->message==WM_NCLBUTTONDBLCLK)
            return TRUE;

      return CFrameWnd::PreTranslateMessage(pMsg);
}

otherwise, you should not include WS_CAPTION | WS_SYSMENU when you create the window
0
 

Author Comment

by:pcssecure
ID: 10956730
Yes I have handled all these. It is just the menu items that I need to disable.
0
 
LVL 7

Expert Comment

by:vijay_visana
ID: 10956974
GREAT...
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now