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

Can you create an .exe file from created form? 2

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
587
PH
Hi everyone, im doing a little project, i designed a form using form designer.. is it possible to create an exe file out of it? If so, please teach me how… thanks in advance…
 
An EXE needs a project to build and a main file. This should be a prg with DO YOURFORM.SCX at least.

Chriss
 
As Chris says, you need to add the form to a project.

The usual approach would be for the project to also contain a program (a PRG file), and for that program to launch the form. However, it is also possible for the project to contain the form and nothing else. In that case, set the form to "Main" (right-click on it within the project, and tick "Set Main"; the name of the form will turn bold). You can then buidl the project to create an EXE.

If you do that, be sure to make the form modal (set its WindowType to 1). Otherwise, the form will simply flash on the screen and then immediately disappear and terminate the program.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Edited:
I see only an unfortunate way how that works, Mike. With the _SCREEN visible.
Because the form has to be modal as you don't want a PRG that could have a READ EVENTS. The form can't be top level, or setting it modal does not work.

So you need to set the form to be in screen or in top level form and when you add a config with SCREEN=OFF or set _SCREEN.visible=.f. in your form code (load or init), then the form disappears.

I only see this working with another top level form or screen and since that's surely not what you want, you better have a main.prg as usual.

Chriss
 
Oh.... I see..... Thanks Chriss and Mike....
 
Okay, I figured out a way, but this is not what I'd ever recommend to do:

Form init:
Code:
_screen.visible=.f.
This.Show()
Read Events

Form queryunload:
Code:
Clear Events

And ShowWindow set to 2, which means as top level form.

Then this works without a PRG, but you never return from init, the whole time the form runs, an event hasn't finished. READ EVENTS allows any further events to happen, but it's not natural to do this. It doesn't feel good, as you have to actually call the Show() method, which is happening after init, usually, but not in a case you stop init from exiting by READ EVENTS.

As you have to use a top level form anyway, and that's never modal, I'd also just have a PRG that can initialize several things and then READ EVENTS. It's also much easier to extend.

Chriss
 
Chris, you've made some good points, and I don't disagree with any of them. But I wouldn't want Mandy to be over-worried about top-level forms. If she just has a modal form in the project, and nothing else, then it should work fine. It's true that the outer VFP window will also be visible, but she hasn't said that she has a problem with that.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

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

Part and Inventory Search

Sponsor

Back
Top