Author Topic: hide mouse cursor  (Read 5511 times)

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
hide mouse cursor
« on: 2008-03-11, 05:02:30 AM »
can i hide the mouse cursor while the game is running?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: hide mouse cursor
« Reply #1 on: 2008-03-11, 05:42:52 AM »
If you have a program that can create a mouse cursor file, you could create an invisible cursor and load it after InitializeComponent is called with a line like this:
Cursor = new Cursor("empty.cur");

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: hide mouse cursor
« Reply #2 on: 2008-03-11, 06:27:37 AM »
this works only in the game window, right? if the player moves the cursor out of the window is there the normal cursor?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: hide mouse cursor
« Reply #3 on: 2008-03-11, 06:48:35 AM »
Yes

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: hide mouse cursor
« Reply #4 on: 2008-03-11, 08:12:17 AM »
Would the Cursor.Hide() method be a possible option here?  It is full-screen, but couldn't a few events just hide it on mouse enter and show it on mouse exit?
Edward Dassmesser

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: hide mouse cursor
« Reply #5 on: 2008-03-11, 02:44:32 PM »
Actually Cursor.Hide does exactly what I was thinking my solution would do, I just didn't know about Cursor.Hide.  That's a much easier solution.  Use Cursor.Hide() instead.

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: hide mouse cursor
« Reply #6 on: 2008-03-12, 11:04:18 AM »
eh.... i don't know how to do this, there are no rules for that (hint, hint, as other users would say  :laugh:)

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: hide mouse cursor
« Reply #7 on: 2008-03-12, 11:22:17 AM »
Create a rule that runs once (During an initialization phase)
do:
System.Windows.Forms.Cursor.Hide
Speaking of which...
BlueMonk:  Maybe there should be a simple way to define rules that always run exactly once (per game/per level/per sprite/whatever).  Rather than surrounding it in an if (initialized) block in the main code, have a separate area for rules that run during the constructor, or something?  It's a very common use case, and while there is already a way to do it, it could be simpler and more efficient.
« Last Edit: 2008-03-12, 11:25:45 AM by durnurd »
Edward Dassmesser