INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Forms & Screen

How To Make a Single-Form-Application by Olaf Doschke
Posted: 16 Jan 07 (Edited 19 Jan 07)

There are some FAQs on READ EVENTS, some on how to turn off the _SCREEN, some how to suppress the creation of a FOXUSER.DBF and some on How to setup a form as top level form.

I think these questions are closely related and mostly come from new VFP users, that try to do something simple first, a single form application with no menu, no MDI (multiple dcument interface). But because VFP offers no project types and so you don't get a template project, you need to find out several things yourself, that seemed easy to do. In fact an MDI application is easier to setup with VFP. And one problem even only gets obvious, when first compiling and running the EXE, just to see a flicker because of a missing READ EVENTS.

Here are two programs (you can save as prg and run), that create and compile a single-form-application each. One program will create a project based on a form (SCX), one program will create a project based on a form class (VCX). There are some differences between SCX and VCX. I'd always recommend basing your project on classes. The tempting thing of an SCX is, you have the RUN Button and off you go, rapid development. But you cannot inherit form classes of SCX forms. In a single form application that does not matter much, but the chances are high, you want a second form soon, then a third...

Simply save one of these as a prg. If you want your project created in another path, simply change line 1. Then run, you'll get a very simple project with a top level form, a config.fpw, that turns off the vfp screen and suppresses creation of a FOXUSER.DBF and a main program (a concept quite similar to C: VFP projects have a main file - not function - , which is the entry point of the EXE). An EXE is built and run and no foxuser.dbf is created in the application/project folder, which may later save trouble, when installing into C:\Program Files\YourApp\, in which users don't have the right to create new files.

VCX:

CODE

#Define ccPropjectpath [D:\vfpprojects\singleformVCX\]
MkDir (ccPropjectpath)
Cd (ccPropjectpath)
MkDir [libs]
MkDir [others]
MkDir [prgs]

Create Project singleformVCX.pjx Nowait Save

Local lcFile
Text To lcFile Noshow
On Shutdown Quit
Set Classlib To [forms] Additive
Local loMainform
loMainform=Createobject("frmmain")
loMainform.Show()
Read Events
EndText
StrToFile(lcFile,"prgs\main.prg")
_vfp.ActiveProject.Files.Add("prgs\main.prg")

Text To lcFile Noshow
SCREEN=OFF
RESOURCE=OFF
ALLOWEXTERNAL=ON
EndText
StrToFile(lcFile,"others\config.fpw")
_vfp.ActiveProject.Files.Add("others\config.fpw")

Local Array laForm[1]
Local loForm
Create Class frmMain Of [libs\forms.vcx] As Form Nowait
ASelObj(laForm,1)
loForm = laForm[1]
loForm.ShowWindow = 2 && as top level form
loFOrm.Autocenter=.T.
loForm.Caption="Main Form"
loForm.WriteMethod("Unload","Clear Events")
Activate Window "Class Designer" && change in localized VFP versions
Keyboard '{CTRL+S}'
Keyboard '{CTRL+F4}'
Doevents
_vfp.ActiveProject.Files.Add("libs\forms.vcx")
_vfp.ActiveProject.Build("singleformVCX.exe",3,.t.,.t.,.t.)

SCX:

CODE

#Define ccPropjectpath [D:\vfpprojects\singleformSCX\]
MkDir (ccPropjectpath)
Cd (ccPropjectpath)

MkDir [forms]
MkDir [others]
MkDir [prgs]

Create Project singleformSCX.pjx Nowait Save

Local lcFile
Text To lcFile Noshow
On Shutdown Quit
Do Form frmMain
Read Events
EndText
StrToFile(lcFile,"prgs\main.prg")
_vfp.ActiveProject.Files.Add("prgs\main.prg")

Text To lcFile Noshow
SCREEN=OFF
RESOURCE=OFF
ALLOWEXTERNAL=ON
EndText
StrToFile(lcFile,"others\config.fpw")
_vfp.ActiveProject.Files.Add("others\config.fpw")

Local Array laForm[1]
Local loForm
Create Form [forms\frmMain.scx] As Form Nowait
ASelObj(laForm,1)
loForm = laForm[1]
loForm.ShowWindow = 2 && as top level form
loForm.Autocenter=.T.
loForm.Caption="Main Form"
loForm.WriteMethod("Unload","Clear Events")
Activate Window "Form Designer" && change in localized VFP versions
Keyboard '{CTRL+S}'
Keyboard '{CTRL+F4}'
Doevents
_vfp.ActiveProject.Files.Add("forms\frmMain.scx")
_vfp.ActiveProject.Build("singleformSCX.exe",3,.t.,.t.,.t.)

Bye, Olaf.

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close