Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing the close button in a Window

Status
Not open for further replies.

SimonRobson

Programmer
Jul 18, 2002
3
IT
Hi

How do I remove the close 'cross' button from a Window? Specifically, I want to remove it from a floating ToolBar window.

Thanks

Simon
 
I never played with toolbar windows, but for a dialog, the easiest way to do that is in the dialog editor -> right-click on the dialog -> properties -> find a check box which says something like "close button", and deactivate it. I'm sure it must be similar for a toolbar window.

Vincent
 
Along similar lines, how do you disable the "close" in a property sheet? I do not have a resource file for the property sheet as I created it on my own (only to realize there was an easier way ..... but too late).
 
Hi Vincent,
For Toolbar or any ControlBar,you have to write explicit code to disable the close button.
Basically, try to get the CMenu pointer and then use the EnableMenuItem function.
It goes something like this:

if(m_dwStyle & CBRS_FLOATING){
CMenu* pSysMenu;
CWnd* pWnd;
CWnd* pWndOwn;

pWnd = GetParent()->GetParent();
pWndOwn = GetOwner();
pSysMenu = pWnd->GetSystemMenu(FALSE);

if((pWnd->GetSafeHwnd()!=pWndOwn->GetSafeHwnd()) && pSysMenu){
pSysMenu->EnableMenuItem(SC_CLOSE,
MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
}
}

MSDN does give some scattered help on this.

Good luck,

ss2905
 
You can try to do it so:
DWORD dwStyle = GetWindowLong(hwndTB, GWL_STYLE );
dwStyle &= ~WS_SYSMENU; //This 'cross' button (with 'minimize' and 'maximize') is in the SYSMENY
SetWindowLong(hwndTB, dwStyle, GWL_STYLE );
hwndTB is HWND of Your Toolbar Window.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top