By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,929 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,929 IT Pros & Developers. It's quick & easy.

Dual Head Monitor

P: n/a
Hi

I'm writing a MFC C++ application using Visual .NET. I'm using a Dual
Head video card with 2 monitors. I want to start my application in the
first monitor but open a dialog box in the second monitor. I tried to
set the X position of the dialog box greather thant the first screen
resolution, but the dialog box still appear on the first monitor.

Can you help me ?

Thanks

Dec 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

fournij wrote:
Hi

I'm writing a MFC C++ application using Visual .NET. I'm using a Dual
Head video card with 2 monitors. I want to start my application in the
first monitor but open a dialog box in the second monitor. I tried to
set the X position of the dialog box greather thant the first screen
resolution, but the dialog box still appear on the first monitor.

Can you help me ?


[Off Topic]
try http://groups.google.com/group/microsoft.public.vc.mfc

Dec 15 '05 #2

P: n/a
fournij wrote:
Hi

I'm writing a MFC C++ application using Visual .NET. I'm using a Dual
Head video card with 2 monitors. I want to start my application in the
first monitor but open a dialog box in the second monitor. I tried to
set the X position of the dialog box greather thant the first screen
resolution, but the dialog box still appear on the first monitor.

Can you help me ?

Thanks


You'll get better feedback if you post this question in a MS or VC++
newsgroup.

Here's some related info:

You could use 'MonitorFromPoint()' or 'MonitorFromWindow()' to
determine which monitor it is shown on. See also
http://msdn.microsoft.com/library/de...nitor_5isz.asp
("Positioning Objects on Multiple Display Monitors") and the associated
code sample at
http://msdn.microsoft.com/library/de...nitor_9t0w.asp
("Positioning Objects on a Multiple Display Setup"):

#include <windows.h>
#include "multimon.h"

#define MONITOR_CENTER 0x0001 // center rect to monitor
#define MONITOR_CLIP 0x0000 // clip rect to monitor
#define MONITOR_WORKAREA 0x0002 // use monitor work area
#define MONITOR_AREA 0x0000 // use monitor entire area

//
// ClipOrCenterRectToMonitor
//
// The most common problem apps have when running on a
// multimonitor system is that they "clip" or "pin" windows
// based on the SM_CXSCREEN and SM_CYSCREEN system metrics.
// Because of app compatibility reasons these system metrics
// return the size of the primary monitor.
//
// This shows how you use the multi-monitor functions
// to do the same thing.
//
void ClipOrCenterRectToMonitor(LPRECT prc, UINT flags)
{
HMONITOR hMonitor;
MONITORINFO mi;
RECT rc;
int w = prc->right - prc->left;
int h = prc->bottom - prc->top;

//
// get the nearest monitor to the passed rect.
//
hMonitor = MonitorFromRect(prc, MONITOR_DEFAULTTONEAREST);

//
// get the work area or entire monitor rect.
//
mi.cbSize = sizeof(mi);
GetMonitorInfo(hMonitor, &mi);

if (flags & MONITOR_WORKAREA)
rc = mi.rcWork;
else
rc = mi.rcMonitor;

//
// center or clip the passed rect to the monitor rect
//
if (flags & MONITOR_CENTER)
{
prc->left = rc.left + (rc.right - rc.left - w) / 2;
prc->top = rc.top + (rc.bottom - rc.top - h) / 2;
prc->right = prc->left + w;
prc->bottom = prc->top + h;
}
else
{
prc->left = max(rc.left, min(rc.right-w, prc->left));
prc->top = max(rc.top, min(rc.bottom-h, prc->top));
prc->right = prc->left + w;
prc->bottom = prc->top + h;
}
}

void ClipOrCenterWindowToMonitor(HWND hwnd, UINT flags)
{
RECT rc;
GetWindowRect(hwnd, &rc);
ClipOrCenterRectToMonitor(&rc, flags);
SetWindowPos(hwnd, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE |
SWP_NOZORDER | SWP_NOACTIVATE);
}

Dec 15 '05 #3

P: n/a
fournij wrote:
I'm writing a MFC C++ application using Visual .NET. I'm using a Dual
Head video card with 2 monitors. I want to start my application in the
first monitor but open a dialog box in the second monitor. I tried to
set the X position of the dialog box greather thant the first screen
resolution, but the dialog box still appear on the first monitor.

Can you help me ?


Nope. But somebody in comp.os.ms-windows.programmer.win32 can.

V
Dec 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.