window_handle() should be a pointer instead of a double (to emulate GMS behavior) [u524]

Reporter: time-killer-games  |  Status: closed  |  Last Modified: October 01, 2017, 11:46:57 AM

Prior to GMStudio, window_handle() returned a double. But ever since GMStudio was released, it now returns a pointer. It works the same in GMStudio 1 and 2. Basically, if you have a DLL that uses window_handle() for one of its arguments the type used is ty_string. Therefore, ty_string can be used for either a "char *" type OR an "HWND" type on Windows, or the "Window" type on Linux. I'm not sure what the Mac equivalent is for HWND/Window but anyway you get the point.

HWND is in reality a pointer:

A handle to a window.

This type is declared in WinDef.h as follows:

typedef HANDLE HWND;

A handle to an object.

This type is declared in WinNT.h as follows:


A pointer to any type.

This type is declared in WinNT.h as follows:

typedef void *PVOID;

HWND is a HANDLE, which is a PVOID, which is a void*

But regardless, if we changed window_handle to return HWND instead of unsigned long long without casting then it would break a lot of support for older GameMaker extensions, which we honestly never really supported that well anyway. YoYoGames may have changed this intentionally for GMS. Perhaps we could keep both and call one window_handle_legacy but I am not sure.

@JoshDreamland you have any thoughts on what you want to do about window_handle?

It does say right in the manual now that it's a pointer:
And again, it used to be double:


Note also that this is somewhat related to issue #820 that you reported before when we actually had two windows instead of one. I think polygonz was responsible for us having two windows before, one for the client, and one for the border area.

I think my personal preference here is to switch to the GMS way. It is more correct to just return an HWND from that function without casting. But I wish we could leave something for old legacy extensions too though.


@RobertBColton You could just have window_handle return different things depending on the compliance mode

Oh that's great, I forgot sorlok added that compliance mode. I'm going to be busy for a few days with school work, probably until Monday now. I'll get to this shortly then!

Closing as resolved by #1082
Please sign in to post comments, or you can view this issue on GitHub.