Well, I handle onMouseDown, onMouseMove and onMouseUp events (in my case on a DXDraw component). It's matter of converting pixel based coordinates to map based coordinates, then write to the map the index of your selected tile (in my case there is a DXImageList with all tiles). For example:

[pascal]
procedure TForm1.DXDraw1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer);
var
TileX, TileY: integer;
begin
TileX := X div (myMap.TileSize);
TileY := Y div (myMap.TileSize);
if button = mbLeft then
// curlayer is the index of the current layer
// TileSelected is the tile I want to draw
begin
// handle Undo here
myMap.Layer[curlayer].Tiles[TileX, TileY].TileIndex := TileSelected;
end;
end;
[/pascal]