Avatar of formadmirer
formadmirerFlag for United States of America asked on

VFP Blinky Cursor

Hi all. Have a simple login form, just email and password textboxes. The email box has TabStop T and a Tab Index of 1.

When the form loads I would like to have the cursor placed inside the email textbox so the user can just start typing, instead of having to click in the box first.

I have tried to do this using code in init:
thisform.txtEmail.setfocus()
thisform.txtEmail.click()

and have also tried using the same code in the email textboxes' WHEN and GotFocus.

Additionally I've tried each of these with SelectOnEntry T and F.
Nothing has worked. I'm sure this has to be simple. Help please.
FoxPro

Avatar of undefined
Last Comment
Olaf Doschke

8/22/2022 - Mon
SOLUTION
Cyril Joudieh

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Pavel Celba

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
formadmirer

I've tried with just setfocus in ever conceivable location but to no avail. Added the click since when the form is displayed, if I click anywhere on the form itself the cursor immediately pops up inside the email textbox like I want. It just won't do it without a click first.

The form is so simple. Literally it's just an email and password box with nothing in the init except for the two lines of code above.

I figured I'd use this simple form to find a fix as all the forms within my app have the same problem. No matter what I do I can't get a cursor to appear in the first textbox after the form loads.

And it's not just that the cursor isn't visible - it isn't there. If you load the form and begin to type the keystrokes act upon Window's desktop, and not the form or it's contents.

----
Maybe the form is not active? - it is called from within Main, loads before most anything else and is the only form activated in Main.

Is the code in the Form's Init? - yes. I've tried the Form's init, the textboxe's Init, When and GotFocus. Nothing I've tried has resulted in the cursor appearing in the textbox ready to take input.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
formadmirer

Thanks. I'll give the MODAL option a shot.

I did find a workable solution on another forum after lots of searching both last night and this morning. For anyone else with the same issue the solution is here:

http://www.tek-tips.com/viewthread.cfm?qid=583761

I'll post back about my experience with setting the form to MODAL shortly.
ASKER
formadmirer

Sorry pcelba for overlooking a response to your suggestions. Yes, I did try what you suggested and set the form to Always ON Top and placed  

ACTIVATE WINDOW <YourLoginFormName>
THISFORM.<YourTextBox>.SetFocus

into the form's refresh method without success. I also tried it in the init, with the form as both Modal and Modeless but to no avail.

Additionally I've now tried the suggestion to make the form Modal instead of Modeless, and that too did not work.

Other suggestions I've read for the issue said to remove _screen.visible=.F. in the program's MAIN and instead use a config.fpw with SCREEN=OFF. That did not work.

A few other suggestions revolved around first removing the form's focus and then reestablishing it. Those did not work either.

But I did find one thing that does work at the link posted above, so for me the issue is resolved and I'll mark this as so.

I appreciate all the help and suggestions - thanks!
Your help has saved me hundreds of hours of internet surfing.
fblack61
Pavel Celba

Great it works for you but we still don't know where the problem is... If you have conditions specific to ones described in Tek-tips web (VFP 6 and SCREEN OFF) then all our hints were out of scope probably...

OK, no time and no reason to investigate it further.

Thank you for knowledge sharing!
Olaf Doschke

If you used the starred solution
Declare BringWindowToTop in User32 Long nhWnd

You better change to SetForegroundWindow:

DECLARE INTEGER SetForegroundWindow IN user32;
      INTEGER hwnd

The hwnd does not need to be determined by FindWindow, hwnd is a form property of _screen and any vfp form, so if you do DO FORM, you do

DO FORM login.scx NAME loLogin
SetForegroundWindow(loLogin.hwnd)

From this discussion you can see foreground window will be made the global foreground window, the active window of all currently running applications.

I used it when I wanted to let an InternetExplorer.Application window with HTML formatted application news be in front of everything, after the login. It's unfortunate, but sometimes even new windows of the recently started application do not automatically become foreground windows.

Bye, Olaf.

Also: Calling a control.click does not cause the same as clicking. It's the mouse click windows event, that is forwarded to VFP, which then calls the click method, besides many other things, but calling click does not cause all the events including activating the form and making it the foreground window, if it isn't already.