Solved

resize and move.

Posted on 2004-04-29
8
485 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 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

21 Experts available now in Live!

Get 1:1 Help Now