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


Reply With Quote
