Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Place Dialog on second screen

94 views
Skip to first unread message

Matthias Pospiech

unread,
Nov 30, 2006, 8:17:21 AM11/30/06
to
I have an application, where the second screen is connected to a machine
which has an VGA Input.

This screen must be completely filled with the Dialog and the Dialog
must be placed on the second screen.

Is there an automatic way to place a dialog on the second screen ?

Matthias

Tom Serface

unread,
Nov 30, 2006, 9:52:38 AM11/30/06
to
Typically the two screens are treated as one large screen so you could just
split the size and use MoveWindow() or SetWindowPos() in the dialogs
OnInitDialog() to set it position on the other screen. You can use
GetSystemMetrics() with SM_CXSCREEN to get the width of the screen. I'm not
sure, in the case of two screens if this will just return the width of the
primary or not (haven't tried that), but if they are both the same then if
it only returns one size that would be doing some of the work for you.

Tom

"Matthias Pospiech" <matth...@gmx.de> wrote in message
news:ekmlo2$scm$1...@newsserver.rrzn.uni-hannover.de...

AliR (VC++ MVP)

unread,
Nov 30, 2006, 10:43:27 AM11/30/06
to
Thre are functions available to for getting information for a multi-monitor
setup.

EnumDisplayMonitors
GetMonitorInfo
MonitorFromPoint
MonitorFromRect
MonitorFromWindow

Take a look at these. What happens is that the x coordiante of the origine
of each monitor is the horizontal resolution of the last monitor + 1.
So GetMonitorInfo will tell you what that value is along with the resolution
of that monitor.

What you want to do is call GetMonitorInfo for the second monitor and then
use SetWindowPos to place your window within the coordinates returned by
GetMonitorInfo.

Here is an example, of a window going fullscreen on the monitor that it's
parent window is on. (if i was to set it to 0,0 instead of Rect.left,
Rect.top it would show up on the first monitor.

CRect Rect;
HMONITOR hMon =
MonitorFromWindow(GetParent()->m_hWnd,MONITOR_DEFAULTTONEAREST);

MONITORINFO MonitorInfo;

MonitorInfo.cbSize = sizeof( MonitorInfo );
::GetMonitorInfo( hMon, &MonitorInfo );
Rect = MonitorInfo.rcMonitor;


SetWindowPos(&wndTopMost,Rect.left,Rect.top,Rect.Width(),Rect.Height(),SWP_S
HOWWINDOW);

AliR.


"Matthias Pospiech" <matth...@gmx.de> wrote in message
news:ekmlo2$scm$1...@newsserver.rrzn.uni-hannover.de...

0 new messages