Results 1 to 4 of 4

Thread: SetWindowLong vs SetWindowLongPtr.. Are they interchangeable?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2003
    Posts
    1,269

    SetWindowLong vs SetWindowLongPtr.. Are they interchangeable?

    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

  2. #2

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2003
    Posts
    1,269

    Re: SetWindowLong vs SetWindowLongPtr.. Are they interchangeable?

    I am editing the SocketMaster (winsock control replacement) control because it does not work on windows server 2003 due to the way it subclasses the control..

    in the code above, the application crashes at the line nAddrOriginal = api_SetWindowLong(hwnd, GWL_WNDPROC, nAddrSubclass) and I was wonder how I can replace that SetWindowLong api with the newer, SetWindowLongPtr API

    http://msdn2.microsoft.com/en-us/library/ms633591.aspx
    http://msdn2.microsoft.com/en-us/library/ms644898.aspx

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: SetWindowLong vs SetWindowLongPtr.. Are they interchangeable?

    Unless you explain the point in changing windows style while working with winsock I'm afraid you might not get any help.
    I personally have no clue why do even need to do all of what you posted.

    Sorry.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width