
Search

Support DFF
If you benefit from the website, in terms of
knowledge, entertainment value, or something otherwise useful,
consider making a donation via PayPal to help defray the
costs. (No PayPal account necessary to donate via credit
card.) Transaction is secure.
If you shop at Amazon anyway,
consider using this link. We receive a few cents from each purchase.
Thanks.

Contact
Feedback:
Send an e-mail with your
comments about this program (or anything else).

|
| |
José
Hernandis sent me an email a few weeks ago asking for advice on
using cursors larger than the standard 32 x 32 bit. It seems that
Windows and/or PC hardware does not support larger cursors, at least
not that I could track down. I developed a model using sprite
processing concepts to move a bitmap image around on the screen and which José
successfully adapted for his application.
Here is how it works:
- Initialization:
- Make a copy of the form in a bitmap, FormImage
- Make a 2nd copy of the form in another form sized bitmap named WorkImage
- Load a cursor bitmap with transparency features activated.
- When we want to start showing the large cursor:
- Turn off the form's cursor (set Cursor := crNone;)
- Draw the cursor bitmap on the form with it's top left corner at the
mouse Cursorpos field.
- Save the rectangle coordinates of the cursor image in Oldrect
- An OnMouseMove exit is where the magic happens:
- Copy an area the size of and located at the cursor from FormImage
to Workimage - this will erase the old cursor.
- Change the location of the cursor image to the new mouse coordinates
and save new image coordinates in Newrect.
- Draw cursor image on WorkImage.
- .Copy an area the size of the overlapped old and new cursor rectangles
from WorkImage to the form canvas. The Windows API function UnionRect
is a convenient way to make this rectangle.
- Move Newrect to Oldrect to set up for the next mouse
move.
That's the bulk of it. José's 128 x 128 cursor image was much better than
my test cursor so I'm using it in this demo. He says the "B" stands for
"Ballantines", an English whiskey, and he is using it in a computerized
board game to be played at discos and pubs.
Since form painting precedes drawing controls, the cursor disappears behind
buttons and other TWinControl descendants. Activating the OnMouseMove exits for the
controls will keep the cursor positioned accurately. For some reason
the big cursor will appear on top of TGraphicControl controls
(e.g. TLabels and TImages) - I haven't figured that one out
yet. For the other controls, the big cursor reverts to the small cursor
while over the control, which might be an acceptable way to handle the
situation.
Download source
| Created: May 18, 2009 |
Modified: May 18, 2009
|
|