Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

resize and move.

Posted on 2004-04-29
8
Medium Priority
?
496 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 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
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.

971 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