You may want some of your applications to be able to extend an existing selection. One way to do this is to have the user hold the SHIFT key when making a selection. Since the wParam parameter contains a flag that specifies whether the SHIFT key is being pressed, it is easy to check for this and to extend the selection, as necessary. In this case, extending a selection means preserving its previous OrgX and OrgY values when you start it. To do this, change the WM_LBUTTONDOWN case so it looks like this:
case WM_LBUTTONDOWN:
fTrack = TRUE;
PrevX = LOWORD(lParam);
PrevY = HIWORD(lParam);
if (!(wParam & MK_SHIFT)) { /* If shift key */
OrgX = LOWORD(lParam); /* is not pressed */
OrgY = HIWORD(lParam);
}
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
/*
* Capture all input even if the mouse goes outside
* the window.
*/
SetCapture(hwnd);
break;