Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modeless FORM just Flashes 1

Status
Not open for further replies.

jsams

Programmer
Aug 22, 2000
73
US
I am still trying to work myself through a simple project utilizing a menu system to invoke several screens which will access a two free tables. The object is trying to learn OOP VFP.

----code snip---------------

In the Main.prg program:

SET CLASSLIB TO myclasslib
DO menu.mpr
READ EVENTS

In the Menu, in a menu option procedure:

ofrm = CREATEOBJECT(‘c_form’)
ofrm.SHOW(0)
--------------

'c_form' is a subclass of parent 'tform' based on the standard form class, both 'c_form' and 'tform' are stored in myclasslib.

If I create the MODELESS form, it just flashes when the menu option is selected. If I change to: ofrm.SHOW(1)for MODAL operation, then the screen displays OK.

I tried a normal (non-classed) form and called it from the same menu procedure as: DO FORM myform, the form will appear and stay on the screen regardless of whether is set the SHOW property to 0 or 1, only difference is I can’t access other menu items with MODAL, which is my basic problem for wanting to use MODELESS for the object based form: c_form.

How can I make the MODELESS screen work when created from a sub-classed object. I am missing something here, but sure don’t see it.

John
 
The variable oFrm goes out of scope and the form closes. If you use DO FORM <formname> it will display correctly.

Craig Berntson
MCSD, Visual FoxPro MVP, Author, CrysDev: A Developer's Guide to Integrating Crystal Reports&quot;
 
Yep, your right Craig, thats what I noted in my fourth paragraph.

But then how do I make the sub-classed form retain scope? How does it loose scope when nothing has happened after the ofrm.SHOW(0) is executed?

John
 
ofrm goes out of scope once the method or procedure that create it ends, just like any other memory variable.

Either declare it at a higher level, or declare it public.

Better yet, create some sort of &quot;form manager&quot; object at the application level that keeps track of form references.
 
Thanks Danfreeman, moving the CREATEOJECTS up into the main and using the HIDE method in the forms on LOSTFOCUS solved the problem. I see the &quot;light&quot; now, but it sure wasn't obvious before.

Thanks again.

John
 
I don't know about &quot;seeing the light&quot;, as you should really only be creating objects when and as needed. In this case, the object exists during the life of the application.

Craig Berntson
MCSD, Visual FoxPro MVP, Author, CrysDev: A Developer's Guide to Integrating Crystal Reports&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top