Jump to content

How to adjust game window position


Go to solution Solved by m2Ciaran,

Recommended Posts

  • Active Member

I've seen some clients doing this but I don't have their source plus I'm sure a lot of new devs like me would like an answer to that.

Most clients start in a specific position (0, 0), therefore when a second instance of the client starts, it goes right on top of the first one and you need to move it (if running on small dimensions such as 800x600) in order to see both of them.

There are some clients though that start the second instance in the other side of the screen and that's convenient on small dimension settings.

I know that there is a block of code that can set the position of the client in EterLib/MSWindow.cpp:

bool CMSWindow::Create(const char* c_szName, int brush, DWORD cs, DWORD ws, HICON hIcon, int iCursorResource)
{
	//assert(ms_hInstance != NULL);
	Destroy();
		
	const char* c_szClassName = RegisterWindowClass(cs, brush, MSWindowProcedure, hIcon, iCursorResource);

	m_hWnd = CreateWindow(
						c_szClassName,
						c_szName,
						ws, 
						0, 0, 0, 0, // <==== Here we can set the first 2 numbers as the position of the window (x, y, width, height)
						NULL,
						NULL, 
						ms_hInstance,
						NULL);

but how is it possible to know if there are other client instances open so we can round around this for example?

  1. 0, 0
  2. End of screen width - window width, 0
  3. 0, End of screen height - window height
  4. End of screen width - window width, End of screen height - window height
  5. 0, 0
  6. ...

Thanks in advance

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Active Member
37 minutes ago, m2Ciaran said:

Look for bAnotherWindow in pythonapplication

Thanks! If anyone else needs this here is a working bool CPythonApplication::Create in UserInterface/PythonApplication.cpp:

Find:

else
{
	AdjustSize(m_pySystem.GetWidth(), m_pySystem.GetHeight());

	if (Windowed)
	{
		m_isWindowed = true;
      ...
    }
  ...
}

Adjust like this:

else
{
	AdjustSize(m_pySystem.GetWidth(), m_pySystem.GetHeight());

	if (Windowed)
	{
		m_isWindowed = true;

		if (bAnotherWindow)
		{
			RECT rc;

			GetClientRect(&rc);

			int windowWidth = rc.right - rc.left;
			int windowHeight = (rc.bottom - rc.top);

			CMSApplication::SetPosition(GetScreenWidth() - 8 - windowWidth, GetScreenHeight() - 78 - windowHeight);
		}
		else
		{
			SetPosition(-8, 0);
		}
	}
	else
	{
		m_isWindowed = false;
		SetPosition(0, 0);
	}
}

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.