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

Form.Show() doesn't work in exe but works through prg 1

Status
Not open for further replies.

Rajesh Karunakaran

Programmer
Sep 29, 2016
549
MU
Dear Team!

I have come across a weird situation and failed to reach at a solution so far.
I have a login form, being created from a class (it's a class which holds application level details),
using loForm = CREATEOBJECT('loginpicture'). But, when I call the Show method, using 'LoForm.Show()' to show the form and to wait for user input, it doesn't work. The login form is not shown and without any error it just flows to the next line after this. However, it works and form is shown with employee list from the development enviro, ie when I start the application from command prompt by calling its main prg file. I am not able to remember any change I made which might have caused this.

By the way, the form 'WindowType' is Model.

Now, I just want to know if this is a known issue that something which could prevent the form being shown through the 'Show' method.
If there isn't any clue, I want to dig deeper to solve this.

Thanks in advance.
Rajesh
 
If the form is modal you should pass 1 in Show:
Code:
LoForm.Show(1)

Borislav Borissov
VFP9 SP2, SQL Server
 
WindowType 1 (Modal) does not work for ShowWindow=2 (as Top-Level Form). I guess you have set this so the login form shows as single form without _screen or another top-level form in the background.
Either you have a READ EVENTS or you use the _SCREEN and make this login form an "In-Screen" form or have your own "Top-Level" form and make the login form an "In Top-Level" form.
With READ EVENTS your login success has to be returned via something staying in scope, eg a _SCREEN property (_SCREEN always exists, even if you don't want to show it), public variable, private variable initiated before the form call, goApp application object property or anything else you can think of, then can CLEAR EVENTS and continue after READ EVENTS depending on login success, to eventually QUIT or start another READ EVENTS after the normal application main form started as Top-Level form.

Bye, Olaf.
 
Thanks for all answers.

Dear bborissov,
The form is already Modal and in Fox help, it is written that if we don't pass parameter in Show(), the WindowType will be assumed.
Also, I knew this was working earlier. Now, I am stuck up with what happened or may be what mistake I did!

Dear Olaf,
I just saw that the form ShowWindow is 0, ie In Screen.

Any other clue, please?

Rajesh
 
Well, if it's in screen, do you show the screen? Can you check _SCREEN.visible? A config.fpw with SCREEN=OFF might hide it and then forms "In Screen" also are hidden.
And finally, when you DO main in somre.EXE you don't start a new process, the EXE isn't executed, you stay in the process and DO main.prg within the IDE, which has a visible _SCREEN, showing the form.

Bye, Olaf.
 
Can you verify the class "loginpicture" you instanciate is at all a form? Does Messagebox(loForm.baseclass) display "form"?
You might have two classes named exactly the same and start something else.

Bye, Olaf.
 
Dear Olaf,

You DID it! You did catch the thief!!! I recall investigating methods of 'Sherlock Holmes' :))...
I am impressed, really, the way you assumed where and what could be the issue even without a piece of code in hand, Great!!!

Thanks a lot to all others also for your valuable time.

Olaf said:
Can you check _SCREEN.visible? A config.fpw with SCREEN=OFF might hide it and then forms "In Screen" also are hidden

Yes, the culprit was the 'config.fpw' which was created when I used a small program to programmatically create an EXE file from a PRG without using a project file. Unfortunately, I did that in the same folder where the subject project is kept (I shouldn't have done that :-( ).

I am posting that small program also, it if benefits someone. I think, this is an edited version of a code I got from someone else, probably in this forum itself. However, here it goes.

Code:
PARAMETERS pPrg
IF TYPE('pPrg') <> 'C' OR EMPTY(pPrg)
	MESSAGEBOX('Pass proper prg name with full path')
	RETURN
ENDIF 
pPrg = FORCEEXT(pPrg,'prg')	
pExe = JUSTSTEM(pPrg)
BUILD PROJECT tmpPrj FROM (pPrg)
MODIFY PROJECT tmpPrj NOWAIT NOSHOW
_vfp.ActiveProject.Icon="myIcon.ico"
STRTOFILE('screen=off'+CHR(13)+CHR(10),'config.fpw')
_vfp.ActiveProject.Files.Add('config.fpw')
_vfp.ActiveProject.Close
BUILD EXE (pExe) FROM tmpPrj RECOMPILE
ERASE config.fpw
ERASE tmpPrj.pj?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top