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!

i compiled a prg file into an exe file but the exe flash and dissapears when run

Status
Not open for further replies.

titoneon

MIS
Dec 11, 2009
335
US
Hello Everyone,
I probably have the wrong syntax or i am missing something here, i compiled a prg file, added to a project and then build an exe file.

i even created a startup prg file to just call the MAIN prg file
The line in the startup prg file is as below

Do MAIN
READ EVENTS

MAIN.PRG have the code that includes the form, control, grid etc... the problem is, i was trying to get rid of the Main VFP screen, so i have a Config.fpw file with SCREEN = OFF in the same folder as the exe file resides, by the way i removed the config.fpw from the project and left it in the same folder where the exe is located cause anyway the exe run but it flash and right away dissapears, even if it is part of the project or not.

so i just remove the config from the project and left it in the folder, also i added into the code below(MAIN.PRG) as shown the showWindow=2 maybe the syntax is wrong ?

can you please, correct me , suggest me here ?
here is the code that runs the form


MAIN.PRG
Code:
SET EXCLUSIVE OFF
path_1="s:\pro50\apex04\apvend04"  &&VFP 5.0 TABLE TYPE
path_2="S:\PRO50\APEX04\POmast04"  &&VFP 5.0 TABLE TYPE                

oForm = Createobject('myForm')
oForm.Show(1)
Set Safety Off


Define Class myForm As Form
	Height = 250
	Width = 300
	AutoCenter = .T.
	Caption = 'Search Vendor Names'
	ShowTips = .T.

 showWindow = 2

	Add Object myGrid As Grid With ;
		Height = 100, ;
		Width = 200, ;
		Top = 50, ;
		Anchor=15, ;
		DeleteMark = .F.,;
		OleDragMode = 1, ;
		GridLineColor = Rgb(192,192,192),;
		FontName = 'Tahoma',;
		FontSize = 8

	Add Object label1 As Label With ;
		top = 15,;
		left = 8,;
		caption = 'Enter Po# ',;
		Backstyle = 0

	Add Object Text1 As TextBox With ;
		top = 15,;
		left = 125,;
		Height = 23,;
		Width = 80,;
		value = '',;
		ToolTipText = 'Start typing to search matching records,'+;
		' Double-click to clear search	'

	Procedure Load
	Set Talk Off
	Set Safety Off
	Close Databases All
	Set Exact On
	

	SELECT po.purno, ap.company from (m.path_1) ap;
	 INNER Join (m.path_2) po ;
	 ON	po.vendno=ap.vendno WHERE .F. Into Cursor crsSample  Readwrite

	Endproc

	Procedure myGrid.Init
	With This
		.RecordSourceType = 6
		.RecordSource = 'crsSample'
	Endwith
	Endproc




	Procedure Text1.DblClick
	This.Value = ''
	This.InteractiveChange()
	Endproc




	Procedure Text1.InteractiveChange
	Set Safety Off
	Local lcSearch
	lcSearch = Alltrim(This.Value)
	
	
	SELECT po.purno, ap.company from (m.path_1) ap;
	 INNER Join (m.path_2) po ;
	 ON	po.vendno=ap.vendno  WHERE po.purno = PADL(m.lcSearch,10) Into Cursor crsSample2  Readwrite
	Go Top
	Select crsSample
	Zap In  crsSample
	Append From Dbf('crsSample2')
	Select  company  From crsSample2   Where purno == PADL(m.lcSearch,10)  Into Cursor crsSample3  NOFILTER
	Go Top
	Thisform.myGrid.Refresh
	Endproc



	Procedure myGrid.OLEStartDrag
	Lparameters oDataObject, nEffect
	With This
		.OLEDropMode = 0
		With .Columns(.ActiveColumn)
			Local lcValue
			lcValue = Trim(Transform(Eval(.ControlSource)))
			oDataObject.SetData(m.lcValue,1)
		Endwith
	Endwith
	Endproc


	Procedure Destroy
	Clear Events
	Endproc
Enddefine

Thanks in advance
 
The [tt]READ EVENTS[/tt] should not appear after [tt]DO Main[/tt]. It should appear inside Main.PRG.

The right place for [tt]READ EVENTS[/tt] is immediately after you launch the form or menu that forms the "top level" of the user interface. In other words, after the main [tt]DO FORM[/tt] or [tt]DO xxx.MPR[/tt]. Think of [tt]READ EVENTS[/tt] as a sort of Pause command - waiting for the user to start interacting with the application. That will give you a good clue as to where it should go.

I also suggest that you remove the Config.fpw file until you have got this working. Once the "flashing" problem is solved, you can take a separate look making the outer window invisible. That's really a separate issue.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,
Yes, after adding the "READ EVENTS" into the Main.prg and removing the config.fpw, now the exe file runs but the main form, is inside the vfp main screen, then i added back the config.fwp and then the exe runs but is hidden, nothing is shown, can you advise why this is happening please ?
Thanks a lot
 
Your main form is not a top level form, therefore it needs the vfp main screen is needed to have this form visible. your main form is jsut a child form of the vfp main form, and if you hide it, you also hide your form.

Bye, Olaf.
 
OK, that's a good step forward.

Your ShowWindow syntax look fine. But I'm not sure about this line (the fifth line in your code):

[tt]oForm.Show(1)[/tt]

I think you should pass [tt]2[/tt] rather than [tt]1[/tt]. The reason is that "1" makes the form modal. A modal form can't also be top-level, so it will be contained within the outer window, and as that's invisible, the form will also be invisible.

Try changing the [tt]1[/tt] to [tt]2[/tt].

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Olaf,
It is a way programmaticly to make my Main form to be a top level form and eliminate the outer vfp window ?
Thanks
 
Mike,
I just changed the oForm.Show(1) to oForm.Show(2) but i also needed to add in the main.prg _screen.visible=.f., otherwise, the outer window will still show, finally i have what i wanted to accomplish, thanks to you and Olaf always for guide people to the right direction
Thanks again
Ernesto
 
Glad to hear it's working, Ernesto.

Just to explain the difference between SCREEN = OFF and _Screen.Visible = .F. ....

When your application loads, the sequence of events is as follows:

1. Config.FPW is processed. This is when SCREEN = OFF takes effect.

2. If SCREEN = OFF is not in effect, the application's outer window is painted.

3. The application starts to execute. When it reaches _Screen.Visible = .F., the outer window becomes invisible.

So, by using the Config.fpw file, the outer window should never become visible. By contrast, if you rely on _Screen.Visible = .F., the window will become visible for a very short time, and will then disappear. Hence the "flashing" effect.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Show(1) vs Show(2) is not about ShowWindow but about WindowTpye being modal or modeless.

You need to set a form as top level form in the form designer by editing the ShowWindow property to 2 (as top level form)
Then you can set SCREEN=OFF, because the form starts as it's own top level form.

Bye, Olaf.
 
Put "read events" under main form's activate event.

Sorry, but that doesn't make sense. You can't put code "under" an event. In any case, the READ EVENTS goes after the code that activates the form or menu, not necessarily in an event of a form (especially if your controlling interface is a menu).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top