Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » TopWindow&PopUp, TrayIcon » How to remove the button [X] that closes the window?
How to remove the button [X] that closes the window? [message #444] Mon, 02 January 2006 19:42 Go to next message
id9848949 is currently offline  id9848949
Messages: 2
Registered: December 2005
Junior Member
i can't find any Closeable()...close button in caption does not look nice in login dialog..
Re: how to display dialog box without close button in window caption? [message #445 is a reply to message #444] Mon, 02 January 2006 20:26 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Unfortunately, is does not seem possible to avoid close button in Win32 API...

Mirek
Re: how to display dialog box without close button in window caption? [message #446 is a reply to message #445] Mon, 02 January 2006 21:31 Go to previous messageGo to next message
id9848949 is currently offline  id9848949
Messages: 2
Registered: December 2005
Junior Member
it looks like that mfc window without WS_SYSMENU doesn't have any buttons, i verified it with simple example; i have checked TopWindow::SyncCaption (TopWin32.cpp) function and i don't understand why TopWindow window has close button but doesn't have any system menu
Re: how to display dialog box without close button in window caption? [message #447 is a reply to message #446] Mon, 02 January 2006 22:37 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Last time I checked I found Win32 behaviour quite fuzzy. I will try to experiment with this a bit ASAP.

Would you find any solution, I would be happy to add it to TopWindow....
Re: how to display dialog box without close button in window caption? [message #456 is a reply to message #444] Wed, 04 January 2006 07:49 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member


I suspect with WS_CAPTION there will always be a close button (and title bar) but you can grey the close button with some effort. Title bar is useful for being able to move the window around, even a login window. CreateWindowEx seems to need WS_SYSMENU to get system menu, depending on other settings.

You can find out what's on the title bar but apparently you can't change it using TITLEBARINFO.
http://msdn.microsoft.com/library/en-us/winui/winui/windowsu serinterface/windowing/windows/windowreference/windowfunctio ns/gettitlebarinfo.asp

Graeme
Re: how to display dialog box without close button in window caption? [message #458 is a reply to message #456] Wed, 04 January 2006 08:18 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member


I'm wrong. It is possible to get rid of the close button and still have title bar.

Here's how to do it in VB. I'm sure it's possible in C++ too Smile

http://www.devx.com/tips/Tip/14284


In C++ (info found on usenet)


Disable the close button

EnableMenuItem( GetSystemMenu( hWnd, 0 ), SC_CLOSE, MF_BYCOMMAND
|MF_DISABLED );



Remove the close button (I think).

HMENU hMenu = GetSystemMenu( hWnd, 0 );
int nNbItems = GetMenuItemCount(hMenu);
RemoveMenu(hMenu, nNbItems - 1, MF_BYPOSITION);
RemoveMenu(hMenu, nNbItems - 2, MF_BYPOSITION);


And handle WM_SYSCOMMAND (SC_CLOSE) if you want also to disable [Alt]+[F4]


Graeme
How to remove the button [X] that close the window [message #2845 is a reply to message #444] Fri, 28 April 2006 00:20 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I do not want my user close the window by pressing the button [X] in the top-right side of the window itself. To prevent it I've attached to the event WhenClose a callback that do nothing. It seems to work although I do not know if it is the correct way.
However I would like to let the button [X] disappear from the bar to prevent useless click. Is it possible?
Thank you

Luigi
Re: How to remove the button [X] that close the window [message #2848 is a reply to message #2845] Fri, 28 April 2006 00:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Unfotunately, not really (AFAIK). That close button is there places by windows and there is a little that can be done with that.

You can work that around using popup windows, but them you have to implement all the window functionality (like caption, resizing etc) on your own, also this is impossible on Linux where popups have quite specific behaviour.

Mirek
Re: How to remove the button [X] that close the window [message #2850 is a reply to message #2848] Fri, 28 April 2006 00:57 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
luzr wrote on Fri, 28 April 2006 00:42

Unfotunately, not really (AFAIK). That close button is there places by windows and there is a little that can be done with that.

Mirek


OK, I'll live with it. Please let me ask the last question.
At least is there the possibility to disable it, so that it looks a bit darker suggesting that is useless to click it?

Luigi
Re: How to remove the button [X] that close the window [message #2852 is a reply to message #2850] Fri, 28 April 2006 09:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
It is not directly supported by U++ (platform differences..), but google reveals that it perhaps is possible, but tricky:

http://addressof.com/blog/articles/232.aspx

Mirek
Re: How to remove the button [X] that close the window [message #2853 is a reply to message #2852] Fri, 28 April 2006 10:25 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member
See this post.

(Edit by fudadmin: url removed, topics merged.)

Disable the close button

EnableMenuItem( GetSystemMenu( hWnd, 0 ), SC_CLOSE, MF_BYCOMMAND
|MF_DISABLED );



Remove the close button (I think).

HMENU hMenu = GetSystemMenu( hWnd, 0 );
int nNbItems = GetMenuItemCount(hMenu);
RemoveMenu(hMenu, nNbItems - 1, MF_BYPOSITION);
RemoveMenu(hMenu, nNbItems - 2, MF_BYPOSITION);


And handle WM_SYSCOMMAND (SC_CLOSE) if you want also to disable [Alt]+[F4]

[Updated on: Fri, 28 April 2006 10:52] by Moderator

Report message to a moderator

Re: How to remove the button [X] that closes the window [message #2855 is a reply to message #2853] Fri, 28 April 2006 10:39 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
I will merge those 2 topics because they are identical...
Edit: Done.

[Updated on: Fri, 28 April 2006 10:54]

Report message to a moderator

Re: How to remove the button [X] that close the window [message #9873 is a reply to message #2848] Tue, 05 June 2007 14:57 Go to previous messageGo to next message
jlfranks is currently offline  jlfranks
Messages: 57
Registered: May 2007
Location: Houston, TX, USA
Member
I have the same problem -- don't want the user to see or access
the X button upper right of window in the title bar.

However, I'm using Linux. Is there any resolution to this, i.e., hide the button so user has no access to it?

--jlf
Re: How to remove the button [X] that closes the window? [message #18441 is a reply to message #444] Wed, 01 October 2008 05:28 Go to previous messageGo to next message
sevenjay is currently offline  sevenjay
Messages: 30
Registered: October 2008
Location: Taiwan
Member
It can be used like this
class example : public WithexampleLayout<TopWindow> {
public:
	ex();
	void Close();
};

void example::Close()
{
	PromptOK("Please Login");
}


and the application can not be closed.

But, more one question is how to close it? Confused
Use
    delete this;

is the method safe?

[Updated on: Wed, 01 October 2008 06:50]

Report message to a moderator

Re: How to remove the button [X] that closes the window? [message #18442 is a reply to message #18441] Wed, 01 October 2008 09:26 Go to previous messageGo to next message
bytefield is currently offline  bytefield
Messages: 210
Registered: December 2007
Experienced Member
HI, Have a look at Break and Breaker functions. These should get you out from main loop.

cdabbd745f1234c2751ee1f932d1dd75
Re: How to remove the button [X] that closes the window? [message #18480 is a reply to message #18441] Fri, 03 October 2008 04:33 Go to previous messageGo to next message
sevenjay is currently offline  sevenjay
Messages: 30
Registered: October 2008
Location: Taiwan
Member
I think this is clear Smile
class example : public WithexampleLayout<TopWindow> {
public:
	example();
	void Close();
	void RealClose();
};

void example::Close()
{
	PromptOK("Please Login");
}
void example::RealClose()
{
	if(PromptOKCancel("Exit MyApp?"))
		this->TopWindow::Close();
}
Re: how to display dialog box without close button in window caption? [message #54366 is a reply to message #458] Tue, 07 July 2020 09:05 Go to previous messageGo to next message
jstip is currently offline  jstip
Messages: 4
Registered: July 2020
Junior Member
Indeed it's possible, similar as in VBA:

#include <Winuser.h>

HMENU hMenu = GetSystemMenu(GetHWND(),0);
RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);

I've placed it in the GotFocus callback.
Re: how to display dialog box without close button in window caption? [message #54472 is a reply to message #54366] Tue, 28 July 2020 17:54 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
That works, but only in Win32....

Mirek
Previous Topic: How do I change main window and dialog title font size
Next Topic: TopWindow when Close override show exception unduly
Goto Forum:
  


Current Time: Thu Mar 28 18:37:28 CET 2024

Total time taken to generate the page: 0.01129 seconds