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

When clicking on the exe of the project created by VFP9, it does not have the focus

Status
Not open for further replies.

alexandreflm

Programmer
Jun 15, 2014
8
BR
When clicking on the exe of the project created by VFP9, it does not have the focus

Good afternoon, fellow colleagues.

My problem is this:

On the desktop of windows 10, I have the shortcut to my program (which was generated in vfp9), but if I click the mouse or select and give "enter", it opens normally, but the focus does not go to my program, the focus is on the shortcut on the windows desktop.

My program relies on a form, disabling the vfp window.

Has anyone had this problem and could you help me?

thank you all in advance.
 
What is the shortcut starting? Do you build an EXE or is it a shortcut tot a PJX or PRG?

Bye, Olaf.
 
I never experienced an EXE not getting focus at its start. Are you seeing anything from your EXE? If you didn't turn _SCREEN off that will likely have focus, as it is the top level form of the EXE, but what you report is the focus stays on the shortcut. I don't see how that would happen.

Bye, Olaf.
 
At the start of your main program, do this:

Code:
DECLARE INTEGER BringWindowToTop IN user32;
    INTEGER hWindow

BringWindowToTop(_SCREEN.Hwnd)

If you don't have a main program, do it in the Init event of your main form.

If your application does not show _SCREEN (that is, if it has a top-level form), then pass the form's Hwnd instead of _SCREEN's.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
That would perhaps solve it, but shouldn't be necessary.

Did you change shortcut properties to start the EXE minimized?

Bye, Olaf.
 
I tried using
"BringWindowToTop (_SCREEN.Hwnd)" and also BringWindowToTop (thisform.Hwnd) in form init

but in both cases it remained the same.
 
I see in your main program you are declaring SetForegroundWindow() and SetActiveWindow(). Are you calling these functions from within your form? (I can't open the form because it has dependencies.) If so, why are you doing so? Could those calls be changing the Z-order of the form or the outer window?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Can you just add a MESSSAGEBOX("Test") right in front of the DO FORM you expect to run?

Bye, Olaf.
 
Sorry for the inconsistency.
I've been trying all the alternatives and I ended up polluting the source
this system comes from vfp5 and is in vfp9 to about 10 years.
but have always had this problem.
 
I have removed all the function calls to put the screen in the front that I put, and it continues the same way.
 
Is it possible that you have the AlwaysOnBottom property set to .T. This is a property of your form, and also of _SCREEN. It's very unlikely that it will be set to .T., but I can't think of anything else just now.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Dear friends of VFP

I found my problem.

in my config.fp I had put the option screen = off
And being this way the "order Z" was not inserted with my project / exe

What I did was put in config.fp screen = on (or simply remove the screen = off),
put before "form meuform"
A DEACTIVATE WINDOW "Microsoft Visual FoxPro"
and an ACTIVATE WINDOW myform
soon after the "form meuform"


I am very grateful for the support of all those who have helped me in this matter, and I am available to assist you if you need me.
 
When this works, your own form just needs to be a top level form and you can add back SCREEN=OFF. It's the better option, as this works without any flicker of showing the _screen for a short instant.

Edit: This means setting the ShowWindow property to 2 (as top level form).

What might contribute to the form not getting focus is the start of the app takes long, before you start the form. Since an EXE process can take long and run formless, I don't think Windows (the OS) waits forever to give focus to the first fomr started. On the other side any form starting up will get focus and become the active window on the desktop.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top