Hello
I am using a control that uses subclassing to do its thing..
But unfortunately applications that use this control crash in windows server 2003 (if compiled, not in the IDE)

It turns out the problem occurs when using the SetWindowLong command to subclass.

Does anyone know how I can replace my project to use the new SetWindowLongPtr instead of SetWindowLong?

Here is the code in question
vb Code:
  1. Private Function Subclass_Subclass(ByVal hwnd As Long) As Boolean
  2. Const PATCH_02 As Long = 62                                'Address of the previous WndProc
  3. Const PATCH_05 As Long = 82                                'Control timer handle
  4. Const PATCH_07 As Long = 108                               'Address of the previous WndProc
  5.  
  6.   If hWndSub = 0 Then
  7.     Debug.Assert api_IsWindow(hwnd)                         'Invalid window handle
  8.     hWndSub = hwnd                                          'Store the window handle
  9.    
  10.     'Get the original window proc
  11.     nAddrOriginal = api_GetWindowLong(hwnd, GWL_WNDPROC)
  12.     Call Subclass_PatchVal(PATCH_02, nAddrOriginal)                  'Original WndProc address for CallWindowProc, call the original WndProc
  13.     Call Subclass_PatchVal(PATCH_07, nAddrOriginal)                  'Original WndProc address for SetWindowLong, unsubclass on IDE stop
  14.    
  15.     'Set our WndProc in place of the original
  16.     nAddrOriginal = api_SetWindowLong(hwnd, GWL_WNDPROC, nAddrSubclass)
  17.     If nAddrOriginal <> 0 Then
  18.       Subclass_Subclass = True                                       'Success
  19.     End If
  20.   End If
  21.  
  22.   If Subclass_InIDE Then
  23.     hTimer = api_SetTimer(0, 0, TIMER_TIMEOUT, nAddrSubclass)        'Create the control timer
  24.     Call Subclass_PatchVal(PATCH_05, hTimer)                         'Patch the control timer handle
  25.   End If
  26.  
  27.   Debug.Assert Subclass_Subclass
  28. End Function