Hi Charles,
it seems that using Get/SetWindowLong and Get/SetWindowLongPtr is a little bit tricky. I learned these functions are used to set and get e.g. certain window styles (GWL_STYLE, GWL_EXSTYLE), for subclassing (GWL_WNDPOC), or as a pointer to data with a given window (GWL_USERDATA). The GWLP_ parameters seem to have the same values.
Set/GetWindowLongPtr can only be used for 64-bit compiling, using these functions for 32-bit will fail. Since some time I have been looking for a simple solution which covers this case. In examples\WinGui\ChildWin.o2bas I tried this:
...
! GetWindowLongPtr lib "user32.dll" alias "GetWindowLongPtrA" (sys hWnd, sys nIndex) as sys
'% Win_64
'-------------------------------------------------------------
function EnumChildProc(sys hwndChild, lParam) as bool callback
'=============================================================
{
RECT * rcParent;
sys i, idChild;
sys v,w,info
// Retrieve the child-window identifier. Use it to set the
// position of the child window.
info=GWL_ID
#ifdef Win_64
idChild = GetWindowLongPtr(hwndChild, info)
#else
idChild = GetWindowLong(hwndChild, info)
#endif
...
I also tried this way:
...
! GetWindowLongPtrA lib "user32.dll" alias "GetWindowLongPtrA" (sys hWnd, sys nIndex) as sys
'% Win_64
function GetWindowLongPtr(sys h, sys i) as sys
#ifdef Win_64
return GetWindowLongPtrA(h,i)
#else
return GetWindowLong(h,i)
#endif
end function
'-------------------------------------------------------------
function EnumChildProc(sys hwndChild, lParam) as bool callback
'=============================================================
{
RECT * rcParent;
sys i, idChild;
sys v,w,info
// Retrieve the child-window identifier. Use it to set the
// position of the child window.
info=GWL_ID
idChild = GetWindowLongPtr(hwndChild, info)
...
Both of my solutions are not really satisfying. The first one needs a workaround for every Get/SetWindowLong/Ptr. In the second case I need to define Win_64 before the function GetWindowLongPtr. Defining Win_64 after the function does not work. Perhaps with the new macro system there is a better way? Two other examples which use GetWindowLong / SetWindowlong are \tools\FindEd.o2bas and \examples\WinDynDialogs\FullScreen.o2bas.
I suspect for really 64-bit compliant compiling Get/SetWindowLongPtr should be considered. And perhaps these functions should also be added to minwin.inc
Roland