private LRESULT WmNcHitTest( HWND hwnd, int uMsg, WPARAM wParam, LPARAM lParam ) {
			// this will handle the left, right and bottom parts of the frame because we didn't change them
			LRESULT lResult = User32Ex.INSTANCE.CallWindowProc( defaultWndProc, hwnd, uMsg, wParam, lParam );
			if( lResult.longValue() != HTCLIENT )
				return lResult;

			// get mouse x/y in window coordinates
			LRESULT xy = screen2windowCoordinates( hwnd, lParam );
			int x = GET_X_LPARAM( xy );
			int y = GET_Y_LPARAM( xy );

			// scale-down mouse x/y because Swing coordinates/values may be scaled on a HiDPI screen
			Point pt = scaleDown( x, y );

			// return HTSYSMENU if mouse is over application icon
			//   - left-click on HTSYSMENU area shows system menu
			//   - double-left-click sends WM_CLOSE
			if( contains( appIconBounds, pt ) )
				return new LRESULT( HTSYSMENU );

			// return HTMINBUTTON if mouse is over minimize button
			//   - hovering mouse over HTMINBUTTON area shows tooltip on Windows 10/11
			if( contains( minimizeButtonBounds, pt ) )
				return new LRESULT( HTMINBUTTON );

			// return HTMAXBUTTON if mouse is over maximize/restore button
			//   - hovering mouse over HTMAXBUTTON area shows tooltip on Windows 10
			//   - hovering mouse over HTMAXBUTTON area shows snap layouts menu on Windows 11
			//     https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/apply-snap-layout-menu
			if( contains( maximizeButtonBounds, pt ) )
				return new LRESULT( HTMAXBUTTON );

			// return HTCLOSE if mouse is over close button
			//   - hovering mouse over HTCLOSE area shows tooltip on Windows 10/11
			if( contains( closeButtonBounds, pt ) )
				return new LRESULT( HTCLOSE );

			int resizeBorderHeight = getResizeHandleHeight();
			boolean isOnResizeBorder = (y < resizeBorderHeight) &&
				(User32.INSTANCE.GetWindowLong( hwnd, GWL_STYLE ) & WS_THICKFRAME) != 0;

			// return HTTOP if mouse is over top resize border
			//   - hovering mouse shows vertical resize cursor
			//   - left-click and drag vertically resizes window
			if( isOnResizeBorder )
				return new LRESULT( HTTOP );

			boolean isOnTitleBar = (pt.y < titleBarHeight);
			if( isOnTitleBar ) {
				// return HTCLIENT if mouse is over any Swing component in title bar
				// that processes mouse events (e.g. buttons, menus, etc)
				//   - Windows ignores mouse events in this area
				try {
					if( captionHitTestCallback != null && !captionHitTestCallback.test( pt ) )
						return new LRESULT( HTCLIENT );
				} catch( Throwable ex ) {
					// ignore
				}

				// return HTCAPTION if mouse is over title bar
				//   - right-click shows system menu
				//   - double-left-click maximizes/restores window size
				return new LRESULT( HTCAPTION );
			}

			// return HTCLIENT
			//   - Windows ignores mouse events in this area
			return new LRESULT( HTCLIENT );
		}
Handle WM_NCHITTEST

https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-nchittest

See also NonClientIslandWindow::_OnNcHitTest() here:
https://github.com/microsoft/terminal/blob/main/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
flatlaf-natives/flatlaf-natives-jna/src/main/java/com/formdev/flatlaf/natives/jna/windows/FlatWindowsNativeWindowBorder.java