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

Setting Focus to VFP form 2

Status
Not open for further replies.

foxbldr

Programmer
Apr 16, 2002
109
0
0
CA
I have a VFP6 application(on Win 98/XP) compiled with the line "_screen.visible=.f." in my main.prg. When I run my exe, the focus is not set to my form and user has to click in the form to set the focus. How do I set the focus to the first control on my form?

Thanks

 
Set your tabindex property of your text box or controls on the form. Start with first control as tabindex=1.

good luck
 
Try putting the _screen.visible in the form's INIT event instead of in the PRG.

Mike Krausnick
Dublin, California
 
I'm having the same problem. I have tried the suggestions above and they have not solved it.

I have developed top-level forms before that have worked OK. I can't figure out what's different.

Any other suggestions?

Thanks

David
 
Thanks for the replies. None of the solutions worked for me.
Is there a function like "BringWindowToTop(API)" in VFP?

Thank you
 
I've never experienced the problem like you. Also you are using VFP6, so I'm not sure about this, let me know how it works

Declare Long FindWindow in User32 String, String
Declare BringWindowToTop in User32 Long nhWnd

hWnd = FindWindow(Null, This.Caption)
BringWindowToTop(hWnd)


-- AirCon --
 
It worked for my form! Thanks a bunch!

I'll keep making changes to the form to see if I can determine what caused this originally.

Thanks again.

David
 
You are welcome David.
I hope it you can find out the real problem is

Regards [thumbsup2]

-- AirCon --
 
I have from time to time had this issue and never could find the hitch, the solution provided by AirCon is a keeper. You get a star

Steve Bowman
steve.bowman@ultraex.com

 
Guys,

My question was 'Is there a function like "BringWindowToTop(API)" in VFP?'

I have used what AirCon suggested and it worked for me!Can we do the same thing by using form's properties or VFP6's in-built functions, without calling BringWindowToTop?
My application is a SDI and it is used for look-up clients by using client's name. I was playing with properties like DESKTOP, ALWAYSONTOP, SHOWWINDOW, etc.

Thanks
Foxbldr
 
I remarked AirCon's code and started tinkering...

I had 'application.visible=.F.' in the Init of my form.

I moved it to the Load event and had the same problem.

I moved it the the Refresh event and now it works.

Does this make sense? Is this acceptable coding?

David
 
David,
I think it's ok for you to do that, as long as it has no effect to the runtime performance or any other issue. Just remember that Refresh got fired many times, maybe you can use a variable to indicate that 'application.visible=.F.' only run for the first time.

Foxbldr,
I don't think VFP has a replacement for "BringWindowToTop(API)". And as I mentioned I've never experienced this problem. So I have no further idea, perhaps someone has ?

Regards

-- AirCon --
 
I am using SCREEN=OFF in config.fpw instead of "_screen.visible=.f." in prg file and I never had problem with loosing of focus in my APP


Zhavic



---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
Placing things in the refresh method tends to slow down the works (it fires many times) Try putting your Application.Visible = .f. in the Activate method instead.
 
I took the code out of the refresh method and tried Zhavic's method using config.fpw. It works.

Thanks all!

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top