Big Cursors

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math Topics]   [Library]   [Utilities]

 

Search

 

Search DelphiForFun.org only

Support DFF

 If you shop at Amazon anyway,  consider using this link. We receive a few cents from each purchase.   Thanks.

In Association with Amazon.com

 

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.

 

 

Contact

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

 

Search DelphiForFun.org only

 

 

 

 

 

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:

bulletInitialization: 
bulletMake a copy of the form in a bitmap, FormImage
bulletMake a 2nd copy of the form in another form sized bitmap named WorkImage
bulletLoad a cursor bitmap with transparency features activated. 
bulletWhen we want to start showing the large cursor: 
bulletTurn off the form's cursor (set Cursor := crNone;)
bulletDraw the cursor bitmap on the form with it's top left corner at the mouse Cursorpos field. 
bulletSave the rectangle coordinates of the cursor image in  Oldrect 
bulletAn  OnMouseMove exit is where the magic happens:  
bulletCopy an area the size of and located at the cursor from FormImage to Workimage - this will erase the old cursor. 
bulletChange the location of the cursor image to the new mouse coordinates and save new image coordinates in Newrect.
bulletDraw cursor image  on WorkImage.
bullet.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.
bulletMove 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

 

 

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2013, Gary Darby    All rights reserved.