天天看点

TMemo

//全选功能
procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  If (Shift = [ssCtrl]) And (Key = 65) then
    Memo1.SelectAll;
end;
           
//鼠标点击指定行,显示指定行数据
procedure TForm1.Memo1Click(Sender: TObject);
Var
  LineY, LineX: Integer;
  S: WideString;
begin
  LineY := SendMessage(Memo1.Handle, EM_LINEFROMCHAR, Memo1.SelStart, 0);
  LineX := SendMessage(Memo1.Handle, EM_LINEINDEX, LineY, 0);
  S := Memo1.Lines.Strings[LineY];
  Showmessage(S);
end;
           
procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if (Shift = [ssAlt]) And (Key = $53) then  //Alt+S
  Begin
    Showmessage(Memo1.Text);
  End;
end;