Creating a Customized Mouse Pointer

Aside from using pre-defined mouse pointers such as Cursors.Arrow and Cursors.Cross, you can also use customized mouse pointers in Visual F#. Follow these steps for a simple example:

1. Download a cursor creator software such as Axialis CursorWorkShop or Icon Craft.

2. Create a .cur file and name it “pointer.cur”.

3. Start Visual F#>Create a new Project.

4. Enter the following codes:

// Learn more about F# at http://fsharp.net
//specifies the memory location of the class files
//that will be needed in our application
open System.Collections.Generic
open System
open System.Windows.Forms
open System.ComponentModel
open System.Drawing
let mouseform = new Form(Text="Cutom Mouse Pointer",AutoScaleDimensions=new System.Drawing.SizeF(60.0F, 13.0F),ClientSize=new System.Drawing.Size(300, 250),StartPosition=FormStartPosition.CenterScreen)
//creates our control
let exitbutton=new Button(Text="Exit", Location=new System.Drawing.Point(200, 200))
let customcur=new System.Windows.Forms.Cursor("pointer.cur")
mouseform.MouseHover.Add(fun cutom->mouseform.Cursor<-customcur) 
mouseform.Controls.Add(exitbutton)                                                                                                
exitbutton.Click.Add(fun quit->mouseform.Close())                                                          
//executes our application
Application.Run(mouseform)

5. Click the Open Folder>bin>debug> then copy and paste pointer.cur.

6. Run your application

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.