技术文章 > 键盘事件

键盘事件

2018-10-19 23:16

文档管理软件,文档管理系统,知识管理系统,档案管理系统的技术资料:

void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if( Shift.Contains(ssShift) ) // 如果按下了Shift键则在第一个面板上显示Shift
StatusBar1->Panels->Items[0]->Text = “Shift“;
if( Shift.Contains(ssAlt)) // 如果按下了Alt键则在第二个面板上显示Alt
StatusBar1->Panels->Items[1]->Text = “Alt“;
if( Shift.Contains(ssCtrl) ) // 如果按下了Ctrl键则在第三个面板上显示Ctrl
StatusBar1->Panels->Items[2]->Text = “Ctrl“;
if( Shift.Contains(ssAlt)&&(Shift.Contains(ssCtrl))) // 如果同时按下了Alt+Ctrl键则在第二个面板上显示Alt+Ctrl
StatusBar1->Panels->Items[5]->Text = “Alt+Ctrl“;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormKeyUp(TObject *Sender, WORD &Key,
TShiftState Shift)
{
// 在Shift、Alt和Ctrl键弹起时清除状态栏中相应面板上的内容
if( !(Shift.Contains(ssShift)) )
StatusBar1->Panels->Items[0]->Text = ““;
if( !(Shift.Contains(ssAlt)) )
StatusBar1->Panels->Items[1]->Text = ““;
if( !(Shift.Contains(ssCtrl)) )
StatusBar1->Panels->Items[2]->Text = ““;
if( !Shift.Contains(ssAlt)&&(!Shift.Contains(ssCtrl)))
StatusBar1->Panels->Items[5]->Text = ““;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
if( Shift.Contains(ssLeft) ) // 如果按下了左键则在第四个面板上显示left
StatusBar1->Panels->Items[3]->Text = “Left“;
if( Shift.Contains(ssMiddle) ) // 如果按下了中键则在第五个面板上显示Middle
StatusBar1->Panels->Items[4]->Text = “Middle“;
if( Shift.Contains(ssDouble) ) // 如果是双击则在第六个面板上显示Double
StatusBar1->Panels->Items[5]->Text = “Double“;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
// 在鼠标按键弹起时清除状态栏中相应面板上的内容
if( !(Shift.Contains(ssLeft)) )
StatusBar1->Panels->Items[3]->Text = ““;
if( !(Shift.Contains(ssMiddle)) )
StatusBar1->Panels->Items[4]->Text = ““;
if( !(Shift.Contains(ssDouble)) )
StatusBar1->Panels->Items[5]->Text = ““;
}