How to return focus.

How to return focus.

Postby HunterEC » Mon Dec 01, 2008 5: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.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Postby Antonio Linares » Mon Dec 01, 2008 3: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby HunterEC » Mon Dec 01, 2008 4: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.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Postby Antonio Linares » Mon Dec 01, 2008 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby HunterEC » Mon Dec 01, 2008 7: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
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Postby Antonio Linares » Mon Dec 01, 2008 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby HunterEC » Tue Dec 02, 2008 1: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.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Postby James Bott » Tue Dec 02, 2008 7: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby HunterEC » Tue Dec 02, 2008 7: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 ?
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Postby Antonio Linares » Tue Dec 02, 2008 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby HunterEC » Tue Dec 02, 2008 2: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.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Postby Antonio Linares » Tue Dec 02, 2008 4:20 pm

Gustavo,

Is app A a MsDos application ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby HunterEC » Wed Dec 03, 2008 5:13 am

Antonio:

Yes, App A is a MS-DOS 16 bit Clipper program.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 98 guests