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(HWN D)". 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
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(HWN
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
ASKER
Thanks.
What if more than one window is opened for word - is there a way to find out the window name?
What if more than one window is opened for word - is there a way to find out the window name?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
'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