Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

resize and move.

Posted on 2004-04-29
8
Medium Priority
?
494 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 2000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

704 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