Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7691249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:34:46+00:00 2026-05-31T20:34:46+00:00

I am making a program with native C++ and the WinAPI. This program has

  • 0

I am making a program with native C++ and the WinAPI.

This program has a main application window that I want to be somewhat persistent. It seems kind of natural to close a window via the red X button, and I often accidentally press it when I don’t actually want to exit the program (this happens to me with Teamspeak). So, I’m trying to repurpose the red X button into a minimize button to avoid accidental exiting.

However, my application should have some way to exit the program with standard system controls. I want to allow ALT+F4 and right clicking on the taskbar icon to close. I tried intercepting WM_CLOSE and SYSCOMMAND (SC_CLOSE) but this seems to disable all standard system methods of exiting the program (short of killing it in Process Explorer – not really a standard method).

Is there a way to only intercept the window’s red X button? I noticed that Windows Live Messenger does this but I have no idea how.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:34:47+00:00Added an answer on May 31, 2026 at 8:34 pm

    Handle WM_NCLBUTTONDOWN message and use WM_NCHITTEST to check it the click is about to be delivered to HTCLOSE control (this is what your red [X] resolves to). Or alternatively, handle WM_NCHITTEST itself and prevent from discovering HTCLOSE part of your window GUI by replacing return value with something else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im making a program in C# that has passwords and I need to encrypt
I'm making a Java program that takes some text as input, and has to
While making my program i have come across this requirement that i have to
I'm making a program use JNI to call some native directives. My code is:
I am using the cool map making program DIY map and i want to
Im making a program for class that manages a Hotel. I have a function
I noticed while making a program that a lot of my int type variables
I'm making a program that communicate with certain patient monitor using C sockets. I'm
I am making a program for class that manages a Hotel. I am able
I have been making a program that creates multiple CSV's from another source CSV

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.