Search code examples
delphifiremonkey

TMapAccess.maReadWrite not defined using DELPHI 11


the code fragment below works fine for DELPHI 10.4 and FMX framework, but does not compile using DELPHI 11 . Error : maReadWrite not defined

[dcc64 Error] ImageUnit.FMX.pas(5340): E2003 Undeclared identifier: 'maReadWrite'

How to solve this issue and how to write code which compiles using DELPHI 10.4 and DELPHI 11 ?

 var bit : TBitmap;
 begin
  if (Bit.Map(TMapAccess.maReadWrite, bitdata1)) then
    try
      for i := 0 to Bit.width - 1 do
        for j := 0 to Bit.height - 1 do
        begin

Solution

  • The TMapAccess values that begin with the ma prefix were deprecated before 10.4 to drop the prefix (ie maRead -> Read, maWrite -> Write, maReadWrite -> ReadWrite). You should have gotten compiler warnings about this in 10.4.

    The prefixed values were finally removed completely in 11.0 Alexandria.

    So, the correct way to write this code for both versions is to simply use the newer non-prefixed value names, eg:

    if (Bit.Map(TMapAccess.ReadWrite, bitdata1)) then