private:
void __fastcall ShowEditPos(TObject *Sender);
// 於 .cpp 檔案:
void __fastcall TForm1::ShowEditPos(TObject *Sender)
{
int col = ((TCustomMemo*)Sender)->CaretPos.x + 1;
int line = ((TCustomMemo*)Sender)->CaretPos.y + 1;
StatusBar1->Panels->Items[0]->Text = "Line: "+IntToStr(line);
StatusBar1->Panels->Items[1]->Text = "Col: "+IntToStr(col);
}
// Memo 物件使用範例
void __fastcall TForm1::Memo1KeyUp(TObject *Sender, WORD &Key,
TShiftState Shift)
{
ShowEditPos(Memo1);
}
轉載自:http://tinyurl.com/27733s
沒有留言:
張貼留言