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. 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.

    Like


  2. 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.

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.