As of October, 2016, Embarcadero is offering a free release
of Delphi (Delphi
10.1 Berlin Starter Edition ). There
are a few restrictions, but it is a welcome step toward making
more programmers aware of the joys of Delphi. They do say
"Offer may be withdrawn at any time", so don't delay if you want
to check it out. Please use the
link to let me know if the link stops working.
Support DFF - Shop
If you shop at Amazon anyway, consider using
this link. We receive a few cents from each purchase.
Support DFF - Donate
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.
e-mail with your comments about this program (or anything else).
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:
- 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
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
|Created: February 18, 2016
Modified: February 18, 2016