Results 1 to 6 of 6

Thread: How to hide and show cursor in Visual C + +

  1. #1
    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.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    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.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    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.

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    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.

  5. #5
    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.

  6. #6
    Join Date
    Feb 2008
    Posts
    1,852

    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.

Similar Threads

  1. How to hide or lock Cursor in Dark Souls game
    By Thaddeu$ in forum Video Games
    Replies: 3
    Last Post: 29-08-2012, 07:02 PM
  2. What is Hide Method in Visual basic?
    By ^MALARVIZHI^ in forum Software Development
    Replies: 4
    Last Post: 02-01-2011, 06:05 AM
  3. Replies: 5
    Last Post: 23-11-2010, 07:33 AM
  4. Need help to show/hide div
    By Nutty in forum Software Development
    Replies: 3
    Last Post: 15-04-2009, 11:54 PM
  5. Hide cursor in Power Point presentation
    By jeffcoo in forum Windows Software
    Replies: 3
    Last Post: 24-02-2009, 09:40 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,297,197.20449 seconds with 16 queries