DRAGBMP
-------

DRAGBMP demonstrates how to do smooth Solitaire-like bitmap dragging. This 
smooth dragging is achieved through the use of several bitmaps and a series
of BitBlts.

Before any dragging can be done, several things must be stored:
1. A bitmap of the desired image, such as the cards in Solitaire or the
domino used in this sample.
2. A bitmap of what lies underneath the desired image. This is needed when
the image is dragged elsewhere and the underlying area must be redrawn.
3. The current position of the image (the width and height of the image can
be stored also or retrieved using GetObject on the image's bitmap).

Once this information is stored, dragging may be performed on the image. The 
user selects the image by clicking the left mouse button while the mouse 
cursor is on the image. Once selected, the image can be dragged by keeping
the mouse button depressed and dragging the mouse. To end the dragging, the
user releases the button.

In this sample, the image is a yellow domino. Hit testing is used in the 
WM_LBUTTONDOWN message case to determine when the domino is selected. Once 
selected, the dragging process begins. On each WM_MOUSEMOVE, a new background 
bitmap must be created, the old background bitmap is restored, and the domino 
is moved to it's new location. The WM_LBUTTONUP message ends the dragging 
process.


	(x',y')		 new position
	-----------------
	|\		|
	| \(dx,dy)	|
	|  \		|
	|   \...........|...... old position
	|   .(x,y)	|	.
	|   .		|	.
	|   .		|	.
	----------------	.
	    .			.
	    .			.
	    .....................

			Figure 1.


The basic steps to perform the bitmap dragging are as follows:

1. Calculate the delta x and delta y in the mouse movement. In figure 1,
this would be dx and dy.

2. BitBlt the screen at the new position onto a new bitmap (this
corresponds to rectangle with origin at (x',y') in Figure 1). This will
become the new background bitmap.

3. Since the new background bitmap still contains part of the domino's
image on it starting at point (x,y) in Figure 1, BitBlt the old background
bitmap to that point on the new background bitmap, offsetting it by dx and
dy. The resulting bitmap contains the correct background for the new
position.

4. Next, BitBlt the domino's bitmap to the screen at it's new location
(origin at point (x',y') in Figure 1).

5. The domino is now in the correct position on the screen and we have a 
bitmap of what is underneath, but there is still a portion of the domino 
showing at the lower right. To erase this portion, BitBlt the bitmap of
the domino onto the old background's bitmap, offsetting it by -dx and -dy.
Then BitBlt this modified old background bitmap to the screen at point 
(x,y). This, in effect, erases the old portion of the domino and causes
no flashing.

6. At this point the dragging is done. Store the new background bitmap and 
delete the old one.

The algorithm described above will work for the general case as well as the 
example used in Figure 1.

The code for dragging and hit-testing can be found in the DRAG.C file. The 
code for processing the mouse and paint messages can be found in MAINWND.C.
