How to launch a game with maximized window

#1

Is there an option to launch the built game with a maximized window?
something like the ‘fullscreen’ option to set a maximized window by default

Thanks :slight_smile:

1 Like

#2

Which OS? We can add that to DefOS

0 Likes

#3

Defold have a fullscreen option in project settings

0 Likes

#4

On Windows, the behavior between pressing the Maximize button and going fullscreen mode is different.

1 Like

#5

It’s windows 8

0 Likes

#6

Thanks AGulev
I tried that but what I want is to just maximize window. The fullscreen option is covering the whole screen, including the frame of the window (buttons to close minimize, maximize). I want the buttons to be accesible. When I select the fullscreen in the project settings, the mouse cursor is not visible either.

0 Likes

#7

ou, yes. My fault.
Then @pkeod is right, you can use DefOS

0 Likes

#8

I’ll test adding it to defos soon.

@AGulev similar Maximize behavior on macOS is holding down option key + shift and then pressing green button. That will maximize to full height and width without overlapping dock or topbar. We can probably get this to work in defos when same method is called for macOS version.

2 Likes

#9

Here is a (imperfect) solution to use until a proper one can be added to defos with other handy features.

maximize_window.lua (615 Bytes)

local M = {}

local ffi = package.preload.ffi()


function M.maximize_window()
	if(ffi.os == "Windows") then

	  -- definitions
	  ffi.cdef([[
			typedef unsigned int LONG;
			typedef long long LONG_PTR;
			typedef void* PVOID;
			typedef PVOID HANDLE;
			typedef HANDLE HWND;
			typedef unsigned int UINT;
			typedef bool BOOL;

			HWND GetActiveWindow();
			BOOL ShowWindow(HWND hWnd, int nCmdShow);
			
		]])

		-- load User32.dll
		local user32 = ffi.load("User32")

		local SW_SHOWMAXIMIZED = 3
		
		
		local ptr = user32.GetActiveWindow()
		
		user32.ShowWindow(ptr, SW_SHOWMAXIMIZED)
		
	end	
end	

return M

Put this file somewhere. You could put it into a utils folder can name it maximize_window

Then in another file such as your main script you would do for example

local maximize_window = require("utils.maximize_window")

function init(self)
	maximize_window.maximize_window()
end
3 Likes

#10

Thanks a lot. i was trying to modify the defOS but I think its a lot for me now xD
this is working. will wait for the new defOS function :smiley:

2 Likes

#11

Defos was updated with new methods for maximize window:

4 Likes