VisualC ++ 6.0API function operation skill set

Source: Internet
Author: User
Welcome to the CC ++ programming community forum, and interact with 3 million technical staff to enter the process of compiling the application software. We often need to operate the cursor and mouse, in this article, I introduced the API functions for mouse and cursor operations in Windows, and provided how to use the introduced API functions in VisualC6.0 ++ to implement mouse and light

Welcome to the C/C ++ programming community forum, and interact with 3 million technical staff> in the process of compiling the application software, we often need to operate the cursor and mouse, in this article, I introduced the API functions for mouse and cursor operations in Windows, and introduced how to use the introduced API functions in Visual C6.0 ++ to implement mouse and light

Welcome to the C/C ++ programming Community Forum and interact with 3 million technical staff> enter

In the process of compiling the application software, we often need to operate the cursor and the mouse. In this article, I introduced the Windows system's API functions for operating the mouse and the cursor, it also provides the code for using the introduced API functions in Visual C6.0 ++ to perform operations on the mouse and the optical mark.

1. Hide and display the cursor

Function: int ShowCursor (BOOL bShow );

The bshow parameter is a Boolean value. If the bShow parameter is set to False, the cursor is hidden. If the bshow parameter is set to True, the cursor is displayed. the return value of this function is an integer type, which is an exponent hidden or displayed by the mouse; when the return value is greater than or equal to 0, the cursor is displayed; otherwise, the mouse is hidden; if the initial value of the mouse is installed, the cursor is 0.

Instance:

In the dialog box-based application, place two buttons named HideCursor and ShowCursor, and then place a CStatic control named Label1 to display the cursor counter.

Source code:

// Reduce the value of the cursor counter by one. If the value is smaller than zero, hide the cursor.
Void CMyTestDlg: OnHideCursor ()
{
Int I;
I = ShowCursor (FALSE );
Cstring string;
String. Format (_ T ("% d"), I );
Label1.SetWindowText (& string );
}
// Add one to the value of the cursor counter. If the value is greater than or equal to zero, the cursor is displayed.
Void CMyTestDlg: OnShowCursor ()
{
Int j;
J = ShowCursor (TRUE );
Cstring string;
String. Format (_ T ("% d"), j );
Label1.SetWindowText (& string );
}
Run the program and click the ShowCursor button consecutively. You will see that the counter is continuously incremented by 1 from 1 (when the cursor is displayed, the initial value is 0). Then, click the HideCursor button consecutively, the counter is reduced by 1. When the counter is-1, the cursor is hidden.

2. Switch the left and right mouse buttons and restore

Function:

BOOL SwapMouseButton (BOOL fSwap );
The fSwap parameter is a Boolean value. "TRUE" indicates that the left and right mouse keys are switched. "FALSE" indicates that the default left and right hand habits are restored. The return value is also a Boolean value. After the switch, the return value is TRUE, and the return value is FALSE.

Instance:

Put two buttons in the application, with the names ReverseMouse and RestoreMouse respectively.

Source code:

// Exchange the left and right mouse keys
Void CMyTestDlg: OnReverseMouse ()
{
Bool t;
T = SwapMouseButton (True );
If (T)
MessageBox ("the left and right mouse keys are exchanged successfully! ");
}

// Restore the left and right mouse Key Exchange
Void CMyTestDlg: OnRestoreMouse ()
{
Bool t;
T = SwapMouseButton (FALSE );
If (! T)
MessageBox ("the left and right mouse keys are restored to the default status! ");
}
Run the program and left-click ReverseMouse to switch between the left and right mouse keys. Right-click RestoreMouse to restore the function.


3. Get the double-click Time

1. functions:
UINT GetDoubleClickTime (VOID );

[1] [2]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.