Word and Windows 7

Post Reply
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Word and Windows 7

Post by MarcoBoschi »

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
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: Word and Windows 7

Post by MarcoBoschi »

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
User avatar
MaxP
Posts: 85
Joined: Thu Jul 12, 2007 2:02 pm
Contact:

Re: Word and Windows 7

Post by MaxP »

You can try with this source

Best regards,
Massimo :wink:

Code: Select all

#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
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Re: Word and Windows 7

Post by Jeff Barnes »

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 12.01, xHarbour 1.2.1, Bcc582)
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: Word and Windows 7

Post by MarcoBoschi »

Many thanks Massimo
It works
I dont' understand opusapp but it works
thanks again
Marco Boschi
info@marcoboschi.it
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: Word and Windows 7

Post by MarcoBoschi »

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
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: Word and Windows 7

Post by MarcoBoschi »

I have the same problem with Excel.
Juts created worksheet remains in background
Marco Boschi
info@marcoboschi.it
User avatar
MaxP
Posts: 85
Joined: Thu Jul 12, 2007 2:02 pm
Contact:

Re: Word and Windows 7

Post by MaxP »

In EXCEL you can try this source:

Code: Select all

hProp := OleGetProperty( oExcel:hObj, "Hwnd" )
IF hProp <> NIL
    SetWindowPos( oExcel:Hwnd, -2, 0, 0, 0, 0, 3 )
ENDIF

 
Best regards,
Massimo :wink:
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Re: Word and Windows 7

Post by Gale FORd »

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
Post Reply