Delphi IDE treating TFrame as if it were a Form

妖精的绣舞 提交于 2019-12-22 05:16:16

问题


Every once in a while when I am tweaking my TFrame classes (adding properties, methods, etc), the IDE gets confused and acts as if it thinks the frame is a form, complete with header/caption, borders, etc. Yet, clearly the class is declared as a TFrame descendent. Any ideas as to what causes this, how to prevent, and how to fix?

I'm using Delphi 2007 Pro. Also note (if it matters), the TFrame descendents are typically registered with the IDE (i.e. on the palette) via a design-time package.


Later: Additional "specifics": The frame that I'm having this problem with at the moment is, visually, a VERY basic TFrame (only change from brand new TFrame is size, and background color).

Here's its class declaration:

TBasePanel = class(TFrame)
  private
    FPanelManager: TPanelManager;
    procedure SetPanelManager(const Value: TPanelManager);
  protected
    procedure Connect; virtual; abstract;
    procedure Disconnect; virtual; abstract;
    procedure Refresh; virtual;
    procedure Requery; virtual; abstract;
  published
    property PanelManager: TPanelManager read FPanelManager write
        SetPanelManager;

This frame is used as a base class for a number of others. I am usually editing it directly from the BPL project it belongs to (because all of these frames install to the palette), rather than as part of an EXE project, with related Forms open etc.

Also, "Embedded designer" is checked in Tools -> Options.

I am saving all DFM files as text rather than binary as well (if that matters at all).


回答1:


I have encountered the same problem. The following steps solved the problem for us, it might also work for you:

  1. in the IDE: close all forms that use the frame
  2. open the frame, view as text (*.dfm)
  3. the dfm probably begins with object MyFrame: TMyFrameClass
  4. change this to inherited MyFrame: TMyFrameClass

I don't know what caused the problem.




回答2:


Perhaps you had unchecked the 'Embedded designer' check box? (Tools | Options | Environment Options | VCL Designer). Then, indeed, your frame is shown at design time as a form (with caption, border etc.). Also a concrete code of your problematic TFrame descendant or more details about your case would help.




回答3:


As far as I know, you have to have both the form and the frame open in the editor when you edit the frame. Else there can be update problems. Although I haven't seen this one.

But I gave up on frames a long time ago because I did not find them very reliable.

Right now I only use them for prototyping, creating a custom component (derived of a panel with the apropriate controls on it).




回答4:


You may have to register custom module to the IDE But your additional properties won't work well unless they are in ancestor class.




回答5:


I have encounter a lot of problems with TFrame and finally came to such workaround that solves all my problems: I create and design frames visually, but use them only by hand-coding.

As a side effect my applications became smaller, because of less dfm-s.



来源:https://stackoverflow.com/questions/589523/delphi-ide-treating-tframe-as-if-it-were-a-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!