Overview

Mouse non-client area are event names starts with WM_NC (Window Message Non Client). These messages are in same format as mouse client area events. The only difference is these are posted to the window when mouse is interacted in non-client area.

  • WM_NCHITTEST - Mouse non-client area test
  • WM_NCLBUTTONDBLCLK - Mouse non-client area left button double click
  • WM_NCLBUTTONDOWN - Mouse non-client area left button down
  • WM_NCLBUTTONUP - Mouse non-client area left button up
  • WM_NCMBUTTONDBLCLK - Mouse non-client area middle button double click
  • WM_NCMBUTTONDOWN - Mouse non-client area middle button down
  • WM_NCMBUTTONUP - Mouse non-client area middle button up
  • WM_NCMOUSEMOVE - Mouse non-client area x or y movement
  • WM_NCRBUTTONDBLCLK - Mouse non-client area right button double click
  • WM_NCRBUTTONDOWN - Mouse non-client area right button down
  • WM_NCRBUTTONUP - Mouse non-client area right button up
  • WM_NCXBUTTONDBLCLK - Mouse non-client area X button up
  • WM_NCXBUTTONDOWN - Mouse non-client area X button up
  • WM_NCXBUTTONUP - Mouse non-client area X button up

WM_NCHITTEST

Mouse position can be obtained from lparam

xPos = GET_X_LPARAM(lParam); 
yPos = GET_Y_LPARAM(lParam);

WM_NCHITTEST event parameters can be passed to DefWindowProc() which will return a code to know which object is clicked. Here are the return codes from DefWindowProc().

HTBORDER
18

In the border of a window that does not have a sizing border.

HTBOTTOM
15

In the lower-horizontal border of a resizable window (the user can click the mouse to resize the window vertically).

HTBOTTOMLEFT
16

In the lower-left corner of a border of a resizable window (the user can click the mouse to resize the window diagonally).

HTBOTTOMRIGHT
17

In the lower-right corner of a border of a resizable window (the user can click the mouse to resize the window diagonally).

HTCAPTION
2

In a title bar.

HTCLIENT
1

In a client area.

HTCLOSE
20

In a Close button.

HTERROR
-2

On the screen background or on a dividing line between windows (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error).

HTGROWBOX
4

In a size box (same as HTSIZE).

HTHELP
21

In a Help button.

HTHSCROLL
6

In a horizontal scroll bar.

HTLEFT
10

In the left border of a resizable window (the user can click the mouse to resize the window horizontally).

HTMENU
5

In a menu.

HTMAXBUTTON
9

In a Maximize button.

HTMINBUTTON
8

In a Minimize button.

HTNOWHERE
0

On the screen background or on a dividing line between windows.

HTREDUCE
8

In a Minimize button.

HTRIGHT
11

In the right border of a resizable window (the user can click the mouse to resize the window horizontally).

HTSIZE
4

In a size box (same as HTGROWBOX).

HTSYSMENU
3

In a window menu or in a Close button in a child window.

HTTOP
12

In the upper-horizontal border of a window.

HTTOPLEFT
13

In the upper-left corner of a window border.

HTTOPRIGHT
14

In the upper-right corner of a window border.

HTTRANSPARENT
-1

In a window currently covered by another window in the same thread (the message will be sent to underlying windows in the same thread until one of them returns a code that is not HTTRANSPARENT).

HTVSCROLL
7

In the vertical scroll bar.

HTZOOM
9

In a Maximize button.

About our authors: Team EQA

Further readings

Where is WinMain() function in MFC application ?

MFC hides WinMain in its framework and includes source file on WinMain(). This explains how framework calls global CWinApp::Initinstance() from entry WinMain.

What is the utility of CWinApp class?

This is constructed during global C++ objects are constructed and is already available when Windows calls the WinMain function, which is supplied by the ...

Basic steps in Win32 GUI Application with source code.

Define a custom Window class structure, Register the class name, CreateWindow, Show windows and write message get and dispatch loop statements. Define the Window CallBack procedure and write the handlers.

What is a Window CallBack procedure and what is its utility?

DispatchMessage() is a API which indirectly triggers the Window CallBack procedure. Message structure members from this function are passed to the CallBack procedure. CallBack procedure should implement event handlers depending on the need of the application.

What are LPARAM and WPARAM in window proc function?

LPARAM and WPARAM are the two parameters in Window CallBack procedure. They signifies parameters of various events. They are used in handing individual events.

What are the basic steps of a typical MFC based application?

We need to write WinMain and need to follow all these in a Win32 application. However we need not to write much if we are writing an application with MFC ...

Learn on Youtube

#