OLE and Word : how to set focus to Word-window

OLE and Word : how to set focus to Word-window

Postby driessen » Wed Oct 01, 2008 5:36 pm

Hello,

I use this code to set the focus to the Word-window when using Word and OLE in my FWH-application :
Code: Select all  Expand view
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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

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

Postby driessen » 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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

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

Postby driessen » 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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby James Bott » Thu Oct 02, 2008 2:03 am

Michel,

Here is another one to try:

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

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby driessen » Thu Oct 02, 2008 7: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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby driessen » Thu Oct 02, 2008 7: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 :
Code: Select all  Expand view
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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Antonio Linares » Thu Oct 02, 2008 8:45 am

Michel,

Very good! :-)

Thanks for sharing it with us
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 88 guests