📄 unit1.cpp
字号:
//---------------------------------------------------------------------------
//目的:鼠标在Form1上双击时,检测双击间隔时间,并逐渐使时间缩短
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{//预先将现在双击间隔时间保存
Tag = ::GetDoubleClickTime();
//显示现在双击间隔时间
StaticText2->Caption = "鼠标双击间隔为 " + AnsiString(Tag)+ " 毫秒";
}
//---------------------------------------------------------------------------
//若关闭此程序时,恢复双击原有速度
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
::SetDoubleClickTime(Tag);
}
//---------------------------------------------------------------------------
//当系统判定鼠标为双击事件时
void __fastcall TForm1::FormDblClick(TObject *Sender)
{//将双击间隔时间逐渐减少
int gtime = ::GetDoubleClickTime() - 20;
//重设双击间隔时间
::SetDoubleClickTime(gtime);
//显示鼠标双击时间与更改背景色彩
StaticText2->Caption = "鼠标双击间隔为" + AnsiString(gtime)+ " 毫秒";
Color=(Button1->Default)?(TColor)RGB(128,255,200):(TColor)RGB(255,200,128);
Button1->Default = !Button1->Default;
}
//---------------------------------------------------------------------------
//当系统判定鼠标为单击事件时
void __fastcall TForm1::FormClick(TObject *Sender)
{//冻结时间至越过鼠标引发双击事件的时间
//区隔OnClick事件与OnDblClick事件
::Sleep(::GetDoubleClickTime()+1);
//显示鼠标双击时间与更改背景色彩
StaticText2->Caption = "你的双击动作慢了!再快一点!";
Color = clBtnFace;
}
//---------------------------------------------------------------------------
//恢复双击原有速度
void __fastcall TForm1::Button1Click(TObject *Sender)
{
::SetDoubleClickTime(Tag);
StaticText2->Caption = "鼠标双击间隔为 " + AnsiString(Tag)+ " 毫秒";
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -