Because  Sender = ComponentVar is just too conservative

Because  Sender = ComponentVar is just too conservative

    if TBitBtn(Sender).Name=’bWoodPallet’

     then tPack.CarrierType:=ctWood

    else if TBitBtn(Sender).Name=’bPlasticPallet’

     then tPack.CarrierType:=ctPlastic

    else if TBitBtn(Sender).Name=’pVendorPlasticPallet’

     then tPack.CarrierType:=ctVendorPlastic;

8 thoughts on “Because  Sender = ComponentVar is just too conservative


  1. I’m not quite sure I understand what you mean, Lars.


    Personnaly I would have made a TBitBTn descendant with a CarrierType property. But what do you mean by Sender=ComponentVar ?


  2. In the dialog, the button is a variable, so you can compare the sender param with the variable, instead of casting sender to get the variable name and compare it to a string literal.  


    Component descendants are such a pain for migrations.  I don’t use packages if I can avoid it.  Too many dependencies.


    Personally, I’d prolly use the Tag value to hold the constant instead – but that’s not entirely safe as well, as even constants can change.


  3. Lars Fosdal  in fact , actually I don’t use packages in Delphi. I find them too difficult to manage when using source code control and versioning . But maybe I miss something with packages usage.

Leave a Reply to Dorin DuminicaCancel reply