/*鼠标指针不再MaskEdit范围中,则MaskEdit无焦点*/
void __fastcall TForm1::MaskEditMouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
{
TMaskEdit *MaskEdit = dynamic_cast<TMaskEdit *>(Sender);
if(MaskEdit){ //若鼠标指针移动下的MaskEdit 与取得焦点的对象不同
if(::GetCapture() != MaskEdit->Handle){ //由鼠标指针移动下的MadkEdit取得焦点
::SetCapture(MaskEdit->Handle); //::SetFocus(MaskEdit->Handle);
ActiveControl = MaskEdit;
}
RECT R = static_cast<RECT>(MaskEdit->ClientRect);
POINT P = Point(X,Y);
//若鼠标指针不再MaskEdit范中,则从现在对象释放焦点,使得MaskEdit皆无焦点
if(!::PtInRect(&R,P)){
::ReleaseCapture();
::SetFocus(NULL);
}
}
}
void __fastcall TForm1::CheckBox1Click(TObject *Sender)
{
if(CheckBox1->Checked){ //交换鼠标左右键功能
::SwapMouseButton(true);
StaticText1->Caption = "鼠标左右键现在交换中!";
}
else{ //鼠标左右键现在恢复正常
::SwapMouseButton(false);
StaticText1->Caption = "鼠标左右键现在恢复正常!";
}
}
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
//预先将现在双击间隔时间保存
Tag = ::GetDoubleClickTime(); //取得鼠标双击时间
StaticText1->Caption = "鼠标双击间隔为"+AnsiString(Tag)+" 毫秒";
}
void __fastcall TForm1::FormDblClick(TObject *Sender)
{
int gtime = ::GetDoubleClickTime() - 20; //将双击间隔时间逐渐减小
::SetDoubleClickTime(gtime); //重设双击间隔时间
StaticText1->Caption = "鼠标双击间隔为"+AnsiString(gtime)+" 毫秒";
Color = (Button5->Default)?(TColor)RGB(128,255,200):(TColor)RGB(255,200,128);
Button5->Default = !Button5->Default;
}
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
::SetDoubleClickTime(Tag); //恢复双击原速度
::SwapMouseButton(false); //离开程序,恢复鼠标左右键正常状态
}