954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Change form's cursor in a static member function

I need to change the cursor in a static member function but I receive a compiler error

error C2671 : static member functions do not have 'this' pointers

this->Cursor = System::Windows::Forms::Cursors::Default;

How do I modify the code so it will work in a static member function?

Thanks.

DotNetUser
Junior Poster in Training
69 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

you cannot access class objects/methods from class static methods. There are at least two ways to overcome this:
1. pass a pointer or reference of an instance of the object to the static method, then access the objects through this pointer/reference.

2. make the object(s) static.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Since I am changing the cursor on the form itself, the form's object is not visible to make it static.

DotNetUser
Junior Poster in Training
69 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You