Thursday, 18 June 2020

D&D in Delphi source code?

- or does your device support Phone, Tablet or Elf?!

While looking through some of the RTL source code, in the quest for the "Tablet" mode (see my previous post from yesterday) - I stumbled upon the TDeviceInfo.TDeviceClass enum.

So my small application has just listed the ID and the name of the TDeviceClass enum, for my old Surface Pro - together with one I added for fun. The one I added has a strange TDeviceClass value.

Following that is the full list of named enum values of TDeviceInfo.TDeviceClass - notice the last 3.

Maybe D&D does not refer to Dungeons & Dragons, but DeviceInfos & DeviceClasses.... well someone had fun at some point of time sneaking them in, and I hope that Embarcadero does not plan to remove those extra "classes" - since the might break backwards compatibility - with my newly added Rincewind deviceInfo :D

Just a small silly finding I wanted share - nothing useful - but no post without code :)


procedure TForm1.Button1Click(Sender: TObject);
  s: TSize;
  // Let us add a silly device := 100; := 100;
  TDeviceInfo.AddDevice(TDeviceInfo.TDeviceClass.Wizard, 'Rincewind', s, s, pfLinux, 96);
  // Let us see what are known
  Memo1.Lines.Add('-- Known devices: Name and Class');
  for var d: Integer := 0 to TDeviceInfo.DeviceCount-1 do
    Memo1.Lines.Add(TDeviceInfo.Devices[d].ID+' - '+
      GetEnumName(TypeInfo(TDeviceInfo.TDeviceClass), ord(TDeviceInfo.Devices[d].DeviceClass)));
  // Let us see possible value of a TDeviceClass
  Memo1.Lines.Add('-- TDeviceClass enums:');
  for var i: TDeviceInfo.TDeviceClass :=
    Low(TDeviceInfo.TDeviceClass) to High(TDeviceInfo.TDeviceClass) do
      Memo1.Lines.Add(GetEnumName(TypeInfo(TDeviceInfo.TDeviceClass), ord(i)));


Update: Brian Long has already mentioned this in #24 of his beatiful blong #Delphi25 post here - which I originally missed.

BTW: I used the DNDC font from

No comments:

Post a Comment