Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Customise the windows mouse cursor from within DBP - including animated cursors.

Author
Message
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 12th Oct 2006 17:43
This code uses the user32 dll to change your mouse icon to anything you like.

You can change the file name to any .cur (normal) or .ani (animated) cursor file. In the code below, I've directed it to the waggy tail cursor in my windows directory, which I'm assuming is probably on most other peoples p.c.'s too.

This cursor, unlike sprite based cursors, will show up over the window title bar and over any BlueGUI gadgets.

It also works without the need to add cursors into the IDE's project file, which some people (including me) have problems with, which is why I ended up having to write this.

Toggle the cursor between new and original styles by pressing the spacebar.





Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 12th Oct 2006 19:22 Edited at: 12th Oct 2006 19:22
Doesn't seem to work for me.

Mr Kohlenstoff
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 12th Oct 2006 20:09
Wow, hehe, brilliant!
This animated cursor looks really cool.

Visit the DBPro - Speed up your game-Thread. http://forum.thegamecreators.com/?m=forum_view&t=88661&b=1
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 12th Oct 2006 20:48 Edited at: 12th Oct 2006 20:50
@Zoto - Did it crash out with an error message, or did it just run with no cursor, (or the normal cursor)? Could you also check to see if the file (C:WINDOWSCursorswagtail.ani) is actually on your machine, and if not try with a different file which you do have (there should be loads in your windows\cursors folder).

I'm hoping this code works properly as I intend to use it in my current project, but it's no good if it only works for a couple of us.

Syncaidius
20
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 12th Oct 2006 21:17
Hehe, I like the animation. Works fine for me by the way.

Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 13th Oct 2006 00:24
Great, that's 3 out of 4 so far - looking good!

Alquerian
19
Years of Service
User Offline
Joined: 29th Mar 2006
Location: Reno Nevada
Posted: 13th Oct 2006 01:41
Hehe, that is pretty cute. Good work Ric

"We are what we repeatedly do. Excellence, therefore, is not an act, but a habit." - Aristotle
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 13th Oct 2006 02:10 Edited at: 13th Oct 2006 02:13
Cool! Tried a few different cursors... they all worked (but I don't have wagtail on my machine) .ani and .cur types alike.

I'm using DarkBASIC Classic and it worked without modification except I had to include the full path to the user32 dll.

Enjoy your day.
Acolyte Entertainment
20
Years of Service
User Offline
Joined: 28th Dec 2004
Location: Oregon, US
Posted: 16th Oct 2006 17:32
Thats awesome. it worked for me accept whenever i moved it it blinked with the regular cursor every second

[href]www.acalite.com[/href]
Be part of reality
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 16th Oct 2006 23:25
I too get a blinking curosr.
If I move the mouse outside the DBP window then back in again the wagtail cursor doesn't animate until the mouse is stationary.


sadsack
21
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 17th Oct 2006 00:55
Just a black screen.
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 17th Oct 2006 10:00
@ Accolyte;Scraggle: The cursor should hopefully not blink anymore - please try this:



@Sadsack: please check the file "C:\WINDOWS\Cursors\wagtail.ani" exists on your p.c., and if not, change for a file that does exist.

Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 17th Oct 2006 14:18
Still blinks
And still fails to animate until stationary when returning to the window.


Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 17th Oct 2006 19:37
Darn it.

The animation problem is the same here - I guess it restarts the animation from the first frame each time the cursor is moved - and I don't think there's anything I can do about that.

But the blinking is annoying. I think dbp is fighting to draw its normal cursor each frame as well as the dll cursor. Can't think of a solution at the moment.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 17th Oct 2006 22:08
Seems to work perfectly in DBC - with your original code. Had no need to change anything except the path to the dll.

Enjoy your day.
Flatlander
FPSC Tool Maker
18
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 28th Jan 2007 01:53
It was working for me in DBPro (most current version). I went to the cursor folder and used several different ones. I used only the animated ones and then I tried a cur file and it went berserk; popping back and forth between the old and new one. I then went back to an animated one and it worked. Then back to a plain [i]cur[/b] file. Still worked. A little bit of a flicker but very very quick. I thought maybe the spacekey function was interefering somehow since it was to move back and forth from new to old. I deleted the spacekey functions. For me, the new cursors now look awfully good and moves smoothly. Just my input.

So, thanks ric for the snippet. I believe it might come in handy at certain times. Especially all the animated cursors XP has. For instance the stopwatch (handwait.ani) or the wristwatch (handapst.ani) with the hands moving.

As opposed to Highlander.
Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 30th Jan 2007 21:05 Edited at: 30th Jan 2007 21:05
So long as you don't have any custom cursors in your project setting CHANGE MOUSE to 2 (empty custom cursor) will fix the problem in DBP.

Thanks for this great code, Ric. I'm going to use it in my project.



http://3dfolio.com
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 31st Jan 2007 02:02
Thanks for the feedback guys.

Login to post a reply

Server time is: 2025-05-12 09:00:43
Your offset time is: 2025-05-12 09:00:43