Difference between revisions of "LMD VCL - LMD Packs"

From LMD
Jump to: navigation, search
(NG Serialization)
(How to serialize collections)
Line 31: Line 31:
 
==NG Serialization==
 
==NG Serialization==
 
===How to serialize collections===
 
===How to serialize collections===
Suppose we have some item class and the corresponding collection class:
+
Serializing collections, including custom or standard collections (like TList) requires writing custom converters. For example, lets consider the folowing collection declaration:
  
 
<pre class="brush:delphi">
 
<pre class="brush:delphi">
Line 39: Line 39:
 
     X: Integer;
 
     X: Integer;
 
     Y: Integer;
 
     Y: Integer;
 +
  end;
 +
 +
  TItems = class(TObjectList<TItem>);
 +
</pre>
 +
 +
To be able to serialize it, we need to declare a converter class, and '''associate''' this class with our collection using Converter attribute:
 +
 +
<pre class="brush:delphi">
 +
type 
 +
  TItemsConverter = class(TConverter)
 +
  public
 +
    function  GetReadMode: TReadMode; override;
 +
    procedure Write(S: TSerializer; const V); override;
 +
    procedure Read(D: TDeserializer; var V); override;
 
   end;
 
   end;
  
 
   [Converter(TItemsConverter)]
 
   [Converter(TItemsConverter)]
 
   TItems = class(TObjectList<TItem>);
 
   TItems = class(TObjectList<TItem>);
 +
</pre>
 +
 +
The converter can be implemented like this:
 +
 +
<pre class="brush:delphi">
 
</pre>
 
</pre>

Revision as of 13:32, 27 May 2015

[edit]

<< Back to Overview page

LMD ShellPack

Using Paste/Copy commands at runtime

Copy: <delphi> if assigned(LMDShellList1.selected) then LMDDoContextMenuVerb( LMDShellList1, (LMDShellList1.Selected as TLMDShellListItem).ShellItem, 'copy'); </delphi> Paste: <delphi> LMDDoContextMenuVerb( LMDShellList2, LMDShellFolder2.ActiveFolder,'paste'); </delphi>

LMD RichPack

Which MS RichEdit DLL Version can I expect on a specific operating system?

Please check list of different RichEdit versions.

Searching for specific attributes

Q: I was trying out the LMD RTF wrapper (using BCB 6) and wanted to know what would be the best way to search for words or characters with a specific attribute. A:

  • Use FindTextEx
  • Check SelAttributes
    if attrs not ok then FindTextEx again.

LMD WebPack

[Linker Error] Unresolved external "InternetCloseHandle" referenced from

Simply add wininet.lib to your project (file can be found in \lib directory of your C++ Builder / BDS / CRS installation). In recent IDEs you can also add
#pragma link "wininet.lib"
in your code.

NG Serialization

How to serialize collections

Serializing collections, including custom or standard collections (like TList) requires writing custom converters. For example, lets consider the folowing collection declaration:

type
  TItem = class
  public
    X: Integer;
    Y: Integer;
  end;

  TItems = class(TObjectList<TItem>);

To be able to serialize it, we need to declare a converter class, and associate this class with our collection using Converter attribute:

type  
  TItemsConverter = class(TConverter)
  public
    function  GetReadMode: TReadMode; override;
    procedure Write(S: TSerializer; const V); override;
    procedure Read(D: TDeserializer; var V); override;
  end;

  [Converter(TItemsConverter)]
  TItems = class(TObjectList<TItem>);

The converter can be implemented like this: