Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

DrawCommand - temporarily store a string

edited October 2012 in General
Hello,

I need to temporarily store a string (up to 22 characters) for each
DrawCommand on my report.

This value will need to be retrieved on the OnClick event.

I know the Tag property is provided for this purpose, but it only stores an
integer. Is there any way around this so that I can store a string?



--- posted by geoForum on http://www.newswhat.com

Comments

  • edited October 2012
    Hi Jay,

    The Tag property in Delphi can be used for storing an additional integer
    value or it can be typecast to component reference or a pointer.

    One (easiest) option would be to create an object or use a pre-existing
    one such as TStringList and use it to hold your string.

    DrawCommand.Tag := Integer(lStringList);
    ...
    lMyText := TStringList(DrawCommand.Tag).Text;

    Another is create and allocate a string pointer and assign to the Tag.
    This is a bit more involved due to the fact that memory needs to be
    allocated for the string with Unicode characters taken into account.


    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2012
    Hello Nico,

    Many thanks! I'm not a Delphi programmer at all, but I managed to fumble my
    way through it and have achieved what I needed.

    Your assistance was very useful - thanks again!

    Jay



    --- posted by geoForum on http://www.newswhat.com
This discussion has been closed.