Created
May 2, 2017 10:35
-
-
Save chaosddp/46e15576d32286e485916eb8a90686fe to your computer and use it in GitHub Desktop.
Call a win32 api to make the window size cannot be changed in Defold engine, as it using LuaJIT on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ffi = package.preload.ffi() | |
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; | |
HWND GetActiveWindow(); | |
LONG GetWindowLongPtrA(HWND hWnd, int nIndex); | |
LONG SetWindowLongPtrA(HWND hWnd, int nIndex, LONG_PTR dwNewLong); | |
]]) | |
local GWL_STYLE = -16 | |
-- styles from https://msdn.microsoft.com/en-us/library/windows/desktop/ms632600(v=vs.85).aspx | |
local WS_MAXIMIZEBOX = 0x00010000 | |
local WS_MINIMIZEBOX = 0x00020000 | |
local WS_SIZEBOX = 0x00040000 | |
-- load User32.dll | |
local user32 = ffi.load("User32") | |
local ptr = user32.GetActiveWindow() | |
local value = user32.GetWindowLongPtrA(ptr, GWL_STYLE) | |
user32.SetWindowLongPtrA(ptr, GWL_STYLE, bit.band(value, bit.bnot(WS_MAXIMIZEBOX), bit.bnot(WS_SIZEBOX))) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment