FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to return focus.
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
How to return focus.
Posted: Mon Dec 01, 2008 05:23 AM
I'm using a FiveWin program (i.e. Program A) that calls Program B through Windows START /I /B Program B command. How can I force focus back to program A ? Via the keyboard this is done with Alt-Tab Thank you.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How to return focus.
Posted: Mon Dec 01, 2008 03:38 PM

Gustavo,

You could use a TIMER that after some time, gives the focus again to your application.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
How to return focus.
Posted: Mon Dec 01, 2008 04:16 PM

Antonio:

Is there a way to send an Alt-Tab keystroke to Windows ? Where I can find more info on setting up a timer ? Thank you.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How to return focus.
Posted: Mon Dec 01, 2008 06:47 PM

Gustavo,

> Where I can find more info on setting up a timer ?

Please review FWH/samples/TestTime.prg

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
How to return focus.
Posted: Mon Dec 01, 2008 07:41 PM

Antonio:

I'm calling a 32 bit FWH program from a 16bit one. The 16bit one cannot be ported now to FWH (over 20,000 lines), so basically I need the FWH program to return focus to the 16bit app. Any ideas ? Thank you

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How to return focus.
Posted: Mon Dec 01, 2008 09:16 PM

Gustavo,

You can use FindWindow( 0, cTitle ) to get the handle of the window to give the focus to and then call SetFocus( hWnd )

http://msdn.microsoft.com/en-us/library/ms646312(VS.85).aspx

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
How to return focus.
Posted: Tue Dec 02, 2008 01:24 AM

Antonio:

Thanks for the tip. I've already used the FindWindow() but in this case our user can have more than 1 instance of the program open (with the same caption). I think on 3 possible solutions:
1. Emulate an Alt-Tab keystroke ?
2. Find out which window called Program B and return control to it.
3. Generate a new caption for each Program A instance.

Any suggestions ? Thank you.

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
How to return focus.
Posted: Tue Dec 02, 2008 07:32 AM

Hunter,

If I understand correctly, you want to call another program from the FW program, then return focus to the FW program. Since you already know the handle of the window doing the calling of the other program, then just try:

SetFocus( oWnd:hWnd )

Where oWnd is the window of the appliction that is calling the other program.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
How to return focus.
Posted: Tue Dec 02, 2008 07:50 AM

James:

Thanks for the advice. Now here's what I'm trying to do.
1. App A (16bit Clipper) calls App B (FWH)
2. App B (FWH) RUNs START /B /I APP C (FWH)
3. App C stays open and returns control to App B, which automatically closes.
4. Focus goes back to App C but I need it (focus) back to App A (16bit)

Converting App A to FWH is now out of the question (over 20,000 lines and customers won't wait). Any ideas ?

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How to return focus.
Posted: Tue Dec 02, 2008 08:47 AM

Gustavo,

You can write the handle of the A window in a file from the A application:

MemoWrit( "handleA.txt", AllTrim( Str( oWndMain:hWnd ) )

Then from C, read handleA.txt using MemoRead( "handleA.txt" ) and give the focus to it:

SetFocus( Val( MemoRead( "handleA.txt" ) ) )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
How to return focus.
Posted: Tue Dec 02, 2008 02:31 PM

Antonio:

That's what I thought, but how I get the window handle in app A since FiveWin is not linked ? If I tried to linked it, Clipper runs out of memory. Is there a C function that I can call from Clipper to get the window handle ? Thank you very much.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How to return focus.
Posted: Tue Dec 02, 2008 04:20 PM

Gustavo,

Is app A a MsDos application ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
How to return focus.
Posted: Wed Dec 03, 2008 05:13 AM

Antonio:

Yes, App A is a MS-DOS 16 bit Clipper program.

Continue the discussion