Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Cursor constructor not working with .cur file

$
0
0

Hi I have tried using the Cursor constructor by passing a file name to it and it fails when it is passed a valid cursor file.

The simple test code is as follows which changes the cursor property of panel on a form

Note that when passed an appropriate ICO file, it works, but fails when passed a CUR file.

usingSystem;

usingSystem.Windows.Forms;

namespacecursor_test

{

publicpartialclassForm1:Form

{

publicForm1()

{

InitializeComponent();

}

privateboolChangeCursor()

{

openFileDialog1.DefaultExt ="cur";

openFileDialog1.Filter ="Cursor|*.cur|Icon|*.ico";

if(openFileDialog1.ShowDialog() == DialogResult.OK)

{

try

{

stringfileName = openFileDialog1.FileName;

panel_Cursor.Cursor =newCursor(fileName);

MessageBox.Show(String.Concat("Cursor set to: ", fileName));

}

catch(ExceptionE)

{

MessageBox.Show(E.Message);

returnfalse;

}

returntrue;

}

returnfalse;

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

ChangeCursor();

}

}

}


Viewing all articles
Browse latest Browse all 8156

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>