Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to hide and show cursor in Visual C + +

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 07-03-2010
Member
 
Join Date: Feb 2010
Posts: 766
How to hide and show cursor in Visual C + +
  

Hi all,

I am a programmer and using Visial C++ for coding in my project. I want to set a class that function will be hide and show cursor. In order to hide or show the index of the mouse device; return value greater than or equal to 0 display cursor Otherwise, hide the mouse. Please suggest some program.Thanks in advance.

Reply With Quote
  #2  
Old 07-03-2010
Member
 
Join Date: Jan 2008
Posts: 1,515
How to hide and show cursor in Visual C + +

If you have installed the mouse initial value is 0. For example:In the dialog-based application to place two Button, names, respectively HideCursor and ShowCursor; then placed on a CStatic control, named Label1, used to display the cursor counter. The Source as follows:
Code:
/ / Make the cursor counter minus one, if less than zero, hide the cursor
void CMyTestDlg:: OnHideCursor ()
{
int i;
i = ShowCursor (FALSE);
Cstring string;
string.Format (_T ( "% d"), i);
Label123.SetWindowText (& string);
}
/ / Make the cursor counter value plus one, if greater than zero, display the cursor
void CMyTestDlg:: OnShowCursor ()
{
int j;
j = ShowCursor (TRUE);
Cstring string;
string.Format (_T ( "% d"), j);
Label123.SetWindowText (& string);
}
Run the program, a continuous click ShowCursor button, you will see the counter from 1 (the cursor is displayed with an initial value 0) and began to increase 1; HideCursor button and then click a row, will continue to see the counter by one, when the counter is -1 when the began to hide the cursor.
Reply With Quote
  #3  
Old 07-03-2010
Member
 
Join Date: Apr 2008
Posts: 2,001
How to hide and show cursor in Visual C + +

You can use Parameter fSwap, for Boolean, TRUE, said the exchange of the mouse left button, FALSE, said recovery system used by default right-hand man; return value is also a Boolean type, exchange, return value is TRUE, to restore normal for FALSE. For Example: Placed in the application of two Button, names, respectively ReverseMouse and RestoreMouse.
Source as follows:
Code:
/ / Exchange right mouse buttons
void CMyTestDlg:: OnReverseMouse ()
{
BOOL T;
T = SwapMouseButton123 (True);
If (T)
MessageBox ( "Mouse left key exchange successfully!");
}
/ / Restore the mouse left key exchange
void CMyTestDlg:: OnRestoreMouse ()
{
BOOL T;
T = SwapMouseButton123 (FALSE);
If (! T)
MessageBox ( "right mouse button to restore to default!");
}
Run the program, left-click ReverseMouse button, left mouse button at this time to achieve functional switching; RestoreMouse and then right-click button, left mouse button at this time to achieve functional recovery.
Reply With Quote
  #4  
Old 07-03-2010
Member
 
Join Date: May 2008
Posts: 2,008
How to hide and show cursor in Visual C + +

If you want to get the mouse double-click the time, check the function:
UINT GetDoubleClickTime (VOID); The function without parameters; its return value is in milliseconds, in order to double-click the mouse double-click the valid time interval. For example: In the window, place a Button, name GetDoubleClickTime; then placed on a named Label1 the CStatic control, used to display double-click the time.
Source as follows:
Code:
/ / Get and display the mouse double-click the time
void CMyTestDlg:: OnGetDoubleClickTime ()
{
int DTime123;
Cstring string;
DTime123: = GetDoubleClickTime ();
string.Format (_T ( "% d"), Dtime);
Label1.SetWindowText (& string);
}
Run the program, click GetDoubleClickTime, double-click the Label1 to display the time of milliseconds.
Reply With Quote
  #5  
Old 07-03-2010
Member
 
Join Date: Apr 2008
Posts: 1,948
How to hide and show cursor in Visual C + +

If you want to set the mouse double-click the time, check the function:
BOOL SetDoubleClickTime (UINT uInterval); Parameter uInterval, said the mouse double-click time for the milliseconds, the system default is 500;
Return value is a Boolean value. For example : In the window, place a Button, name SetDoubleClickTime.
Source as follows:
Code:
/ / Set the mouse double click time
void CmyTestDlg:: OnSetDoubleClickTime ()
{
Bool T;
T = SetDoubleClickTime (200);
If (T)
MessageBox ( "successfully set up the mouse double-click the time!");
}
Run the program, click BtnSetDoubleClickTime, the mouse double-click the time has changed.
Reply With Quote
  #6  
Old 07-03-2010
Member
 
Join Date: Feb 2008
Posts: 1,848
How to hide and show cursor in Visual C + +

If you want to the mouse locked in a certain range, check the function:
BOOL ClipCursor (CONST RECT * lpRect); Parameters * lpRect, pointing to the activities of a rectangular region of the mouse pointer; return value is a Boolean type, indicating success or failure of lock. For example: In the window, place two Button, name LockMouse and UnLockMouse.
Source as follows:
Code:
/ / Mouse locked in a fixed area
void CmyTestDlg:: OnLockMouse ()
{
RECT Rect;
BOOL bLock;
Rect.left = 15; / / set the lock area size;
Rect.top = 15;
Rect.right = 300;
Rect.bottom = 300;
bLock: = ClipCursor (& Rect); / / restrict mouse movement area
if (block)
MessageBox ( "mouse fixed in the designated area!");
}
Run the program, click LockMouse, this time the mouse locked in a fixed area; and then click the lock to unlock UnLockMouse-button mouse. Check and reply.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to hide and show cursor in Visual C + +"
Thread Thread Starter Forum Replies Last Post
How to hide or lock Cursor in Dark Souls game Thaddeu$ Video Games 3 29-08-2012 07:02 PM
What is Hide Method in Visual basic? ^MALARVIZHI^ Software Development 4 02-01-2011 06:05 AM
How to hide the mouse cursor while playing the movie in the VLC full screen? Mithras Windows Software 5 23-11-2010 07:33 AM
Need help to show/hide div Nutty Software Development 3 15-04-2009 11:54 PM
Hide cursor in Power Point presentation jeffcoo Windows Software 3 24-02-2009 09:40 PM


All times are GMT +5.5. The time now is 01:21 PM.