Archived

This topic is now archived and is closed to further replies.

rossco

Disable the X button on a Window using C/C++

Recommended Posts

I need to Disable the X icon on a window to prevent the user from closing the Window - I have a main menu form and an other form off the main form. I want the user to exit the new form and return to the main form using an Exit button I have created instead of clicking on the X icon on the Window. Please help I need this for my 3rd Year project in college due on Monday next!

Share this post


Link to post
Share on other sites
Why not let the user exit by clicking the x-icon? It's the normal way in windows, and it's not particulary diffucult to find out when the user clicks on the x either. In c/c++ just keep an eye for WM_CLOSE messages, i think.

[edited by - __filip on April 22, 2004 1:10:42 PM]

[edited by - __filip on April 22, 2004 1:11:00 PM]

Share this post


Link to post
Share on other sites
Removing the WS_SYSMENU style from the window might be enough. If not, check with the API documentation which style bit should be removed.

Share this post


Link to post
Share on other sites
I looked through the MSDN manual and I couldn''t find anything. All I know is that it has something to do with "system menu" (atleast that''s how you disable it MVC++''s resource editor. Sorry!

/*
I use DirectX 9 and C++ (Microsoft Visual C++ 6.0 Professional edition)
*/

Share this post


Link to post
Share on other sites
ok, if you really want to remove the x-icon (personally I still think it''s wrong), use CreateWindowEx() and pass 0 as both the dwStyle and dwStyleEx parameters. And voila! You will then get a window without a x-icon. I don''t know if it works under WinXp, I''ve only tested it under win98

Share this post


Link to post
Share on other sites