Adding to Advmemo Undolist

I have a function that adds "" to the beginning of selected lines. Because I am manipulating the memo contents programmatically, the undolist does not have entries for the changes. I have spent a fair amount of time looking at the the various TUndo descendents but can't figure out out to add the changes to the undo list. Can you point me in the right direction? The code for the function is below:

procedure TEditForm.CommentExecute(Sender: TObject);
var
  I, Temp, SelStart, SelEnd: Integer;
begin
  SelStart := Memo1.SelStartY;
  SelEnd := Memo1.SelEndY;
  if SelStart > SelEnd then
  begin
    Temp := SelEnd;
    SelEnd := SelStart;
    SelStart := Temp;
  end;
  for I := SelStart to SelEnd do
  begin
    Memo1.Lines := '' + Memo1.Lines;
  end;
  Memo1.ClearSelection;
end;


Also, I have some functions that use the Memo.Lines.Insert() to replace selected text. Could you also point me in the right direction on adding changes made in that manner to the undolist?

Thank you very much!

Directly manipulating AdvMemo.Lines is indeed not tracked by the undo buffer (by design).
To insert text tracked by the undo buffer, please use AdvMemo.InsertText()