Frames are great for isolating code, but nested frames and frame reuse has issues. What am I doing wrong?

Frames are great for isolating code, but nested frames and frame reuse has issues.  What am I doing wrong?

The frames:
frmValidation - 
a small toolbar with a message box and Save/Cancel buttons
frmDetailProperties - has a frmValidation embedded
frmMasterProperties - has a frmValidation embedded
frmDetailList has a list and the frmDetailProperties embedded
frmMasterList has a list and the frmMasterProperties and a frmDetailList embedded.

Initially, I had a problem with the frmValidation instances having the same name on the two properties forms - and Delphi complained about Duplicates not allowed.  Renaming one, solved that issue.

All frames have been added to the palette, and when I have the project open, I have no problems with viewing the combined frames. The frame source is in the project path.

The problem: If I close Delphi and start again, Delphi complains that it can't find the TfrmDetailProperties in frmMasterList.  I click cancel, the project opens, but the frmMasterList can't be viewed.  

If I now close the frmMasterList unit - and reopen it, it opens without any messages, and the frame can now be correctly viewed. 

What is going on here?

Comments

  1. Did you confirm all frames are referenced in the DPR?

    ReplyDelete
  2. Have you left any of the frame units open when you close the project? In other words, such that they would be re-opened at the same time as the form in which they are used?

    ReplyDelete
  3. Marshall is right: frames need to be explicitly referenced in the .dpr; putting them in the search path is not enough.

    ReplyDelete
  4. Want some real fun? Try adding a frame to a form twice.

    ReplyDelete
  5. All frames are referenced in the dpr.

    The frame units are reopened when the project loads. Is that the problem?

    ReplyDelete
  6. Kenneth Cochran Isn't that what frmMasterList has? It has frmValidation from frmMasterProperties and frmDetailList (via frmDetailProperties).

    ReplyDelete
  7. You're right. Didn't notice that. In that case design time is only the first hurdle. My experience has been that it is impossible to create a form with two instances of the same frame on it using dfm streaming. I encountered the same error at runtime despite the renaming of the frame instances.

    I resorted to creating the frame instanced dynamically and assigning the a panel on the form as the parent.

    ReplyDelete
  8. That means wiring up props "by hand", but whatever it takes, I guess. I wonder if this has a QC entry or two?

    ReplyDelete
  9. That's been like it for ages, I can remember getting the same problem in d6. Let's not mention visual inheritance. IMHO you should always work with frames dynamically, never any other way.

    ReplyDelete
  10. Couldn't find a QC. It's about time it gets fixed, though.

    ReplyDelete

Post a Comment