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:
Private Function Subclass_Subclass(ByVal hwnd As Long) As Boolean
Const PATCH_02 As Long = 62 'Address of the previous WndProc
Const PATCH_05 As Long = 82 'Control timer handle
Const PATCH_07 As Long = 108 'Address of the previous WndProc
If hWndSub = 0 Then
Debug.Assert api_IsWindow(hwnd) 'Invalid window handle
hWndSub = hwnd 'Store the window handle
'Get the original window proc
nAddrOriginal = api_GetWindowLong(hwnd, GWL_WNDPROC)
Call Subclass_PatchVal(PATCH_02, nAddrOriginal) 'Original WndProc address for CallWindowProc, call the original WndProc
Call Subclass_PatchVal(PATCH_07, nAddrOriginal) 'Original WndProc address for SetWindowLong, unsubclass on IDE stop
'Set our WndProc in place of the original
nAddrOriginal = api_SetWindowLong(hwnd, GWL_WNDPROC, nAddrSubclass)
If nAddrOriginal <> 0 Then
Subclass_Subclass = True 'Success
End If
End If
If Subclass_InIDE Then
hTimer = api_SetTimer(0, 0, TIMER_TIMEOUT, nAddrSubclass) 'Create the control timer
Call Subclass_PatchVal(PATCH_05, hTimer) 'Patch the control timer handle
End If
Debug.Assert Subclass_Subclass
End Function
Re: SetWindowLong vs SetWindowLongPtr.. Are they interchangeable?
I don't see where you are subclassing... :confused:
And what exactly are you trying to do? And why are you changing functions names?
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
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. :confused:
Sorry.