⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getevent.cpp

📁 《C++ Builder 5技术内幕》一书附带的程序源代码
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "GetEvent.h"
#include "VirtKey.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormCapturingEvents *FormCapturingEvents;
//---------------------------------------------------------------------------
__fastcall TFormCapturingEvents::TFormCapturingEvents(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFormCapturingEvents::FormPaint(TObject *Sender)
{
  MemoInfo->Font->Name = "Times New Roman";
  MemoInfo->Font->Size = 10;
  MemoInfo->Lines->Clear();
  MemoInfo->Lines->Add( AnsiString( "Font: " ) + MemoInfo->Font->Name );
}
//---------------------------------------------------------------------------
void __fastcall TFormCapturingEvents::FormResize(TObject *Sender)
{
  AnsiString asInfo = AnsiString( "Current width is" )
                    + AnsiString( Width )
                    + AnsiString( ". Current height is" )
                    + AnsiString( Height );
  MemoInfo->Lines->Add( asInfo );
}
//---------------------------------------------------------------------------
void __fastcall TFormCapturingEvents::FormKeyDown(TObject *Sender,
      WORD &Key, TShiftState Shift)
{
  AnsiString asInfo = "Key Down: " + GetKey( Key ) + " " + GetShift( Shift );
  MemoInfo->Lines->Add( asInfo );
}
//---------------------------------------------------------------------------
void __fastcall TFormCapturingEvents::FormKeyUp(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
  AnsiString asInfo = "Key Up: " + GetKey( Key ) + " " + GetShift( Shift );
  MemoInfo->Lines->Add( asInfo );
}
//---------------------------------------------------------------------------
void __fastcall TFormCapturingEvents::FormMouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
  MemoInfo->Lines->Add( "Mouse Down:" );
  AnsiString asInfo = GetShift( Shift );
  MemoInfo->Lines->Add( asInfo );
}
//---------------------------------------------------------------------------
void __fastcall TFormCapturingEvents::FormMouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
  MemoInfo->Lines->Add( "Mouse Move:" );
  AnsiString asInfo = "X: " + IntToStr( X ) + ", Y: " + IntToStr( Y ) + " " + GetShift( Shift );
  MemoInfo->Lines->Add( asInfo );
}
//---------------------------------------------------------------------------
void __fastcall TFormCapturingEvents::FormMouseUp(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
  MemoInfo->Lines->Add( "Mouse Up:" );
  AnsiString asInfo = "X: " + IntToStr( X ) + ", Y: " + IntToStr( Y ) + " " + GetShift( Shift );
  MemoInfo->Lines->Add( asInfo );
}
//---------------------------------------------------------------------------
void TFormCapturingEvents::NewMouseMove(TWMMouse &Message)
{
  TForm::Dispatch( &Message );
  StatusBarInfo->SimpleText = "X: " + IntToStr( Message.XPos ) + ", Y: " + IntToStr( Message.YPos );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -