?
Solved

ShellExecute Open Document - How to pop on top?

Posted on 2016-09-04
3
Medium Priority
?
59 Views
Last Modified: 2016-11-29
I am using ShellExecute  with verb "open" to show *.txt files and *.pdf files.   I have been doing this forever, and was simple and worked fine.  Recently I changed some of the architecture of my application ( MFC, C++, VS2015 ) in that certain panels are Modal, others non-Modal, and I have various situations like "a Modal that is a child of a non-Modal" and so forth.   Now when I do a ShellExecute, the document is not on top -- its 'under' one or more of the screens of my app.  So, I've tried a few things to make it pop on top, like:

Instead of:
HINSTANCE h = ShellExecute(NULL, _T("open"), doc, NULL, NULL, SW_SHOWNORMAL);

I tried:
HWND hwnd = this->GetSafeHwnd();
HINSTANCE h = ShellExecute(hwnd, _T("open"), doc, NULL, NULL, SW_SHOWNORMAL);

( and in the above, instead of "this" which is the currently-open Modal panel, I tried passing its non-modal parent panel, and other guesses)

I also tried:
HINSTANCE h = ShellExecute(HWND_TOPMOST, _T("open"), doc, NULL, NULL, SW_SHOWNORMAL);

But in all cases, the document opens behind my full-screen panel or its parent, and can't be seen.

Is there some way to make the thing pop up 'top-most' ?
0
Comment
Question by:tullhead
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 15

Accepted Solution

by:
Minh Võ Công earned 2000 total points
ID: 41864867
You can use ShellExecuteEx to create process and use SetForegroundWindow, SetActiveWindow to bring the window to top z order.

http://stackoverflow.com/questions/17166178/shell-execute-bring-window-to-front
0
 

Author Comment

by:tullhead
ID: 41870676
Didn't try your solution - had already found another way before  you posted -- but thanks!
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41905418
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Minh Võ Công (https:#a41864867)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question