Author: Peter Below Given a string like '[mbOk, mbCancel]', what is a simple way to use the routines in TypInfo to produce the corresponding set? Answer: 1 uses 2 TypInfo; 3 4 function ButtonStringToSet(const S: string): TMsgDlgButtons; 5 var 6 Temp: TStringlist; 7 I: Integer; 8 N1, N2: Integer; 9 begin 10 Result := []; 11 N1 := Pos('[', S); 12 N2 := Pos(']', S); 13 if N2 = 0 then 14 N2 := Length(S) + 1; 15 Assert(N2 > N1); 16 Temp := TStringlist.Create; 17 try 18 Temp.Commatext := Copy(S, N1 + 1, N2 - N1 - 1); 19 for i := 0 to Temp.Count - 1 do 20 Include(Result, TMsgDlgBtn(TypInfo.GetEnumValue(TypeInfo(TMsgDlgBtn), 21 Trim(Temp[I])))); 22 finally 23 Temp.Free; 24 end; 25 end; 26 27 function SetToButtonString(Buttons: TMsgDlgButtons): string; 28 var 29 Temp: TStringlist; 30 Btn: TMsgDlgBtn; 31 begin 32 Temp := TStringlist.Create; 33 try 34 for Btn := Low(Btn) to High(Btn) do 35 if Btn in Buttons then 36 Temp.Add(TypInfo.GetEnumName(TypeInfo(TMsgDlgBtn), Ord(Btn))); 37 Result := Format('[%s]', [Temp.Commatext]); 38 finally 39 Temp.Free; 40 end; 41 end;