[SOLVED] OnMessage() & AutoHotkey.exe

Report problems with documented functionality
just me
Posts: 9550
Joined: 02 Oct 2013, 08:51
Location: Germany

[SOLVED] OnMessage() & AutoHotkey.exe

Post by just me » 23 Jan 2014, 09:41

The help file wrote:The Function's Parameters

Parameter #1: The message's WPARAM value, which is an integer between 0 and 4294967295.
Parameter #2: The message's LPARAM value, which is an integer between 0 and 4294967295.

Code: Select all

#NoEnv
WM_MOUSEWHEEL := 0x020A
Gui, Show, w00 h00, Test GUI
OnMessage(WM_MOUSEWHEEL, "On_WM_MouseWheel")
Return
GuiClose:
ExitApp
On_WM_MouseWheel(W, L, M, H) {
   ToolTip, % W
}]
The ToolTip in On_WM_MouseWheel() is showing:

78643220 or 4287102976 when running with AHK U32
78643220 or -78643220 when running with AHK U64

That's at least not 'as documented'.
Last edited by just me on 24 Jan 2014, 03:27, edited 1 time in total.

lexikos
Posts: 9678
Joined: 30 Sep 2013, 04:07
Contact:

Re: OnMessage() & AutoHotkey.exe

Post by lexikos » 23 Jan 2014, 17:15

The documentation is out of date. WPARAM and LPARAM are pointer types, so are 64-bit on 64-bit builds.

The number is signed because AutoHotkey does not support unsigned 64-bit integers.

just me
Posts: 9550
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: OnMessage() & AutoHotkey.exe

Post by just me » 24 Jan 2014, 00:58

Hi lexikos,

just for my understanding:

Code: Select all

#if defined(_WIN64)
 typedef unsigned __int64 UINT_PTR;
#else
 typedef unsigned int UINT_PTR;
#endif
Does this apply only to the size or also to the value range, i.e. may/will UINT_PTR actually contain values greater than (UINT) 4294967295 on 64-bit builds?

User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: OnMessage() & AutoHotkey.exe

Post by nnnik » 24 Jan 2014, 01:35

No it won't since it is not actually an unsigned int64.
Its an int64.
Recommends AHK Studio

just me
Posts: 9550
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: OnMessage() & AutoHotkey.exe

Post by just me » 24 Jan 2014, 01:43

Thanks, but it seems my that question wasn't clear enough. It is not related to AHK, it's related to C.

lexikos
Posts: 9678
Joined: 30 Sep 2013, 04:07
Contact:

Re: OnMessage() & AutoHotkey.exe

Post by lexikos » 24 Jan 2014, 02:22

Message parameter values are whatever the sender of the message specifies. So yes, they can contain values greater than 4294967295. That would be the purpose of defining them as UINT_PTR rather than UINT.

nnnik, int64 holds values far greater than UINT. Approximately 2**31 times greater, in fact.

just me
Posts: 9550
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: OnMessage() & AutoHotkey.exe

Post by just me » 24 Jan 2014, 02:31

TY for clarification. I assumed that UINT_PTR would be a pointer-sized type containing a value limited to the range of UINT as yet.

lexikos
Posts: 9678
Joined: 30 Sep 2013, 04:07
Contact:

Re: OnMessage() & AutoHotkey.exe

Post by lexikos » 24 Jan 2014, 03:11

If the value was limited to the range of UINT, there would be no point in defining it as UINT_PTR. Message parameters are often pointers, so must support the same range of values as other pointer types.

The documentation has been updated. Note the return value is also pointer-sized.

just me
Posts: 9550
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: OnMessage() & AutoHotkey.exe

Post by just me » 24 Jan 2014, 03:27

THX again.

Post Reply

Return to “Bug Reports”