Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

SetClassLong

dannycat
New Contributor I
1,581 Views
Does anyone know a workround/alternative for SetClassLong function for x64. I get a warning message when compiling the 64-bit code. I tried SetClassLongPtr but it does not exist. I using it for setting cursor styles:

iret = SetClassLong(ghWndView,GCL_HCURSOR,LoadCursor(NULL,IDC_CROSS))

0 Kudos
8 Replies
Paul_Curtis
Valued Contributor I
1,581 Views
Quoting - dannycat
... for setting cursor styles:

iret = SetClassLong(ghWndView,GCL_HCURSOR,LoadCursor(NULL,IDC_CROSS))


Why not use SetCursor, sure looks simpler (I have no idea if this fails in x64):

rval = SetCursor (LoadCursor(NULL, IDC_ARROW))
0 Kudos
Steven_L_Intel1
Employee
1,581 Views
What kind of warning?
0 Kudos
dannycat
New Contributor I
1,581 Views

Hi Steve, Here is an example of the warning, this time for the background brush for the window. I get similar warnings for loading the cursor. I think the final argument in SetClassLong is 32-bit but in 64-bit OS functions like LoadCursor and GetStockObject will return a 64 bit value. I could cast the function using int(function,DWORD) but I don't think it will return the correct value always.

iret

= SelectObject(hBkDC,GetStockObject(DC_BRUSH))

icolref

= SetDCBrushColor(hBkDC,RGB(int1(255*gp%BkRGB(1)),int1(255*gp%BkRGB(2)),int1(255*gp%RGB(3))))

iret

= SetClassLong(ghWndView,GCL_HBRBACKGROUND,GetStockObject(DC_BRUSH))


C:WinFEM2000menuupdate.f90(716): warning #6075: The data type of the actual argument does not match the definition. [GETSTOCKOBJECT]

0 Kudos
Steven_L_Intel1
Employee
1,581 Views
You want to use SetClassLongPtr instead. Quoting MSDN: "Note This function has been superseded by the SetClassLongPtr function. To write code that is compatible with both 32-bit and 64-bit versions of Microsoft Windows, use SetClassLongPtr."
0 Kudos
dannycat
New Contributor I
1,581 Views
You want to use SetClassLongPtr instead. Quoting MSDN: "Note This function has been superseded by the SetClassLongPtr function. To write code that is compatible with both 32-bit and 64-bit versions of Microsoft Windows, use SetClassLongPtr."

Steve, I've already tried this (see initial post)but the function could not be resolved by the linker. Where is it defined?
0 Kudos
Steven_L_Intel1
Employee
1,581 Views
Oh, I see. It's not in module USER32 in 11.0. I think it is for 11.1. You can add your own definition as follows.

[plain]FUNCTION SetClassLongPtr_( &
        hWnd, &
        nIndex, &
        dwNewLong)
use ifwinty
  integer(ULONG_PTR) :: SetClassLongPtr_ 
    !DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'SetClassLongPtrA' :: SetClassLongPtr_
  integer(HANDLE) hWnd ! HWND hWnd
  integer(SINT) nIndex ! int nIndex
  integer(LONG_PTR) dwNewLong ! LONG dwNewLong
 END FUNCTION
END INTERFACE[/plain]
Note that I added an underscore at the end so as to not conflict with the real definition when it appears
0 Kudos
dannycat
New Contributor I
1,581 Views
Oh, I see. It's not in module USER32 in 11.0. I think it is for 11.1. You can add your own definition as follows.

[plain]FUNCTION SetClassLongPtr_( &
        hWnd, &
        nIndex, &
        dwNewLong)
use ifwinty
  integer(ULONG_PTR) :: SetClassLongPtr_ 
    !DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'SetClassLongPtrA' :: SetClassLongPtr_
  integer(HANDLE) hWnd ! HWND hWnd
  integer(SINT) nIndex ! int nIndex
  integer(LONG_PTR) dwNewLong ! LONG dwNewLong
 END FUNCTION
END INTERFACE[/plain]
Note that I added an underscore at the end so as to not conflict with the real definition when it appears

Thanks Steve, it builds and links ok now but I can't test it until Monday. When will 11.1 be released?
0 Kudos
Steven_L_Intel1
Employee
1,581 Views
Late June, last I heard.
0 Kudos
Reply