views:

804

answers:

5

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).

A: 

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).

Gamecat
+1  A: 

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  A: 

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.

birger
This seems to work on the ancestor classes, but I still have issues sometimes with the "root" class (the one descending from TFrame). That "First" one SHOULD be "object," right?
Jamo
I'm not sure, in the project where I had this problem, all frames start with 'inherited MyFrame: TMyFrame'. The first descendant from TFrame that we use does not have a dfm, so I can't check what should be in the dfm there.
birger
Interesting! I'd not thought of having that "first" TFrame descendent be one without a DFM altogether. That might eliminate the "base TFrame" problems I'm suspecting. Hmmm... Thanks for that info. Will experiment with this approach!
Jamo
@birger: My hero! Thanks! You just ended several hours of utterly pointless bug hunting. ;) I totally failed to notice that change in the DFM. Would probably have been easier to spot if the file had already been under version control...
Oliver Giesen
A: 

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

AhmetC
Do you still need to do this, even if the whole frame-based component is registered via a design package? It shows up on the palette just fine, and the published properties show up in the inspector. It does "lose it's frame behavior" but that is actually what I want. Not following what this does.
Jamo
This is nothing about registering it as a regular component. You may need to register custom module in order to obtain proper designer specific behaivour. Still i am not sure because how ide is handling Tframe in design time is not transparent to programmers. But it is worth to try in my opinion.
AhmetC
A: 

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.

kuaw26