有对DLL中引出“类”熟悉的富翁请进,看看这段代码错误出在哪儿!? ( 积分: 50 )

  • 主题发起人 主题发起人 TrustMe
  • 开始时间 开始时间
T

TrustMe

Unregistered / Unconfirmed
GUEST, unregistred user!
// trGLBase.inc 文件<br>{$IFDEF trGLBase}<br>uses Windows, trCtrl, OpenGL, OpenGLX;<br>{$ENDIF}<br>type<br> trGLBaseObj = class<br> private<br> &nbsp;{$IFDEF trGLBase}<br> &nbsp;FSelected: boolean;<br> &nbsp;FOnAfterDraw: trNotifyEvent;<br> &nbsp;FOnBeforeDraw: trNotifyEvent;<br> &nbsp;procedure Draw;virtual;abstract;<br> &nbsp;procedure DrawSelected;virtual;abstract;<br> &nbsp;{$ENDIF}<br> &nbsp;function &nbsp;GetSelected: boolean;virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> &nbsp;procedure SetSelected(const value: boolean);virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> &nbsp;function &nbsp;GetOnAfterDraw: trNotifyEvent;virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> &nbsp;procedure SetOnAfterDraw(const value: trNotifyEvent);virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> &nbsp;function &nbsp;GetOnBeforeDraw: trNotifyEvent;virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> &nbsp;procedure SetOnBeforeDraw(const value: trNotifyEvent);virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> public<br> &nbsp;{$IFDEF trGLBase}<br> &nbsp;constructor Create;<br> &nbsp;{$ENDIF}<br> &nbsp;procedure ReDraw;virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> published<br> &nbsp;property Selected: boolean read GetSelected Write SetSelected;<br> &nbsp;<br> &nbsp;property OnAfterDraw: trNotifyEvent read GetOnAfterDraw write SetOnAfterDraw;<br> &nbsp;property OnBeforeDraw: trNotifyEvent read GetOnBeforeDraw write SetOnBeforeDraw;<br> end;<br>// trGLBase.pas 文件<br>unit trGLBase;<br>{$DEFINE trGLBase}<br>interface<br>{$I trGLBase.inc}<br>implementation<br><br>function trGLPtNew: trGLPointObj;<br>begin<br> result:= trGLPointObj.Create;<br>end;<br><br>{trGLBaseObj}<br><br>constructor trGLBaseObj.Create;<br>begin<br> FSelected:= False;<br> FOnAfterDraw:= nil;<br> FOnBeforeDraw:= nil;<br>end;<br><br>function &nbsp;trGLBaseObj.GetSelected: boolean;<br>begin<br> result:= FSelected;<br>end;<br><br>procedure trGLBaseObj.SetSelected(const value: boolean);<br>begin<br> if value &lt;&gt; FSelected then begin<br> &nbsp;FSelected:= value;<br> &nbsp;ReDraw;<br> end;<br>end;<br><br>function &nbsp;trGLBaseObj.GetOnAfterDraw: trNotifyEvent;<br>begin<br> result:= FOnAfterDraw;<br>end;<br><br>procedure trGLBaseObj.SetOnAfterDraw(const value: trNotifyEvent);<br>begin<br> FOnAfterDraw:= value;<br>end;<br><br>function &nbsp;trGLBaseObj.GetOnBeforeDraw: trNotifyEvent;<br>begin<br> result:= FOnBeforeDraw;<br>end;<br><br>procedure trGLBaseObj.SetOnBeforeDraw(const value: trNotifyEvent);<br>begin<br> FOnBeforeDraw:= value;<br>end;<br><br>procedure trGLBaseObj.ReDraw;<br>begin<br> if Assigned(FOnBeforeDraw) then FOnBeforeDraw(Self); // 注:代码执行到此处时,出错<br> Draw;<br> if FSelected then DrawSelected;<br> if Assigned(FOnAfterDraw) then FOnAfterDraw(Self);<br>end;<br>另,本人初学OpenGL,哪位富翁对此感兴趣或已有造诣者,欢迎QQ:22627167(身份验证时,请注明:大富翁,OpenGL字样,谢谢!)交流!
 
// trGLBase.inc 文件<br>{$IFDEF trGLBase}<br>uses Windows, trCtrl, OpenGL, OpenGLX;<br>{$ENDIF}<br>type<br> trGLBaseObj = class<br> private<br> &nbsp;{$IFDEF trGLBase}<br> &nbsp;FSelected: boolean;<br> &nbsp;FOnAfterDraw: trNotifyEvent;<br> &nbsp;FOnBeforeDraw: trNotifyEvent;<br> &nbsp;procedure Draw;virtual;abstract;<br> &nbsp;procedure DrawSelected;virtual;abstract;<br> &nbsp;{$ENDIF}<br> &nbsp;function &nbsp;GetSelected: boolean;virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> &nbsp;procedure SetSelected(const value: boolean);virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> &nbsp;function &nbsp;GetOnAfterDraw: trNotifyEvent;virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> &nbsp;procedure SetOnAfterDraw(const value: trNotifyEvent);virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> &nbsp;function &nbsp;GetOnBeforeDraw: trNotifyEvent;virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> &nbsp;procedure SetOnBeforeDraw(const value: trNotifyEvent);virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> public<br> &nbsp;{$IFDEF trGLBase}<br> &nbsp;constructor Create;<br> &nbsp;{$ENDIF}<br> &nbsp;procedure ReDraw;virtual;{$IFDEF trDLL}abstract;{$ENDIF}<br> published<br> &nbsp;property Selected: boolean read GetSelected Write SetSelected;<br> &nbsp;<br> &nbsp;property OnAfterDraw: trNotifyEvent read GetOnAfterDraw write SetOnAfterDraw;<br> &nbsp;property OnBeforeDraw: trNotifyEvent read GetOnBeforeDraw write SetOnBeforeDraw;<br> end;<br>// trGLBase.pas 文件<br>unit trGLBase;<br>{$DEFINE trGLBase}<br>interface<br>{$I trGLBase.inc}<br>implementation<br><br>function trGLPtNew: trGLPointObj;<br>begin<br> result:= trGLPointObj.Create;<br>end;<br><br>{trGLBaseObj}<br><br>constructor trGLBaseObj.Create;<br>begin<br> FSelected:= False;<br> FOnAfterDraw:= nil;<br> FOnBeforeDraw:= nil;<br>end;<br><br>function &nbsp;trGLBaseObj.GetSelected: boolean;<br>begin<br> result:= FSelected;<br>end;<br><br>procedure trGLBaseObj.SetSelected(const value: boolean);<br>begin<br> if value &lt;&gt; FSelected then begin<br> &nbsp;FSelected:= value;<br> &nbsp;ReDraw;<br> end;<br>end;<br><br>function &nbsp;trGLBaseObj.GetOnAfterDraw: trNotifyEvent;<br>begin<br> result:= FOnAfterDraw;<br>end;<br><br>procedure trGLBaseObj.SetOnAfterDraw(const value: trNotifyEvent);<br>begin<br> FOnAfterDraw:= value;<br>end;<br><br>function &nbsp;trGLBaseObj.GetOnBeforeDraw: trNotifyEvent;<br>begin<br> result:= FOnBeforeDraw;<br>end;<br><br>procedure trGLBaseObj.SetOnBeforeDraw(const value: trNotifyEvent);<br>begin<br> FOnBeforeDraw:= value;<br>end;<br><br>procedure trGLBaseObj.ReDraw;<br>begin<br> if Assigned(FOnBeforeDraw) then FOnBeforeDraw(Self); // 注:代码执行到此处时,出错<br> Draw;<br> if FSelected then DrawSelected;<br> if Assigned(FOnAfterDraw) then FOnAfterDraw(Self);<br>end;<br>另,本人初学OpenGL,哪位富翁对此感兴趣或已有造诣者,欢迎QQ:22627167(身份验证时,请注明:大富翁,OpenGL字样,谢谢!)交流!
 
来了,QQ细说
 
问题解决了,子类重载的问题,将此处改为:<br>protected<br> &nbsp;procedure Draw;virtual;abstract;<br> &nbsp;procedure DrawSelected;virtual;abstract;<br>谢谢chenybin。
 
后退
顶部