Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ShellExecute Open Document - How to pop on top?

Posted on 2016-09-04
3
Medium Priority
?
76 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

636 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