请高手帮我把BCB的小小东西翻译成DELPHI 谢谢
TPanel *pp = dynamic_cast <TPanel *> (Sender);
TLabel *ll = dynamic_cast <TLabel *> (Sender);
if (!pp && ll)
pp = dynamic_cast <TPanel *> (ll-> Parent);
if (pp)
ShowMessage(pp-> Caption);
[解决办法]
//void __fastcall TForm1::lwv(TObject *Sender)
procedure TForm1.lwv(Sender:TObject);
//{TPanel *pp = dynamic_cast <TPanel *> (Sender);
// TLabel *ll = dynamic_cast <TLabel *> (Sender);
var
pp:TPanel;
ll:TLabel;
begin
pp:=nil;
ll:=nil;
if Sender is TPanel then
pp:=Sender as TPanel;
if Sender is TLabel then
ll:=Sender as TLabel;
//if (!pp && ll)
if(Not Assigned(pp)) and Assigned(ll) then
//pp = dynamic_cast <TPanel *> (ll-> Parent);
if Assigned(ll.Parent) then
if ll.Parent is TPanel then
pp:=ll.Parent as TPanel;
//if (pp)
if Assigned(pp) then
//ShowMessage(pp-> Caption);
ShowMessage(pp.Caption);
// }
end;