Launching applications directly into a specific monitor

benoitd
benoitd used Ask the Experts™
on
Hi,

I have a multi-monitor problem to which I cannot find the solution. What I'm trying to do is to launch applications on specific monitors on Windows 2000. I've been trying to use ShellExecuteEx with a proper hMonitor in the SHELLEXECUTEINFO structure, but it seems to be impossible to make it work properly. The application always opens on the primary monitor. Using the multi-monitor API, I am able to move it to any screen after it has been lauched but I'm not able to make it directly open into the monitor of my choice.

Here's the code I use:

// build the shelexecute structure
SHELLEXECUTEINFO info;
info.cbSize = sizeof(SHELLEXECUTEINFO);
info.fMask = SEE_MASK_HMONITOR;
info.hwnd = NULL;
info.lpVerb = NULL;
info.lpFile = "test.txt"; // file to be "executed"
info.lpParameters = NULL;
info.lpDirectory = NULL;
info.nShow = SW_SHOWNORMAL;

// show the file on each monitor - DOESN'T WORK: all are shown on same monitor
for (int i = 0; i < m_nbMon; i++)
{
info.hMonitor = m_hMon[i];
ShellExecuteEx(&info);
}

m_hMon[] was populated correctly by a callback function called by EnumDisplayMonitors.

Is that hmonitor feature in ShellExecuteEx really working?

Any help would be appreciated! Any code that does it even better!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Is your call to ShellExecuteEx being preformed only once? If the app is SDI then would not ShellExecute be calling an app that is already open? Also I notice no "open" statement. (info.lpVerb = NULL;) Check the return value for ShellExecuteEx. In my older api's the return value is a valid HINSTANCE (HINSTANCE < 32 is error).

I am not sure about the NULL's for the Windows. The default Window (NULL) is the apps monitor (I imagine). You may have to collect HWND's for the monitors also.

Since you have already established that the api works, why not create a loop that sends output to all the screens in your? Just a thought.

Hope this helps. I need some points so I can ask a question.

I am creating a security app. A screen saver type that locks up the system. But HOW do I stop the user from pressing F5 or space bar and going into protective mode?

Or can I create an app that starts up in protective mode and starts up in normal mode?

Thanks
Richard Jones (rjsoftware2000@yahoo.com)


Commented:
This question didn't show any activity for more than 21 days. I will ask Community Support to close it unless you finalize it yourself within 7 days.
You can always request to keep this question open. But remember, experts can only help if you provide feedback to their comments.
Unless there is objection or further activity,  I will suggest to accept

    "RJSoft"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
========
Werner
Force accepted

** Mindphaser - Community Support Moderator **

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial