When the user clicks the left mouse button, the OnLButtonDown handler checks the mouse coordinates to see if the cursor is on the finder image control. If it is, the handler sets a flag to indicate that a drag operation is in progress, so that the other mouse event handlers can alter their behavior appropriately. For example, OnMouseMove moves the drag image to the new mouse location only if this flag is set. Next OnLButtonDown calls the API function SetCapture, so that the dialog will receive all further mouse input until the user releases the mouse button to end the drag operation. Once this is done, OnLButtonDown creates a CWindowDC object to obtain a device context for the desktop window for drawing the finder's outline rectangles.
Device contexts are limited resources.
This lets the finder icon function but without outlining the windows as the icon moves. Once OnLButtonDown has obtained and verified the device context pointer, it prepares to track the window as the pointer moves. The timer will be used to highlight the window under the mouse cursor. As the user moves the mouse, the OnMouseMove handler erases and redraws the finder icon so that it follows the mouse position. Next OnTimer calls the image list's DragShowNoLock member function to hide the finder icon, so that it won't interfere with the outline rectangles as they are drawn or erased.