C&C++论坛精华
源代码在线查看: 隐藏鼠标.txt
作者:hxfwsk
email: hxfwsk@hotmail.com
日期:8/2/2001 4:41:09 PM
如何实现象“超级解霸”中的自动隐藏鼠标功能呢?当我们欣赏VCD时,屏幕中的鼠标常常会影响观赏效果。当一段时间内,用户没有任何输入的情况下就自动隐藏鼠标,一旦用户进行任何输入立即重新显示出鼠标即可。程序段如下:
请先添加一个Timer组件,再设置Timer组件的Interval属性为1000,
//----------------------------------------------------------
#include
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
bool MouseHide;
void MouseDo();
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
MouseHide=true;
}
//---------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
MouseDo();
}
//---------------------------------------------------------------------
void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
MouseDo();
}
//---------------------------------------------------------------------
void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
MouseDo();
}
//---------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
MouseHide=true;
Screen->Cursor=crNone;// 隐藏鼠标
Timer1->Enabled=false;
}
//---------------------------------------------------------------------
void MouseDo()
{
if(MouseHide)
{
Screen->Cursor=crDefault;//显示鼠标
MouseHide=false;
}
else
Form1->Timer1->Enabled=true;