473,378 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Change cursor and reset it again to default

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
Nov 17 '05 #1
4 5797
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

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Nov 17 '05 #2
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
Nov 17 '05 #3
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);
}
}
}
Nov 17 '05 #4
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

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

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Wayne Wengert | last post by:
In VB.NET is there a way to set the mouse cursor to the Wait cursor that will stay in effect across several forms? For example, I want to set the cursor to the WaitCursor in formA just before it...
6
by: Jan Heppen | last post by:
Is it posible to set something so that when my vb.net (visual studio 2005, framework 2.0) application is busy that the mouse pointer change into a hourglass ? Or do i have to set everywhere...
7
by: Academic | last post by:
What are the different effects of the following two statements: C1.Cursor = Cursors.WaitCursor C1.Cursor.Current = Cursors.WaitCursor I believe the first replaces the entire C1.Cursor...
10
by: Franky | last post by:
I think I misread a post and understood that if I do: System.Windows.Forms.Cursor.Current = Cursors.WaitCursor there is no need to reset the cursor to Default. So I made all the reset...
12
by: info | last post by:
Hi All, I am trying to set the hourglass cursor inside a class that has nothing to do with MainForm class and I don't want to pass a reference to MainForm. How can I set the current cursor to...
9
by: KDawg44 | last post by:
Hi, I am brand new to Python. In learning anything, I find it useful to actually try to write a useful program to try to tackle an actual problem. I have a syslog server and I would like to...
5
by: =?Utf-8?B?UGVy?= | last post by:
I want to change the current path in the OpenFileDialog in runtime. When the user presses OK-button I'm checking the selected path if it's valid for my application. If it's not valid I want to set...
1
by: Frank Swarbrick | last post by:
We're trying to take advantage of the new ROW CHANGE TIMESTAMP option. Here is a simple table: CREATE TABLE "ACCTASGN"."NUMBER_STATUS" ( "STATUS_CODE" CHAR(1) NOT NULL , "STATUS_DESCRIPTION"...
4
by: mike | last post by:
I have the opportunity to rescue a project that uses a mouse to sense the relative position of a machine. The hardware is built...just needs to be programmed. Stop snickering!!! I didn't do it...I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.