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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to tackle this?

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi,

In start of my application, I created one splash form, in which I put the following

Init Event:
WITH This
.AutoCenter = .T.
.BorderStyle= 2 && Fixed Dialog
ENDWITH

Unload Event:
CLEAR EVENTS

There is timer on form:
Timer Event:
ThisForm.Release()

Interval: 3000

After that I have a login form, in which user put the password and ID on correct entry it opens MainMenu.scx forms.

The problem is it opens splash screen but hanged on password form.

The code of the main.prg is as follows:

Code:
On Shutdown Do cleanup()

*-------------------------------------------
*--
*-- Runtime Mode Application Startup Program
*--
*-- Entry point for front-end application
*--
*-------------------------------------------

*-- Include

*-- Clear all at first
Clear
Clear Dlls
Release All Extended
Clear All

Public debugmode  && TRUE when running within VFP, FALSE for standalone program
Public gchomepath && Working directory
Public want_to_exit

Set Path To
Set Defa To
*=setpath()
*lcdefaultpath = gchomepath
lcDefaultPath = JUSTPATH(SYS(16))
*lcdefaultpath = 'd:\vtts'
Set Default To (lcdefaultpath)

= set_app_paths()

*SET PROCEDURE TO ('procs\Measure')
Set Exclusive Off
Set Multilocks On
Do Locfile("system.app")
DO FORM ('spscreen1.scx')
READ EVENTS
Do Form ('userid.scx')
Do Form ('mainmenu.scx')
Read Events
Release All
Clear All
Close All
Clear Dlls
Release All Extended
Clear All

Clear Events
On Error
On Shutdown
If _vfp.StartMode = 0
   Return To Master
Else
   Quit
Endif

*--------------------------------------------

Procedure set_app_paths
   Set Path To lcdefaultpath + '\' Additive
   Set Path To lcdefaultpath + '\data'      Additive
   Set Path To lcdefaultpath + '\forms' Additive
   Set Path To lcdefaultpath + '\graphics' Additive
   Set Path To lcdefaultpath + '\graphics\heads' Additive
   Set Path To lcdefaultpath + '\graphics\icons' Additive
   Set Path To lcdefaultpath + '\graphics\logo' Additive
   Set Path To lcdefaultpath + '\graphics\others' Additive
   Set Path To lcdefaultpath + '\graphics\products' Additive
   Set Path To lcdefaultpath + '\graphics\skins' Additive
   Set Path To lcdefaultpath + '\graphics\skins\backgrounds' Additive
   Set Path To lcdefaultpath + '\graphics\sound' Additive
   Set Path To lcdefaultpath + '\graphics\staff\images' Additive
   Set Path To lcdefaultpath + '\help' Additive
   Set Path To lcdefaultpath + '\junk' Additive
   Set Path To lcdefaultpath + '\libs' Additive
   Set Path To lcdefaultpath + '\menus' Additive
   Set Path To lcdefaultpath + '\others' Additive
   Set Path To lcdefaultpath + '\progs' Additive
   Set Path To lcdefaultpath + '\query' Additive
   Set Path To lcdefaultpath + '\reports' Additive
   Set Path To lcdefaultpath + '\foxbarcode' Additive
   Set Path To lcdefaultpath + '\foxbarcode\docs' Additive
   Set Path To lcdefaultpath + '\foxbarcode\forms' Additive
   Set Path To lcdefaultpath + '\foxbarcode\images' Additive
   Set Path To lcdefaultpath + '\foxbarcode\samples' Additive
   Set Path To lcdefaultpath + '\foxbarcode\reports' Additive
   Set Path To lcdefaultpath + '\foxbarcode\source' Additive
   Set Path To lcdefaultpath + '\foxyview' Additive
   Set Path To lcdefaultpath + '\foxyview\sampledistribproject' Additive
   Set Path To lcdefaultpath + '\foxyview\sampledistribproject\exe' Additive
   Set Path To lcdefaultpath + '\foxyview\source' Additive
   Set Path To lcdefaultpath + '\foxyview\source\images' Additive
Endproc

*--------------------------------------------
*-- Set path to application working directory
*--------------------------------------------
Function setpath()
   *-----------------

   Local lcpath, lcbuffer
   Local lnstart

   lcpath = Sys(16)                              && Where we were executed...
   lnstart = At("\\", lcpath)

   If lnstart = 0
      lnstart = At(":", lcpath) - 1
   Endif

   If lnstart > 0
      lcpath = Substr(lcpath, lnstart)            && Derive program name
   Endif

   gchomepath = Left(lcpath, Rat("\", lcpath))   && ... and path to it

   *-- Change current directory to working...
   Cd (gchomepath)

   *-- If we are running MAIN.PRG directly, then
   *-- CD up to the parent directory
   If Right(lcpath, 3) = "FXP"
      *-- One level up
      Cd ..

      *-- Assume we were run from VFP
      debugmode  = .T. &&TRUE

      *-- Make out path to INI file
      gchomepath = Left(gchomepath, Rat("\", gchomepath, 2))

      *-- Ensure the project manager is closed
      Deactivate Window "Project Manager"
   Endif

   *-- Set all pathes
   Set Default To (gchomepath)

Function cleanup
   *If want_to_exit
   Clear Events
   Clear All
   Release All
   On Error
   On Shutdown
   If _vfp.StartMode = 0
      Return To Master
   Else
      Quit
   Endif
   *Endif

*-- End of program

Kindly point out me where I am wrong?

Thanks

Saif

 
The problem is in the userid.scx, isn't it?

Did you make that form modal? Then the app "hangs" on it, until you login and release the form.

Or what's the problem, really?

It's unusual to have two read events, but you can have your spash screen simply wait for 3 seconds in it's first read events, clear that and continue, that's totally valid. The login form then shows, doesn't it? So that part is working. You have to look for what your login form is doing. You shouldn't use a modal form and read events both at the same time, especially if the modal form usese clear events, you'll get into the situation starting the form, doing clear events before even doing read events and hanging on read events.

Bye, Olaf.



 
Thanks for reply!

Userid is a modal form.

I made slightly changes as per your advise:

Do Locfile("system.app")
DO FORM ('spscreen1.scx')
Do Form ('userid.scx')
*READ Events
Do Form ('mainmenu.scx')
Read Events

What is happening all three forms appearing at a time and after 3 seconds disappear.

Thanks

Saif
 
You should not remove the read events after splash screen, that's unusual, but valid, and needed in your case.

In the code you posted initially, you had a read events directly after DO FORM ('spscreen1.scx') and as you do CLEAR EVENTS in the spash screen unload, that's both absolutely ok and necessary.

Bye, Olaf.
 
I still don't understand what you mean, when you say the login form hangs. What do you expect to happen?

As the userid.scx is modal, it will run, show and the mainmenu.scx will only run after you have logged in, because of the form modality. But this doesn't mean the app hang, it's intentional the login has to finish first, isn't it?

Bye, Olaf.
 
I am sorry I used wrong word "Hangs" I mean it disappears.

Saif
 
I put read events, now after splash screen both the forms come together userid.scx and mainmenu.scx.

Please advise.

Saif
 
You said userid.scx is a modal form, how can it appear in parallel with mainmenu.scx, then?

If userid.WindowType is 1 (modal), one thing preventing the real modal nature of the form is, it's also ShowWindow = 2 (As Top Level Form). Top Level Forms can't be modal.

Then use another read events, perhaps. Also clear events in the userid.unload event, as with the splash screen.

If your app isn't using the _Screen at all, you can't have modal forms, unless they are child forms of some main form you would then start first.

Bye, Olaf.



 
Thanks for the reply!

I finally got it after slightly changes in main.prg which is as follows:

Set Exclusive Off
Set Multilocks On
Do Locfile("system.app")
DO FORM ('spscreen1.scx')
READ Events
Do Form ('userid.scx')
READ Events
*Do Form ('mainmenu.scx') && This Command will be used in UserId.scx where it will work according to the userid and password.
*Read Events
Release All
Clear All
Close All
Clear Dlls
Release All Extended
Clear All

Thanks

Saif
 
True, Craig!

But I think the solution samples or the sample projects you can use from component gellery templat epplications or create via application wizard all work with the _SCREEN visible.

As Saif said the userid.scx is configured to be a modal form, yet does not act modal, from which I deduct it's a top level form. And that suggests, the whole application uses SCREEN=OFF and then doing a splash screen as top level form and a login as top level form and a main form as top level form each running in sequence need several read events.

Now the login starts the main form, which gets rid of one read events.

What you could do to get rid of the spscreen1.scx is using the -B command-line switch. It's a very simple splash screen showing a simple image file for a specified duration.

RUN vfp9.exe -Bfox.bmp,5000

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top