Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

disable close/minimize boxes

hi,
how can i disable the close and minimze boxes in a simple formview?
thanks
0
talsp
Asked:
talsp
  • 5
  • 4
1 Solution
 
mblatCommented:
Disable or remove?

to remove you need to overwrite PreCreateWindow and remove
some styles

Something in line of

LONG lStyle = ::GetWindowLong(hWnd, GWL_STYLE);
lStyle &= ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
::SetWindowLong(hWnd, GWL_STYLE, lStyle);

To disable close button use

EnableMenuItem(::GetSystemMenu(AfxGetMainWnd()->m_hWnd, FALSE), SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);

Hope it helps...

0
 
mblatCommented:
Or, by the way.

The only way I know of to disable minimize/maximize buttons is to delete corresponing menu items

DeleteMenu(::GetSystemMenu(AfxGetMainWnd()->m_hWnd,FALSE), SC_MINIMIZE, MF_BYCOMMAND);

after that minimiza item no longer present on system menu, and while minimize button still present and seems active it doesn't do anything....

0
 
talspAuthor Commented:
i was looking for a way to disable the close/minimze boxes in the child windows.

can u help me out with it?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
orange_juiceCommented:
mblat's way should work
0
 
mblatCommented:
It should be the same instead of AfxGetMainWnd() use CWnd* of a window that you want disabled....
If you are in that window you can use this pointer.
0
 
talspAuthor Commented:
its wierd, i am doing:
DeleteMenu(::GetSystemMenu(this->m_hWnd,FALSE), SC_MINIMIZE, MF_BYCOMMAND);

in the CFormView i am using but nothing happens.
the minimize box still working.
0
 
mblatCommented:
Does "Minimize" menu item still exist?  
By the way the simpliest way to prevent user to minimize your app is to overwrite SC_MINIMIZE message.  
May be you can do that?
0
 
talspAuthor Commented:
Minimize menu doesn't exist.

its wierd i did the same with the SC_CLOSE and its working great, no close option in menu and the X button don't work.

btw: how do i overwrite th SC_MINIMIZE?
thanks

0
 
talspAuthor Commented:
thanks a lot
i had another flag i didn't notice.
it working great.
thanks.
0
 
mblatCommented:
Why B then?  Moderator!  Help!!!!!!!!!!!!!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now