📄 mouse.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "mouse.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ChartfxLib_TLB"
#pragma resource "*.dfm"
TForm1 *Form1;
// Initialize array of hit element descriptions
LPSTR sHitName[] = {"Background","2D Background Area","3D Background Area",
"Value (middle)","Point Marker","Y Axis","Secondary Y-Axis","X-Axis","Secondary X Axis",
"Left Title","Rigth Title","Top Title","Bottom Title"};
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
ICfxAxisDisp pAxis;
// Enable MouseMoving Event
ChartFX1->SendMsg(0,0,CT_TRACKMOUSE); // Can't use TypeMask because of BUG in LIBIMP. Yet another !
// Show Secondary Y-Axis
ChartFX1->Axis->get_Item(AXIS_Y2,&pAxis);
pAxis.Min = 0;
pAxis.Max = 300;
pAxis.Visible = TRUE;
// Show Titles
ChartFX1->Title[CHART_LEFTTIT] = L"What's this ?";
ChartFX1->Title[CHART_TOPTIT] = L"What's this ?";
ChartFX1->Title[CHART_RIGHTTIT] = L"What's this ?";
ChartFX1->Title[CHART_BOTTOMTIT] = L"What's this ?";
// ChartFX1->OnMouseMoving = TForm1::ChartFX1MouseMoving;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ChartFX1MouseMoving(TObject *Sender, short x,short y, short* nRes)
{
short nHit;
short nSeries;
long nPoint;
char s[80];
wsprintf(s,"%d",x);
Edit1->Text = s;
wsprintf(s,"%d",y);
Edit2->Text = s;
nHit = ChartFX1->HitTest(x, y, &nSeries, &nPoint);
wsprintf(s,"%d",nSeries + 1);
Edit3->Text = s;
wsprintf(s,"%d",nPoint + 1);
Edit4->Text = s;
Edit5->Text = sHitName[nHit];
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -