FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour OLE and Word : how to set focus to Word-window
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
OLE and Word : how to set focus to Word-window
Posted: Wed Oct 01, 2008 05:36 PM
Hello,

I use this code to set the focus to the Word-window when using Word and OLE in my FWH-application :
BringWindowToTop(FindWindow("OpusApp",NIL))

Sometimes it works fine but sometimes the Word-button on the bar at the bottom of my screen starts flickering. I have to push on it before Word has actual the focus.

What is wrong with my code ? How can I set the focus to Word in an automatic way ?

I'm using Windows XP, Office 2003 or 2007, FWH 8.09 and xHarbour Builder Sept. 2008.

Thanks a lot in advance for any help.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
OLE and Word : how to set focus to Word-window
Posted: Wed Oct 01, 2008 10:46 PM

Michel,

Did you try what Jeff pointed you from Microsoft ?

http://forums.fivetechsoft.com/viewtopic.php?t=10978

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
OLE and Word : how to set focus to Word-window
Posted: Wed Oct 01, 2008 11:17 PM

Antonio,

The article which Jeff pointed me to, was about the ForeGroundLockTimeOut in the Windows register.

I changed the register, but unfortunately, it didn't help. The problem is still occuring.

Any idea ?

Thanks.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
OLE and Word : how to set focus to Word-window
Posted: Wed Oct 01, 2008 11:31 PM

Michel,

Does this code makes a difference ?

Setforegroundwindow(FindWindow("OpusApp",NIL))

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
OLE and Word : how to set focus to Word-window
Posted: Wed Oct 01, 2008 11:47 PM

Antonio,

No, your suggestion doesn't work.

I also tried

  • BringWindowToTop()
  • ShowWindow()
  • SetFocus()

But I don't have any success with one of them.

Thanks.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
OLE and Word : how to set focus to Word-window
Posted: Thu Oct 02, 2008 02:03 AM

Michel,

Here is another one to try:

SetWindowPos( oWnd:hWnd, -2, 0, 0, 0, 0, 3 )

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
OLE and Word : how to set focus to Word-window
Posted: Thu Oct 02, 2008 07:29 AM

James,

Thanks a lot for your effort but I'm afraid the problems stays as it was.

Thanks.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
OLE and Word : how to set focus to Word-window
Posted: Thu Oct 02, 2008 07:44 AM
Guys,

Thanks a lot for your help.

I was able to solve the problem.

After a deep debug, I noticed that the problem occurred at this line :
hWordOle:Documents:Save()

I added a BringWindowToTop() just in front of this line and now the problem is solved.

Thanks a lot for your efforts.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
OLE and Word : how to set focus to Word-window
Posted: Thu Oct 02, 2008 08:45 AM

Michel,

Very good! :-)

Thanks for sharing it with us

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion