Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Multiple Monitors

Author
Message
Westa
13
Years of Service
User Offline
Joined: 28th Oct 2011
Location:
Posted: 13th Feb 2018 23:46
Is there any method - that anyone has discovered in either Tier1 or Tier2 that allows selection of which monitor in a multi-monitor setup a game is to be displayed on?

Westa
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Feb 2018 00:54
i think you can use setwindowposition() to make the window appear on a second monitor
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 14th Feb 2018 03:48
Quote: "i think you can use setwindowposition() to make the window appear on a second monitor"


That has no affect if you are running in fullscreen as most games would, e.g. SetWindowSize(1024, 768, 1)

To my knowledge there is no way to determine whether the user has 1 or more monitors nor to select where it appears fullscreen. It will always be placed on the primary monitor. Seems like a good feature request though.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Feb 2018 19:47 Edited at: 14th Feb 2018 19:48
Maybe try running as a window, set it's position to the monitor you want to display on. Then change the window to full screen
Westa
13
Years of Service
User Offline
Joined: 28th Oct 2011
Location:
Posted: 20th Feb 2018 08:47 Edited at: 20th Feb 2018 08:48
Ok so - after a lot of testing - it turns out that for Tier2 users at least there is a way to open the AppGameKit window full screen on a second or even third screen - and possibly to span multiple windows depending on your graphic card setup.

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// quick hack for now to get location of usable secondary monitor.
// setup some globals for now
int gCountMonitors = 0;
int gPreferedMonitor = 0;
int gStoredMonitor = 0;
HMONITOR gPrefhMonitor; // this will hold the direct reference to the monitor we want to open full screen window on eventually

BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
// count total number of monitors
gCountMonitors++;
if (gCountMonitors == 1 | gCountMonitors == gPreferedMonitor)
{
gStoredMonitor = gCountMonitors;
gPrefhMonitor = hMonitor;
}
return TRUE;
}


///////////////////////////////////////////////////////////////////////////////////////////////
// inside the main window

int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{

... Just before the call to CreateWin32Window(

// set a value for the monitor we would like to open 1,2,3
gPreferedMonitor = 2; // set the preferred monitor for display

// Enumerate the monitor list and get core monitor metrics for either the default monitor or a preferred monitor
gCountMonitors = 0;
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, NULL);

/////////////////////////////////////////////////////////////////////////////////////
// create a win32 window for the app
HWND hWnd = CreateWin32Window( hInstance, DEVICE_WIDTH, DEVICE_HEIGHT, uString("AGK"), dwCenterWindowX, dwCenterWindowY, FULLSCREEN )

////////////////////////////////////////////////////////////////////////////////////////////////////////

The rest of the magic then needs to happen inside CreateWIn32Window()

...

RECT rc;
GetWindowRect(GetDesktopWindow(), &rc);


//Immediately after the call to GetWindowRect we need to add a new set of code
//handle special coding for re-positioning to second monitor if needed
// for now override the previous system process - we will try to force the window to open on the referred window.

if (fullscreen && gPreferedMonitor != 1 && gStoredMonitor == gPreferedMonitor)
{
// we first create a monitorinfo instance
MONITORINFOEX mi;
mi.cbSize = sizeof(mi);

// then get the details of the monitor we want to switch to
GetMonitorInfo(gPrefhMonitor, &mi);

// and then we override the normal window rectangle
rc = mi.rcMonitor;
}

...


// finally we change the x and y position to the location of the new window if fullscreen is set.
if ( fullscreen )
{
width = rc.right-rc.left;
height = rc.bottom-rc.top;
x = rc.left;
y = rc.top;

// the nett result is that windows will force the full screen window to open on the secondary monitor

Login to post a reply

Server time is: 2024-11-24 00:37:42
Your offset time is: 2024-11-24 00:37:42