Search code examples
delphidelphi-7twain

TDelphiTwain component, corrupts delphi form (dfm file)


I have downloaded opensource delphi twain component (TDelphiTwain). The interesting thing is, that when placed and saved on the form it creates bad dfm entry for itself.

  object DelphiTwain: TDelphiTwain
    OnSourceDisable = DelphiTwainSourceDisable
    OnSourceSetupFileXfer = DelphiTwainSourceSetupFileXfer
    TransferMode = ttmMemory
    SourceCount = 0
    Info.MajorVersion = 1
    Info.MinorVersion = 0
    Info.Language = tlDanish
    Info.CountryCode = 1
    Info.Groups = [tgControl, tgImage, tgAudio, MinorVersion]
    Info.VersionInfo = 'Application name'
    Info.Manufacturer = 'Application manufacturer'
    Info.ProductFamily = 'App product family'
    Info.ProductName = 'App product name'
    LibraryLoaded = False
    SourceManagerLoaded = False
    Left = 520
    Top = 136
  end

The problem is with the line:

   Info.Groups = [tgControl, tgImage, tgAudio, MinorVersion]

There are only three possible elements:

tgControl, tgImage and tgAudio

It adds MinorVersion everytime I Save the form. When the app is run I get the error that there is invalid property for Info.Groups. When i rmeove the bad part manually and without leaving dfm file the app starts ok.

I looked in the internet and there was one inquire regarding these strange issue, unfortunately it hasn't been resolved.

I think that there is some sort of memory corruption. In the post in teh internet, strange signs were displayed ...

Has anyone worked with that component or could give me some hint how this could be fixed?


Solution

  • The error seems to be in TTwainIdentity.GetGroups where result is not initialized. You can try to change the code by replacing

    Include(Result, tgControl);
    

    with

    Result := [tgControl]; 
    

    You have to recompile the package to make this change work inside the IDE.