Solved

ShellExecute Open Document - How to pop on top?

Posted on 2016-09-04
3
27 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
3 Comments
 
LVL 15

Accepted Solution

by:
Minh Võ Công earned 500 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

773 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