GPFs using multiple forms
Posted on 1998-07-02
I am having a problem that is related to component writing and I was hoping someone here could help me.
(Note:The program is a Delphi 1 program. I am developing on a Win 95 machine.)
I have written a Delphi program with two Forms - the main form is Form1 and the second Form, ibpDlg, is called modally as in "rslt := ibpDlg.ShowModal"
I have both forms set to auto-create in the project file. I have also added some properties per Stewart McSporran's article "RAD Vs. Good Object-Oriented Practice" published in the July 1997 issue of Delphi Developer.
When I run the program, the first time I try to reference the ibpDlg form the program GPFs on me. So I have played around with it and if I add the following statement to the TForm1.CreateFrom event handler:
ibpDlg := TibpDlg.Create(Self);
the modal form appears to work correctly BUT when I go to close the program with "Form1.close;" the program aborts with "Invalid Operation - can not change Visible on OnShow or OnHide". I have NO idea where this is coming from - I am guessing that I am doing something so wrong the program is getting "lost" and throwing up a screw-ball error.
Anybody have any ideas? Also and AS important, where can I find out how to encapsulate a Form into a component that I can place on the component taskbar and drop onto my Form? The ibpDlg Form is a generic Dialog box that replaces ShowMessage and that ilk. I have read Developing Custom Delphi Components by Ray Konopka but couldn't find an example of how to encapsulate a Form (the about box example looked close but I want a From to be able to have TStringList components (a memo) in addition to non-created variables like Integer and String.)
I hope this makes some sense and there is someone out there who can help.