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

activate first form from a program

Status
Not open for further replies.

Yeap

Programmer
Jul 5, 2004
12
RO
when i build a application under vfp 5.0, the first form
does not get the focus. I mean the control bar is not active. The only way to acticvate it is by clicking in that form or pressing alt+tab. How can i get the focus after i start the program?
 
yeap, I am not sure if I understand your question, but I'll give it a shot.

1. When the form is open, select the Veiw / Tab Order menu options and one-at-a-time, starting with the first item to set focus to, click on each item to set the tab order.

2. You can programmatically setfocus in the INIT event of the form by adding code something like this:

THISFORM.myControlname.setfocus



Jim Osieczonek
Delta Business Group, LLC
 
If it is the form and not a form control, then I's assume the issue may be coming from how the main.prg is constructed.

Brian
 
This sounds like you are using Top-level forms in the application.

After you DO FORM (form based forms) or Show the form (assuming you are using class based forms), try executing a SetFocus() based on the reference to the form.

Code:
loForm = createobject("MyForm")
loForm.Show()
loForm.SetFocus()

_RAS
VFP MVP
 
I don't work with classes although i should. Yes, my first form is "as top level form". In my main program i use
do form xxx.scx
read events
I still didn't managed to activate it :(
 
that didn't solved the problem neighter.
If i have total commander starded, and i start my program,
total commander is still active. I can't belive this thing
is so hard to do. I have this problem scince i started
programming in Vfp. If it's ok, please tell me a way to send
you my form to see what's wrong along with my main.prg

 
Is it possible that "Total Commander" is a Always-on-top" application? I have tested this and it works for me using VFP 8. I even recompiled and tested this in VFP 5, no problem.

My code in the previous message has a bug in it in case you have ON ERROR *, I forgot to include the object name I wanted to SetFocus() to in the object containership in the line of code I SetFocus().

I recall one of the older versions having problems with being on top, but I thought this approached solved it. My memory on older versions of VFP is starting to get stale, sorry.

_RAS
VFP MVP
 
i have solved the problem by moving
the
applicaltion.visible=.F.
to the gotfocus event of the first control of the form.
Thanks all of you anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top