You need to update your implementation so that your application react to mouse move event.
You might also want to define global variable "x" and "y" so that the values of "x" and "y" changes according to mouse move event. The following is the reference on how to process a mouse move event. https://docs.microsoft.com/en-us/windows/desktop/inputdev/wm-mousemove
The following is example to enable the movement of the line according to x position of the mouse:
/// Define global variable to store the changes of mouse position
/// It is recommended to add a prefix "g_" for global variable.
int g_x = 0;
int g_y = 100;
...
...
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
...
...
case WM_MOUSEMOVE:
{
/// Retrieve X Position from lower bytes of lParam
g_x = lParam & 0x0FFFF;
/// Request windows to update the rendering
InvalidateRect(hWnd, NULL, TRUE);
break;
}
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
MoveToEx (hdc, g_x, g_y, NULL);
LineTo (hdc, g_x, 0);
EndPaint(hWnd, &ps);
/// Do not forget the break so that the case after WM_PAINT will not be executed
break;
}