Solved

resize and move.

Posted on 2004-04-29
8
491 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 
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
 

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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

627 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