Dear Dennis, I read the help of Delphi, it says : A protected member is visible anywhere in the module where its class is declared and from any descendant class, regardless of the module where the descendant class appears.
Now I purposely make my constructor to be Protected member, then step into myPic.Graphic := nGra; in the unit of graphics.pas, the call NewGraphic := TGraphicClass(Value.ClassType).Create; of Tpicture class still call my protected construstor correctly. But nGra := gCls.Create won't. Why? //---------------------------------------- Type TMyGraphic = class(TGraphic) Protected constructor Create; override; public procedure Assign(Source: TPersistent); override; end; procedure TMyGraphic.Assign(Source: TPersistent); begin // end; constructor TMyGraphic.Create; begin inherited; CallNo := CallNo + 1; end; var CallNo : Integer; //------------------------------------------------------------------------ procedure TryIt; var gCls : TGraphicClass; nGra : TGraphic; myPic : TPicture; begin CallNo := 0; gCls := TGraphicClass(TMyGraphic); nGra := gCls.Create; ShowMessage(IntToStr(CallNo)); // 0 myPic := TPicture.Create; myPic.Graphic := nGra; ShowMessage(IntToStr(CallNo)); // 1 end; -----Original Message----- From: Jianming Lin (ASL) [mailto:JianmingL@;aslnz.co.nz] Sent: Friday, 18 October 2002 11:20 a.m. To: Multiple recipients of list delphi Subject: RE: [DUG]: polymorphism problem Dear Dennis, YOU are right, TGraphic's constructor in D5 IS INDEED protected. Thanks everyone who has replied to this thread Jianming -----Original Message----- From: Dennis Chuah [mailto:dennis_cs_chuah@;hotmail.com] Sent: Friday, 18 October 2002 11:02 a.m. To: Multiple recipients of list delphi Subject: Re: [DUG]: polymorphism problem I stepped through your code in D6 (don't have D5 installed on this machine) - but perhaps there is something wrong in D5? I am wondering in D5 whether TGraphic's constructor is protected? Dennis. ----- Original Message ----- From: "Jianming Lin (ASL)" <[EMAIL PROTECTED]> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]> Sent: Friday, October 18, 2002 9:10 AM Subject: RE: [DUG]: polymorphism problem > > > -----Original Message----- > From: Dennis Chuah [mailto:dennis_cs_chuah@;hotmail.com] > Sent: Friday, 18 October 2002 7:14 a.m. > To: Multiple recipients of list delphi > Subject: Re: [DUG]: polymorphism problem > > > > I stepped through your code and it *DEFINITELY* calls TMetadata.Create. > What you have done looks correct and this is certainly not a polymorphism > pproblem. Few suggestions: > > 1. Check that you do not have $(DELPHI)\Lib in your project path - it > should only be in the global library path. > > Checked > > 2. What if you replaced your code with: > NGraphic := TMetadata.Create; > > Step through the code - does it call TMetadata.Create? > > Yes it does > > 3. Check the class type of NGraphic and compare Pointer(NGraphic.ClassType) > against Pointer(TMetadata). Are they the same pointer values? > > Checked. still not get called. > > What version of Delphi are you using? > > D5 Ent > > > Dennis. > > ----- Original Message ----- > From: Jianming Lin (ASL) > To: Multiple recipients of list delphi > Sent: Thursday, October 17, 2002 4:35 PM > Subject: [DUG]: polymorphism problem > > > > > G'Day, guys, > > procedure TryMetadata(ImgType : Integer); > var NGraphic: TGraphic; > GraphicClass: TGraphicClass; > begin > ImgType := 1; > case ImgType of > 1 : GraphicClass := TMetaFile; > 2 : GraphicClass := TBitmap; > end; > NGraphic := GraphicClass.Create; > end; > > > Why constructor of TMetafile.Create is not called instead only > TObject.Create is called? > > > > > > [Jianming Lin (ASL)] > > > > > > This e-mail message has been scanned for Viruses and Content and cleared by > MailMarshal - For more information please visit www.marshalsoftware.com > -------------------------------------------------------------------------- - > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > Website: http://www.delphi.org.nz > To UnSub, send email to: [EMAIL PROTECTED] > with body of "unsubscribe delphi" > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ > > ############################################################################ ######### > This e-mail message has been scanned for Viruses and Content and cleared > by MailMarshal > For more information please visit www.marshalsoftware.com > ############################################################################ ######### > -------------------------------------------------------------------------- - > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > Website: http://www.delphi.org.nz > To UnSub, send email to: [EMAIL PROTECTED] > with body of "unsubscribe delphi" > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ > --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ ############################################################################ ######### This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal For more information please visit www.marshalsoftware.com ############################################################################ ######### --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ ##################################################################################### This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal For more information please visit www.marshalsoftware.com ##################################################################################### --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/