Link to home
Start Free TrialLog in
Avatar of benoitd
benoitd

asked on

Launching applications directly into a specific monitor

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!
ASKER CERTIFIED SOLUTION
Avatar of RJSoft
RJSoft

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of Mindphaser
Mindphaser

Force accepted

** Mindphaser - Community Support Moderator **