Link to home
Start Free TrialLog in
Avatar of joex
joex

asked on

Displaying word app on top

When running the attached scao.cpp file under XP, a word application is launched and appears on top.

However, when running on Windows 7, the word application is launched, but it does not appear on top.

To make the word app appear on top, it seems desirable to get the HWND for the MSWordApplication in the code (m_app).  The HWND could then be used to make a call to "::setForegroundWindow(HWND)".  However, it is unclear how to get the HWND for the MSWordApplication (see MSWord.h).

If the HWND was available, it seems like the setForegroundWindow call should follow  "m_app->Activate()".        The following comment was inserted to simplify finding this call:

//
//   HOW TO MAKE THE WORD APP APPEAR ON TOP?????
//


Thanks in advance.


Scao.cpp
Scao.h
MSWord.h
Avatar of puppydogbuddy
puppydogbuddy

Try using the FindWindow by class name, then use the setForegroundWindow as you indicated in your post.


'Use the FindWindow API call to find a window of the specified class. Pass a long NULL pointer for the window name.  The class name for Word is "OpusApp"

Declare Function FindWindowByClass Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As Long) As Long

Dim hwnd As Long

'ClassName for Word: OpusApp

'Get the handle to the Word window.
hwnd = FindWindowByClass("OpusApp", 0&)

Avatar of joex

ASKER

Thanks.

What if more than one window is opened for word - is there a way to find out the window name?
ASKER CERTIFIED SOLUTION
Avatar of puppydogbuddy
puppydogbuddy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial