Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Setting A Mouse Curcer In C#?


  • Please log in to reply
5 replies to this topic

#1 Wolfy87

Wolfy87

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:03:01 PM

Posted 16 August 2008 - 11:40 AM

I am making a shooting game...yada yada yada...for more of that look at my other poasts lol but anyway im trying to assign a curcer to a form...and i just cant do it due to me being quite a beginer but if somone could help that would be great.
So far this is what i have \/ \/ \/

Private Sub Game_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Cursor = ("C:\Documents and Settings\Oliver C\Desktop\Programing\Projects\VRange\0,CD.cur")
End Sub

But all of the directory is underligned with blue so what am i doing wrong...
Also how would i implement this peice of code to generate a random number within the parameters set \/ \/ \/

int minimumValue=0;
int maximumValue=5;
Random rNum = new Random();
int randomNumber= rNum.Next(minimumValue,maximumValue);

I dont have a clue how it works?... :thumbsup:

BC AdBot (Login to Remove)

 


#2 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:03:01 PM

Posted 16 August 2008 - 12:59 PM

Groovicus Please save me! can you just help me out this one last time...Please? :thumbsup:

#3 Ryan 3000

Ryan 3000

  • Members
  • 834 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Maryland
  • Local time:11:01 AM

Posted 17 August 2008 - 11:31 PM

See Is It Just Me Or Is C# Random Terrible? for what I said about the random.
No pessimist ever discovered the secrets of the stars, or sailed to an uncharted land.

#4 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:03:01 PM

Posted 18 November 2008 - 02:42 PM

HOws that got to have anything to do with random XD

#5 NiJor

NiJor

  • Members
  • 5 posts
  • OFFLINE
  •  
  • Local time:04:01 PM

Posted 19 November 2008 - 05:32 PM

Private Sub Game_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Cursor = ("C:\Documents and Settings\Oliver C\Desktop\Programing\Projects\VRange\0,CD.cur")
End Sub

But all of the directory is underligned with blue so what am i doing wrong...


First thing I noticed is that the above stated code is in Visual Basic since it uses Private Sub and End Sub.
So we must change that to C# code,

private void Game_Load(object sender, EventArgs e)
{
Cursor myCursor = new Cursor(@"C:\Documents and Settings\Oliver C\Desktop\Programing\Projects\VRange\0,CD.cur");
someControl.cursor = myCursor; //Replace someControl !
}

When including a path in C# you have to escape the \ character as \\ or you could place an @ in front of the path.
for example:
Cursor = ("C:\\Documents and Settings\\Oliver C\\Desktop\\Programing\\Projects\\VRange\\0,CD.cur");
Or
Cursor = (@"C:\Documents and Settings\Oliver C\Desktop\Programing\Projects\VRange\0,CD.cur");

Also I noticed the comma in the path at \0,CD.cur this might cause a problem!

Also how would i implement this peice of code to generate a random number within the parameters set \/ \/ \/

int minimumValue=0;
int maximumValue=5;
Random rNum = new Random();
int randomNumber= rNum.Next(minimumValue,maximumValue);

I don't have a clue how it works?... :thumbsup:


For more information on using the Random functionality in C# I suggest you to read the following:
C# Corner, Random Number
Microsoft, Random Function

I hope this helps you, I'm not 100% sure on the included code since I couldn't check it on this computer.

#6 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:03:01 PM

Posted 20 November 2008 - 03:04 PM

Thankyou NiJor :thumbsup: some brilliant advice, thankyou so much.
I tryed it and it worked this time.
Thanks NiJor,
Wolfy87.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users