📄 demo4frm.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Demo4Frm.h"
//---------------------------------------------------------------------------
#pragma link "RichView"
#pragma link "RVScroll"
#pragma link "RVStyle"
#pragma resource "*.dfm"
TfrmDemo4 *frmDemo4;
//---------------------------------------------------------------------------
__fastcall TfrmDemo4::TfrmDemo4(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
const AnsiString Descriptions[8] =
{
"Exact time twice a day!",
"Unique 9-button model",
"Additional keys available on request",
"Must have for any airline!",
"Second hand",
"Universal thing",
"2 kg",
"Brooklyn Bridge, available only today, 10% discount for first 10 buyers!"
};
//---------------------------------------------------------------------------
void TfrmDemo4::BuildDoc()
{
int VPos = rv->VScrollPos;
rv->Clear();
rv->AddNL("Welcome to our shop!",1,1);
rv->AddNL("Today we have:",2,1);
for (int i=0; i<GoodsCount; i++)
{
rv->AddBulletEx("", Goods[i], ilGoods, 0);
rv->Add(pm->Items->Items[Goods[i]]->Caption,3);
rv->Add(" ("+Descriptions[Goods[i]]+") ",0);
rv->AddHotspotEx("", 2,3, il, -1);
rv->AddBreak();
}
if (GoodsCount!=10)
rv->AddHotspotEx("", 0,1, il, 0);
rv->Format();
rv->VScrollPos = VPos;
}
void __fastcall TfrmDemo4::FormCreate(TObject *Sender)
{
#if __BORLANDC__>=0x0550
pm->AutoHotkeys = maManual;
#endif
BuildDoc();
}
//---------------------------------------------------------------------------
void __fastcall TfrmDemo4::rvJump(TObject *Sender, int id)
{
if (id==GoodsCount)
{
// adding
TPoint p;
GetCursorPos(&p);
pm->Popup(p.x, p.y);
}
else
{
// deleting
for (int i=id; i<GoodsCount-1; i++)
Goods[i] = Goods[i+1];
GoodsCount--;
BuildDoc();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmDemo4::pmItemClick(TObject *Sender)
{
Goods[GoodsCount++] = ((TMenuItem*)(Sender))->MenuIndex;
BuildDoc();
rv->VScrollPos = rv->VScrollMax;
}
//---------------------------------------------------------------------------
void __fastcall TfrmDemo4::FormKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key==VK_ESCAPE)
Close();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -