Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

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
0
joex
Asked:
joex
  • 2
1 Solution
 
puppydogbuddyCommented:
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&)

0
 
joexAuthor Commented:
Thanks.

What if more than one window is opened for word - is there a way to find out the window name?
0
 
puppydogbuddyCommented:
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now