Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2004

Tip: Looking for answers? Try searching our database.

Change cursor and reset it again to default

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mphanke - 11 Jun 2004 13:19 GMT
Hi,

I have a snippet which makes me go mad!

The clip region of the Cursor is set correctly, but I can't reset it
anymore afterwards! This really drives me nuts, because I don't
understand what is exactly happening at thsi point.

Can anybody tell me what is wrong with this:

        void OnMouseClick(Object * sender, MouseEventArgs * mea)
        {
            if(mea->Button == MouseButtons::Left)
            {
                m_bLeft = !m_bLeft;
                if(m_bLeft)
                {
                    Cursor::Current->Clip =
Rectangle(m_PicBox->PointToScreen(Point(m_PicBox->ClientRectangle.Left,
m_PicBox->ClientRectangle.Top)), m_PicBox->Size);
                }
                else
                {
                    Cursor::Current = Cursors::Default;
                }
            }
        }

Thanks,

Martin
Gary Chang - 12 Jun 2004 10:48 GMT
Hi Martin,

I tested your code snippet in a WinForm MC++ project, the following line:
Cursor::Current = Cursors::Default;
seems never been called, it appears the cursor had already been
trapped/beloned by the picture box(m_PicBox) just after you click the left
button of the mouse first time, you cannot trap it in the original function
again.

So I modify the code as following:
...
System::Void Form1_MouseUp(System::Object* sender,
System::Windows::Forms::MouseEventArgs* mea)
{
    if(mea->Button == MouseButtons::Left){
         Cursor::Current->Clip =
Rectangle(m_PicBox->PointToScreen(Point(m_PicBox->ClientRectangle.Left,
m_PicBox->ClientRectangle.Top)), m_PicBox->Size);
}

}

System::Void m_PicBox_MouseUp(System::Object* sender,
System::Windows::Forms::MouseEventArgs* mea)
{
    if(mea->Button == MouseButtons::Left){
        this->Cursor = new
System::Windows::Forms::Cursor(Cursor::Current->Handle);
        Cursor::Clip =  Rectangle(this->Location, this->Size);
   }
}
...

Wish it helps!

Best regards,

Gary Chang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
mphanke - 12 Jun 2004 12:08 GMT
Hi Gary,

thanks for your help! I haven't had time to implement this at the
moment, but I will tomorrow.. I will give you feedback then. Do you have
any idea why this behaviour is?

Martin
mphanke - 12 Jun 2004 13:04 GMT
Hi Gary,

okay, I figured it out! The problem was I was changing the cursor on the
MouseDown event - this does not work...

Thanks alot for your support!

Martin

Snippet for whoever is interested:

        void OnMouseUp(Object * sender, MouseEventArgs * mea)
        {
            if(mea->Button == MouseButtons::Left)
            {
                m_bLeft = !m_bLeft;
                if(m_bLeft)
                {
                    m_rectClip = Rectangle(Cursor::Current->Clip);
                    Cursor::Current->Clip =
Rectangle(m_PicBox->PointToScreen(Point(m_PicBox->ClientRectangle.Left,
m_PicBox->ClientRectangle.Top)), m_PicBox->Size);
                }
                else
                {
                    m_ParentForm->Cursor = new
System::Windows::Forms::Cursor(Cursor::Current->Handle);
                    Cursor::Clip = Rectangle(m_rectClip);
                }
            }
        }
"Gary Chang" - 15 Jun 2004 04:16 GMT
Hi Martin,

Thanks for your response and I am glad to know you got the solution!

Good Luck!

Best regards,

Gary Chang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.