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!

Application Focus

Status
Not open for further replies.

JBalcerzak

Programmer
Sep 5, 2002
73
US
Hello All -
I've got an app I'm building and I'm having trouble with a focus issue on startup. I instantiate my app object and load my menu and call a login modal dialog. However, once I've authenticated the user and release the login dialog my app title bar goes into the background (light blue inactive title bar instead of solid blue active window title bar). If I click anywhere on the app to activate the window, it activates normally (goes to solid blue) and I can use my menu to call up all the other forms and such and continue to operate normally. Just wondering if there is something I can do to have the main window active once I clear the login dialog - or is there a better way to do this altogether?

Thanks
 
JBalcerzak

Have you tried :
_screen.Activate

After the release of your login form.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
No - but that sounds like just the thing. Forgot that _screen has an activate method just like a form - they're both objects, duh!

Thanks Mike!
 
You could try this ...

DECLARE INTEGER SetForegroundWindow in WIN32API INTEGER hWinHandle
SetForegroundWindow(_VFP.HWND)

If you are using VFP 6 or earlier, you would have to use foxtools to get the window handle.
 
That sounds like an interesting method as well. I'll have to try them both.

Thanks Chris!
 
I had the same problem. If you are still interested, I found accidentally the answer (I guess you still have the problem). Even if you have _screen.visible=.F. in the main program, create a config.fpw file in the same directory with at least one line: SCREEN = OFF. Good luck!
 
I am suffering from a very similar effect - my program starts up fine with a splash screen. This then is properly released but the application doesn't receive focus. I am wanting the SCREEN to appear as I think JBalcerzak is. Is that correct?

I tried Chris' suggestion and the result was that the button on the taskbar flashed blue at me, but it didn't give my application focus. I tried it again, feeding in the SCREEN's HWnd with the same result.

I've also got _SCREEN.Show & _SCREEN.Activate in my startup program. I have also got SCREEN = OFF in the fpw file.

Any more ideas guys?

Stewart
 
I'm not sure this will work. but try it:

_Screen.ActiveForm.Activate()
or
_Screen.ActiveForm.Show()
or
_VFP.ActiveForm.Activate()
or
_VFP.ActiveForm.Show()


-- AirCon --
 
What worked for me was to keep a reference count for the number of active windows. I made all my forms off a base class form that would incriment the count in the load method and decriment the count in the unload method. Whenever the reference count got to zero, I would fire a _screen.show() and the app would get the focus even though there were no windows, and thus controls to receive focus, active and displayed. This has really worked well so far.

Hope that gives people ideas.

Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top