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 7622931
In Process

The Archive Base Latest Questions

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

I am using plain C++ (without MFC) to implement an application. I wanted to

  • 0

I am using plain C++ (without MFC) to implement an application.
I wanted to add custom Min/Max/Close button

The code below is what I used.
For HTCAPTION and other border related definition works like a charm,
but I could not get HTMINBUTTON, HTMINBUTTON, HTCLOSE to work in the same way.
Is anything else needed to be implemented for the NCHITTEST to take effect?

// Defining min/max/close
if ((p.x > rt.right - 130) && (p.x < rt.right - 104) &&
    (p.y > 41) && (p.y < 67))
    return HTMINBUTTON;
else if ((p.x > rt.right - 100) && (p.x < rt.right - 74) &&
    (p.y > 41) && (p.y < 67))
    return HTMAXBUTTON;
else if ((p.x > rt.right - 70) && (p.x < rt.right - 44) &&
    (p.y > 41) && (p.y < 67))
    return HTCLOSE;

// Defining window border and caption
else if ((p.x > EDGE) && (p.x < rt.right-EDGE) &&
    (p.y > EDGE) && (p.y < rt.bottom-EDGE))
    return HTCAPTION;
else if (p.x <= EDGE && p.y <= EDGE)
    return HTTOPLEFT;
else if (p.x <= EDGE && p.y >= rt.bottom - EDGE)
    return HTBOTTOMLEFT;
else if (p.x >= rt.right - EDGE && p.y <= EDGE)
    return HTTOPRIGHT;
else if (p.x >= rt.right - EDGE && p.y >= rt.bottom - EDGE)
    return HTBOTTOMRIGHT;
else if (p.x <= EDGE)
    return HTLEFT;
else if (p.x >= rt.right - EDGE)
    return HTRIGHT;
else if (p.y <= EDGE)
    return HTTOP;
else if (p.y >= rt.top - EDGE)
    return HTBOTTOM;
else
    return DefWindowProc(hWnd, message, wParam, lParam);
  • 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-31T04:34:45+00:00Added an answer on May 31, 2026 at 4:34 am

    If you’re drawing the entire Non-Client area of your program (ie. you have a custom window title bar and border), then your best option would be to remove the default title bar and border and use the entire client area as your window. This way, you can just make a custom button (or owner-drawn button) with the graphics needed for your min/max/exit buttons and place them in the title bar area as a button control. Your program will still act like it has a title bar and border because you are handling the WM_NCHITTEST message. I just did this exact thing with my custom window today and it works very well.

    Edit: I forgot to add that returning HTMAX/HTMIN/HTCLOSE will not cause the window to react. The value you return from WM_NCHITTEST is sent in the WPARAM of other messages, notably WM_NCLBUTTONDOWN and WM_NCLBUTTONUP. Unfortunately, the WM_NCLBUTTONUP message does not get sent properly because when you click in the title bar, it captures the mouse.

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

Sidebar

Related Questions

Instruction on accessing a interface to an application, in plain C/C++ without : MFC
I have written a Word add-in in C++ using plain Win32 API. It opens
How do I hide the top bar in UITabBarController using OBJ-C code (without using
I want to use NVelocity from plain ASPX pages without using any MVC framework.
I'm trying to create a dijit button in ZF. I've tried using plain dojo
i am new to this FCKeditor,i am using below mentioned code , i am
I want to inject a plain java object using Spring programmatically without using any
I'm writing an Adobe AIR app using plain HTML which needs to upload photos
How to strip off HTML tags from a string using plain JavaScript only, not
Hi im using sqlalchemy on a db2 table with 500k rows. using plain sql

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.