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

form loses focus when running executable

Status
Not open for further replies.

Webrookie

Programmer
May 18, 2000
112
US
so i have an executable with a login form that is a top level form and alwaysontop=.t.

I obviously don't want my user to see that stupid fox window that pops up when they run the executable, so i have a config.fpw with screen=off in it.

If I run the program like this, the login window loses focus. I know it's a petty thing, but when you have to move your mouse to the username field of the login window everytime you run a program, it gets a bit obscene.

If I lose the config.fpw file, the login window gets focus, but then there's that stupid fox window lurking.

Can someone help me here? Before I format my hard drive?
 
Are you talking about the Fox Splash Screen? If so you can use a command line switch in your start-up e.g.
C:\myStartDirectory\myApp.exe -T

As to why your form doesn't start with focus, I'm sure someone on the forum will understand what is going on there. I've never had that problem.
 
Actually I've see the same thihg in a number of professional programs and it is a bit annoying. You're blithely starting to type your login and then notice that there's nothing in the Box. I'd expect, however that all that's needed is to put something in the activate event of the form explicitly setting the focus where you want it. (or one of the other start-up events if that one doesn't work right) -- Dave
 
CDavis -

I'm not talking about the splash screen, i'm talking about the main VFP window that opens.....DEDMOD knows what i'm talking about....

DEDMOD -

I swear I've tried all of that with the startup events, as far as setting focus the form....I'll give it another try..could be that I missed something
 
Ok, I have used thisform.user.setfocus in each of the startup events of the form: init, activate, load

and it still loses focus....

 
I have one idea which may or may not help any. Do you have the tabindex of the textbox you want to start with set to 1? If tabindex 1 is set to something which you can't enter text into that would be a problem. Of course that wouldn't explain why it works if you don't have the config file active.

Perhaps I'll try an experiment and get back to you if nobody else has a solution before then.

Dave Dardinger
 
Thanks Dave, good luck in your experiments....please let me know what you find.....
 
Webrookie,

I never seem to have a problem with setting the focus when I use the config.fpw file.

Is there something in that textboxes gotfocus or refresh events that might be screwing things up?

Steve
 
Steve,

Here's my basic set up...My project starts from a prg file where i do initializations and such. The project gets going with the following code:

Do form main
main.visible=.f.
Do form login
read events

My main form is top level and show as top level form. Same with my login form....once the proper authentication has been made in my login form, it's visible property gets set to .f. and the main form's visible property get set to .t.
Everything works except for the login form being already focused.

On the login form, I have two textboxes, and they both have code in their valid events...and that's the only code tied to them. Currently the tabindex of the actual form is 1, the user txtbox is 3, and the password is 4. I have no code in any startup events of the form right now, but like i've said before, i have attempted code...whether it be thisform.setfocus or thisform.show or whatever...

If you need any more info let me know...I'm still working on this...

thanks
 
Put on top of you initialization file command:

Application.visible = .f.
 
Tried that cegi...didn't work..

My whole issue is giving the first form shown..focus. The whole issue of making that main fox window disappear has been taken care of, but when it goes away, it takes focus from the first form shown.
 
Webrookie,

If I understand what you are saying you have two top level forms. The main form and the login form. If this is correct, keep the login form as the top level form and show the main form in the top level form.

Steve
 
The main form is a top level form because it is the main application, it has several other forms that are set up as "show in top level form." The main form contains the menu bar and the GUI for the user.

Maybe I'm not understanding your response so well.
 
I'm just guessing that if the login form doesn't have the focus, your main form does. Only having one top level form would take care of this. You could try something like this:

Create a public variable, say glLogin and set it to .F. in the login forms Load event. When the login form loses focus, and if both textbox values are valid, set it to .T. Now, in the main form's GotFocus event have something like this:

IF NOT glLogin
frmLogin.SetFocus
ENDIF

 
Sorry Steve, didn't work. I am clearly a lost cause...

My login form will just never have focus without user intervention...that's all.

thanks everyone for trying.
 
Ok, I have created a mock project which sums up my real project in a nutshell, as far as this thread is concerned.

You can download the zip file at
It's in VFP 6.0 SP4. It only involves two forms and a command button.

And it demonstrates the problem I am having right now.
 
Ok, I have created a mock project which sums up my real project in a nutshell, as far as this thread is concerned.

You can download the zip file at
It's in VFP 6.0 SP4. It only involves two forms and a command button.

And it demonstrates the problem I am having right now.

Keep in mind that it works if you run the main.prg in Fox, but if you run the executable I build, it doesn't work.
 
Try putting the form calls in a loop like this:

for x = 1 to 2
if x = 1
do form login
* any other processing here
else
do form main
endif
read events
next
 
Hey Webrookie,
I'm following you. Because I am facing the same problem with my project. Which one does work?

This one?
for x = 1 to 2
if x = 1
do form login
* any other processing here
else
do form main
endif
read events
next


If yes, isn't there other method to make it possible?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top