Click to See Complete Forum and Search --> : How Do I Disable Close Window X?


Simon Pettman
April 1st, 1999, 08:43 AM
I have a CToolBar which when dragged from its docking position, becomes a window.


It displayes that little cross 'fella' in the corner to close it.


I want to disable this. I had assumed that I could create it without one but I dont know how. I notice in Visual studio the toolbar close facilty (X) is disable How do I do that?

Walter I An
April 2nd, 1999, 04:24 AM
Try following.
First, get system menu from floating window,
then disable close button.

Here is a tiny code and they work for all windows with system menu.

CMenu *pSysMenu = (CMenu*)pMiniFrame->GetSystemMenu(FALSE);
pSysMenu->DeleteMenu(SC_CLOSE, MF_BYCOMMAND);

Good Luck. :)
Walter I An

Simon Pettman
April 7th, 1999, 10:42 AM
CMenu *pSysMenu = (CMenu*) (&m_wndToolBar2)->GetSystemMenu(FALSE);
pSysMenu->DeleteMenu(SC_CLOSE, MF_BYCOMMAND);

This creates an exception. Probably because the window is not originally created as floating. So it doesnot have a system menu. How do I only call this once the window floats?

In otherwords what message can I capture that tells me when the window is made to float.

Simon Pettman

AntHtoo Naing
April 7th, 1999, 11:19 AM
Hi
You can see the answer at CodeGuru Home Page.
In Home Page, there is title "Other Source Code Section". Select "dialog". And then search the title "Menu Handling". Under "Menu Handling" there is a subject "Disable close button for Dialog Box" by Rajesh Rarikh. You can study and enjoy.
AntHtoo Naing

Walter I An
April 9th, 1999, 01:35 AM
U are right!
U need to check this when Ur window is not docked.

There is a function called "IsFloating()"
in CControlBar.

Good luck. :)

Walter An