First, hide and display the cursor
function: int showcursor (BOOL bshow);
Parameter bshow, is a Boolean, hides the cursor when the bshow value is false, displays the cursor when True, the return value of the function is an integer, the exponent that is hidden or displayed for the mouse, the return value is greater than or equal to 0 o'clock displays the cursor, otherwise hides the mouse;
Instance:
Place two button in a dialog based application named Hidecursor and ShowCursor, and then place a CStatic control, named Label1, to display the cursor counter.
The source program is:
// 使光标计数器的值减一,如果小于零,隐藏光标
void CMyTestDlg::OnHideCursor()
{
int i;
i=ShowCursor(FALSE);
Cstring string;
string.Format(_T("%d" ),i);
Label1.SetWindowText(&string);
}
// 使光标计数器的值加一,如果大于等于零,显示光标
void CMyTestDlg::OnShowCursor()
{
int j;
j=ShowCursor(TRUE);
Cstring string;
string.Format(_T("%d" ),j);
Label1.SetWindowText(&string);
}
Run the program, click the ShowCursor button continuously, you will see the counter from 1 (the initial value of the cursor is 0) began to add 1, and then click the Hidecursor button continuously, you will see the counter continuously minus 1, when the counter is-1 o'clock to start hiding the cursor.
Second, the exchange of mouse around key and restore
Function:
BOOL Swapmousebutton (bool Fswap);
Parameter Fswap, Boolean, true to exchange the left and right side of the mouse key, false to restore the system default handedness; The return value is also a Boolean, and after the exchange, the return value is true, restoring the normal value to false.
Instance:
Place two button in the application, named Reversemouse and Restoremouse respectively.
The source program is:
//交换鼠标左右键
void CMyTestDlg::OnReverseMouse()
{
BOOL T;
T=SwapMouseButton(True);
If(T)
MessageBox("鼠标左右键交换成功!");
}
// 恢复鼠标左右键交换
void CMyTestDlg::OnRestoreMouse()
{
BOOL T;
T=SwapMouseButton(FALSE);
If(!T)
MessageBox("鼠标左右键恢复为默认状态!");
}
Run the program, left-click Reversemouse button, at this point to achieve the mouse left and right key function switch, and then right-click the Restoremouse button, at this point to achieve the mouse left key function recovery.