FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Word and Windows 7
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Word and Windows 7
Posted: Wed Jun 08, 2011 03:15 PM

In xp at the end of execution of this program I see word in foreground
In Windows 7 I have to click to bring it in foreground.
Any ideas
King regards
Marco

include "fivewin.ch"

function Main()
LOCAL oWord, oText

oWord := CreateObject( "Word.Application" )

oWord:Documents:Add()

oText := oWord:Selection()

oText:Font:Size := 16

oText:Invoke( "TypeText", "Test 1" + CRLF + CRLF )

oText:Font:Size := 8

oText:Invoke( "TypeText", "Test 2" + CRLF+ CRLF )

oText:Font:Size := 12

oText:Invoke( "TypeText", "Test 3" + CRLF+ CRLF )

oWord:Visible := .T.
oWord:WindowState := 1 // Maximize

return nil

Marco Boschi
info@marcoboschi.it
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Word and Windows 7
Posted: Thu Jun 09, 2011 08:53 AM

Please try this
Many thanks

include "fivewin.ch"

function Main()

LOCAL oDlg, oButton

DEFINE DIALOG oDLg FROM 10 , 10 TO 800 , 800 PIXEL

@ 1 , 1 BUTTON oButton OF oDlg ACTION CREATEWORD()

ACTIVATE DIALOG oDlg CENTER

RETURN NIL

FUNCTION CREATEWORD()

LOCAL oWord , oText

oWord := CreateObject( "Word.Application" )

oWord:Documents:Add()

oText := oWord:Selection()

oText:Font:Size := 16

oText:Invoke( "TypeText", "Test 1" + CRLF + CRLF )

oText:Font:Size := 8

oText:Invoke( "TypeText", "Test 2" + CRLF+ CRLF )

oText:Font:Size := 12

oText:Invoke( "TypeText", "Test 3" + CRLF+ CRLF )

oWord:Visible := .T.
oWord:WindowState := 1 // Maximize

return nil

Marco Boschi
info@marcoboschi.it
Posts: 99
Joined: Thu Jul 12, 2007 02:02 PM
Re: Word and Windows 7
Posted: Thu Jun 09, 2011 03:46 PM
You can try with this source

Best regards,
Massimo :-)


Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()


LOCAL oDlg, oButton

DEFINE DIALOG oDLg FROM 10 , 10 TO 800 , 800 PIXEL

@ 1 , 1 BUTTON oButton OF oDlg ACTION CREATEWORD()



ACTIVATE DIALOG oDlg CENTER

RETURN NIL 

FUNCTION CREATEWORD()

LOCAL oWord , oText , hWnd

oWord := CreateObject( "Word.Application" )

oWord:Documents:Add()

oText := oWord:Selection()

oText:Font:Size := 16

oText:Invoke( "TypeText", "Test 1" + CRLF + CRLF )

oText:Font:Size := 8

oText:Invoke( "TypeText", "Test 2" + CRLF+ CRLF )

oText:Font:Size := 12

oText:Invoke( "TypeText", "Test 3" + CRLF+ CRLF )



oWord:Visible := .T.
oWord:WindowState := 1 // Maximize

hWnd := FindWindow( "opusApp" )
IF hWnd > 0
        SetWindowPos( hWnd, -2, 0, 0, 0, 0, 3 )
ENDIF        

return nil
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: Word and Windows 7
Posted: Thu Jun 09, 2011 07:49 PM

Hi Marco,

This is per the Microsoft Knowledge Base article #886217:
To resolve this issue, modify the value of the ForegroundLockTimeout registry entry in Registry Editor. To do this, follow these steps:

1 Click the Start Orb, click Run, type regedit in the Open box, and then click OK.

2 In Registry Editor, locate and then click the following registry subkey:
HKEY_CURRENT_USER\Control Panel\Desktop

3 In the right pane, locate and then double-click ForegroundLockTimeout.

4 Under Base, click Decimal, type 0 in the Value data box, and then click OK. Note The default decimal value for the ForegroundLockTimeout registry entry is set as 200000.

5 Quit Registry Editor.

6 Restart your computer.
*This must be done for each User Account on the system.

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Word and Windows 7
Posted: Fri Jun 10, 2011 07:00 AM

Many thanks Massimo
It works
I dont' understand opusapp but it works
thanks again

Marco Boschi
info@marcoboschi.it
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Word and Windows 7
Posted: Fri Jun 10, 2011 07:09 AM

Jeff,
it works!
But is not a good idea to change this value in the customer registry editor.

King regards

marco

Marco Boschi
info@marcoboschi.it
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Word and Windows 7
Posted: Fri Jul 01, 2011 12:38 PM

I have the same problem with Excel.
Juts created worksheet remains in background

Marco Boschi
info@marcoboschi.it
Posts: 99
Joined: Thu Jul 12, 2007 02:02 PM
Re: Word and Windows 7
Posted: Fri Jul 01, 2011 04:01 PM
In EXCEL you can try this source:
Code (fw): Select all Collapse
hProp := OleGetProperty( oExcel:hObj, "Hwnd" )
IF hProp <> NIL
    SetWindowPos( oExcel:Hwnd, -2, 0, 0, 0, 0, 3 )
ENDIF


Best regards,
Massimo :-)
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Word and Windows 7
Posted: Fri Jul 01, 2011 04:45 PM

We have 20+ computers updated to Windows 7 so far and I have not had this problem.
I use the following lines:

::oExcel:Visualizar(.t.)
sysrefresh()
::oExcel := nil

Continue the discussion