VB Studio closes by itself!
:mad:
If I exit my program VB Studio shuts down now. It will dfo this everytime Once I chose to close my application I developed. It never used to do that. If I run an older program and close it it works fine. Then I reopen my current application again and run things it is fine...until I try to debug anything it starts doing it again. Anybody seen that before?
Re: VB Studio closes by itself!
Sounds like a sub-classing issue. That happens if you close the app without running thru the exit code of your app, which releases the hook.
Re: VB Studio closes by itself!
Yeah I have been removing my error handling so I can get right to the issue with any code right now. I have been doing that for years though.
Re: VB Studio closes by itself!
Post your project, or the sub-classing parts that hook and un-hook, and we'll see if there is anything that can be fixed. Does the IDE crash if you close the app correctly (rather than clicking on the X to close a form?)
Re: VB Studio closes by itself!
Here is some of the Code that uses subclassing to allow the Mouse Wheel to work in my grids.
Code:
Private Sub Form_Activate()
FIRST_CLICK = True
Call WheelHook(frmMDIChild_Service_Area_Detail)
End Sub
Private Sub Form_Deactivate()
Call WheelUnHook
End Sub
Public Sub WheelHook(PassedForm As Form)
On Error Resume Next
Set myForm = PassedForm
LocalHwnd = PassedForm.hwnd
LocalPrevWndProc = SetWindowLong(LocalHwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Public Sub WheelUnHook()
Dim WorkFlag As Long
On Error Resume Next
WorkFlag = SetWindowLong(LocalHwnd, GWL_WNDPROC, LocalPrevWndProc)
Set myForm = Nothing
End Sub
Re: VB Studio closes by itself!
Take the error trap out of the unload, and place a breakpoint, to see if it's getting called. You may also want to put some code in the query unload of your form.
Re: VB Studio closes by itself!
You think I should have the UnHook function call in my Form_Unload Event instead?
Re: VB Studio closes by itself!
I get an error "Object doesnt support this property or method" at this line:
myForm.MouseWheel MouseKeys, Rotation, Xpos, Ypos
Code:
Private Function WindowProc(ByVal Lwnd As Long, ByVal Lmsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim MouseKeys As Long
Dim Rotation As Long
Dim Xpos As Long
Dim Ypos As Long
If Lmsg = WM_MOUSEWHEEL Then
MouseKeys = wParam And 65535
Rotation = wParam / 65536
Xpos = lParam And 65535
Ypos = lParam / 65536
myForm.MouseWheel MouseKeys, Rotation, Xpos, Ypos
End If
WindowProc = CallWindowProc(LocalPrevWndProc, Lwnd, Lmsg, wParam, lParam)
End Function