Dragging Images
The Win32 API includes functions for dragging an image on the screen. The
dragging functions move an image smoothly, in color, and without any flashing of
the cursor. Both masked and unmasked images can be dragged.
The
ImageList_BeginDrag function begins a drag operation. The parameters include the handle of the
image list, the index of the image to drag, and the location of the hot spot
within the image. The hot spot is a single pixel that the dragging functions
recognize as the exact screen location of the image. Typically, an application sets
the hot spot so that it coincides with the hot spot of the mouse cursor. The
ImageList_DragMove function moves the image to a new location.
The
ImageList_DragEnter function sets the initial position of the drag image within a window and draws
the image at the position. The parameters include the handle of the window in
which to draw the image and the coordinates of the initial position within the
window. The coordinates are relative to the window's upper-left corner, not the
client area. The same is true for all of the image dragging functions that
take coordinates as parameters. This means you must compensate for the widths of
window elements, such as the border, title bar, and menu bar, when specifying
the coordinates. If you specify a NULL window handle when calling
ImageList_DragEnter, the dragging functions draw the image in the device context associated with
the desktop window, and the coordinates are relative to the upper-left corner
of the screen.
ImageList_DragEnter locks all other updates to the given window during the drag operation. If you
need to do any drawing during a drag operation, such as highlighting the
target of a drag and drop operation, you can temporarily hide the dragged image by
using the
ImageList_DragLeave function. Another method is to use the
GetDCEx function with the DCX_LOCKWINDOWUPDATE value to retrieve a device context
that allows you to draw. You must be careful, however, not to obliterate the
dragged image.
The
ImageList_SetDragCursorImage creates a new drag image by combining the given image (typically a mouse
cursor image) with the current drag image. Because the dragging functions use the
new image during a drag operation, you should use the
ShowCursor function to hide the actual mouse cursor after calling
ImageList_SetDragCursorImage. Otherwise, the system may appear to have two mouse cursors for the duration
of the drag operation.
When an application calls
ImageList_BeginDrag, the system creates an temporary, internal image list can copies the
specified drag image to the internal list. You can retrieves the handle of the
temporary drag image list by using the
ImageList_GetDragImage function. The function also retrieves the current drag position, and the
offset of the drag image relative to the drag position.
- Software for developers
-
Delphi Components
.Net Components
Software for Android Developers
- More information resources
-
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
- Databases for Amazon shops developers
-
Amazon Categories Database
Browse Nodes Database