Question: So I'm using Visual C++, and I have created a draggable, borderless window. Anyway, there is a toolbar along the top, and i want to be able to drag the window by that toolbar. I still want the toolbar to be functional, but i have no earthly idea how to be able to drag the window by it. This is my current window (see the toolbar on the top):

![window](https://i.stack.imgur.com/0DCwy.png)

And this is my current code to make it draggable:

```
case WM_NCHITTEST: {
    LRESULT hit = DefWindowProc(hWnd, message, wParam, lParam);
    if(hit == HTCLIENT) hit = HTCAPTION;
    return hit;
}
break;

```

Answer: 
You are on the right track with hooking WM\_NCHITTEST. Now, you need to make change what constitutes a client hit versus a caption hit. If I understand your code right now, anywhere you click within the client area of the window (everything but the border) will allow you to drag the window elsewhere. This will make interacting with your application very difficult. Instead, you should be returning HTCAPTION only after you have determined that the hit was within the menubar area. Specifically, the area of the menubar that does not hold the File/Edit/Help buttons.

```
case WM_NCHITTEST: {
  LRESULT hit = DefWindowProc(hWnd, message, wParam, lParam);
  if (hit == HTCLIENT) { // The hit was somewhere in the client area. Don't know where yet.
    // Perform your test for whether the hit was in the region you would like to intercept as a move and set hit only when it is.
    // You will have to pay particular attention to whether the user is actually clicking on File/Edit/Help and take care not to intercept this case.
    // hit = HTCAPTION;
  }
  return hit;
  break;
}

```

Some things to keep in mind here:

* This can be very confusing to a user that wants to minimize, close, or move your application. Menubars do not convey to the user that you can move the window by dragging them.
* If you are concerned with vertical pixels you may consider doing what other applications on Windows are starting to do -- moving the menubar functionality to a single button that is drawn in the titlebar. (See recent versions of Firefox/Opera or Windows explorer in Windows 8 for some idea to move things to the titlebar.
In one of my applications I also wanted to make the window what I call "client area draggable". Unfortunately the mentioned solution (replacing HTCLIENT with HTCAPTION)
does have a serious flaws:

Double-clicking in the client area now shows the same behaviour as
double-clicking the caption (i.e. minimizing/maximizing the window)!

To solve this I did the following in my message handler (excerpt):

```
        case WM_MOUSEMOVE:
            // Move window if we are dragging it
            if (mIsDragging) // variable: bool mIsDragging;
            {
                POINT mousePos = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};

                mIsDragging = (ClientToScreen(hWnd, &mousePos) &&
                               SetWindowPos(hWnd,
                               NULL,
                               mDragOrigin.left + mousePos.x - mDragPos.x,
                               mDragOrigin.top + mousePos.y - mDragPos.y,
                               0,
                               0,
                               SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE));
            }
            break;

        case WM_LBUTTONDOWN:
            // Check if we are dragging and safe current cursor position in case
            if (wParam == MK_LBUTTON)
            {
                POINT mousePos = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
                if (ClientToScreen(hWnd, &mousePos) &&
                    DragDetect(hWnd, mousePos))
                {
                    // Check if the cursor is pointing to your new caption here!!!!
                    mIsDragging = true;
                    mDragPos = mousePos;

                    GetWindowRect(hWnd, &mDragOrigin);
                    SetCapture(hWnd);
                }
            }
            break;

        // Remove this case when ESC key handling not necessary
        case WM_KEYDOWN:
            // Restore original window position if ESC is pressed and dragging active
            if (!mIsDragging || wParam != VK_ESCAPE)
            {
                break;
            }

            // ESC key AND dragging... we restore original position of window
            // and fall through to WM_LBUTTONUP as if mouse button was released
            // (i.o.w. NO break;)
            SetWindowPos(hWnd, NULL, mDragOrigin.left, mDragOrigin.top, 0, 0,
                         SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);

        case WM_LBUTTONUP:
            ReleaseCapture();
            break;

        case WM_CAPTURECHANGED:
            mIsDragging = false;
    break;

```

The (pseudo) code omits the return values (default: 0) and variable definitions but
should make the procedure clear anyway!? (If not drop me a line and I'll add more
or all code).

ps: I just found another comprehensive description which also explains the differences
 of these two solutions: <http://tinyurl.com/bqtyt3q>