原来做的基类TmyBaseFrame,因为只是增加了几个纯虚的方法,没有对于的dfm和实现代码。
现在改为也是老老实实做一个dfm,代码还是没有——因为只是增加了几个纯虚的方法
然后,具体的派生frame的dfm的第一行的object改为inherited,问题不再出现了!
Report From: Delphi-BCB/VCL/Core VCL Classes/TFrame [ Add a report in this area ]
Report #: 5866 Status: Withdrawn
TFrame inherited from a CustomFrame class with no form resource
Project: Delphi Build #: 4.453
Version: 7.0 Submitted By: Thomas Bachinger
Report Type: Basic functionality failure Date Reported: 9/5/2003 9:53:58 AM
Severity: Serious / Highly visible problem Last Updated: 9/8/2003 2:39:20 AM
Platform: 95, 98, 2000, NT, XP Internal Tracking #:
Resolution: None Resolved in Build: : None
Duplicate of: None
Voting and Rating Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 1
Description If one defines a Frame object in the code (without adding a form resource to it) and then inherits a frame that contains a form resource from this 'resource-less' frame the inherited frames resource will be changed in the object inspector in such a way that it displays all the properties that a TForm object normally deisplays in the OI. The resource file is then also changed to contain properties like OldCreateOrder which is specific to a TForm object, and therefore the frame's TReader object will raise when loading the frames resource on process start.
I now wonder if it is possible at all to inherit from a frame instance that does not have a resource assigned to it. Doing what is decribed above for a TForm object works just fine... so why does it not work for a TFrame object...? Steps to Reproduce: 1) Creating a TMyFrame object that inherites from TFrame but does not have a form resource assigned. This class just simply adds properties and
methods to the functionality of TFrame.
2) Then create a real frame from within the IDE (with a form resource) and inherit it from TMyFrame that has no form resource assigned (the new frame's
resource file must then read 'object' and not 'inherited' in the fileheader?).
Both frame declarations can be in one PAS file and look like the following:
type
TMyFrame = class(TFrame)
end;
TFrameWithResource = class(TMyFrame)
3) The very first time one opens this frame (TFrameWithResource ) and shows the form resource in the IDE everything is OK. If one then e.g. chooses to view the frame as text and switches back to showing the frame as form... the frame will get all the properties that a form normally displays in the Object Inspector and in run-time the TReader object will raise exceptions for e.g Property OldCreationOrder does not exist.
Comments:
The project source file already defines the frame as e.g.
uses
Unit2 in 'Unit2.pas' {TFrameWithResource: TFrame};
... so no problem there... as far as I can see!
The forms resource file defines the frame as e.g.
object FrameWithResource: TFrameWithResource
.. so no prolbem there either... I think? Workarounds One can assign an empty frame resource to the TMyFrame object and then it works.... BUT, I need to add another form resource to the unit where the frame resides that should have no form resource. And it works for forms and other components, so why should one bother with a frame??? Attachment None Comments
None