-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MouseMove Event in SStab control causes crash #1835
Comments
When you create the procedure in VB6 does it have a ByVal? Edit: Just got home to check; the answer is no. This is a curious situation here. It's ByRef in VB6 and works. When it's ByVal in twinBASIC, it works. How is this? I check VarPtr(Button) in VB6 and it's not using that as both pointer and value. When it's ByRef in tB, it's crashing because VarPtr(Button) is 0. But in VB it's not 0 and points to the correct value. This makes no sense. The interface appears weird in OLEVIEW too; it's missing in/out attributes. My thinking is this is a VB6 bug; since it's missing the in/out parameter, it uses the default (if you omit ByVal and ByRef, ByRef is used), but because it's passed by the control ByVal, it winds up working out somehow. So if true then the question is... should tB replicate this bug? For a long time I would have thought yes, but since in other circumstances now no matter how reliable undefined/incorrect behavior is in VB6, it won't be supported in tB, only Wayne can say. In any case, the correct way to handle this is for It's VB6 that has the 'wrong' prototype here, even if it's somehow working out right behind the scenes. Edit2: Confirmed |
Looks like none of the mouse events in VB6 (for Form as well as SStab) specify Byval/byref. tB is going to be a better language than VB, and although VB was intended to be friendly to total beginners I don't think this applies to tB, the world has moved on, even schoolkids have to work in C type langauges 😃 |
So Eduardo- on VBF helped me figure out what's going on here. VB6 has a signature override for specific dispids. If it encounters a method with a specific dispid, here for MouseMove 0xfffffda2, it takes the ByVal parameter, and turns it into ByRef. It's an open question as to WHY? Proof of concept: -Create new ActiveX control in tB, registered to local machine so VB6 sees it. -Code;
-Compile. Open in OLEVIEW. The dispinterface tB generates correctly reflects the ByVal,
-New VB6 project, add control, add to form: VB6 creates a ByRef prototype, and it works, not crashing but instead producing the expected values:
WHY is the big question here. Why not pass through the ByVal like normal? I haven't tested modifying the signature from the expected, what's going to happen then, how specific is this override mechanism? To replicate, tB is going to have to reinterpret not just this dispid, but all the others too... at a minimum:
|
Another question is why tB is not raising a signature mismatch error but instead letting it crash. |
I suspect that ByVal and ByRef are probably the first bit of "unwelcome computer science" that non-programmers encounter when using VB. |
I confess that I am not fully understanding this stuff (but then I do try to be a high level language programmer which is why I like VB) If I create a Form in tB (without a Tab Control) then ByVal/Ref is again not specified in Form_Mousemove. |
Form_MouseMove is a bit different than an external control; tB didn't have to comply with any besides VB6, so the original event definition is ByRef. And
I think there though it's got an actual reason; convert to twips or whatever? I was trying to dig around the IDL def for VB.Form but couldn't find one. I suspect if it did exist it would be ByVal. |
It is actually
|
Ah, first place I looked but I missed it. But yeah... ByRef by nature, not associated with the dispid 0xfffffda2, so no compatibility issues there or behind the scenes reinterpreting going on in VB. |
For mousemove on a form I can optionally specify ByRef in the Form_mousemove (etc) definitions, |
Yes There's only a difference when |
It looks like you have done some work on this but its still not right. |
No, I haven't yet touched anything specific in this regard. |
How odd, stuff that was compiling fine but giving errors at run time is now giving the 5018 error. |
I don't keep or even install every new release, they do come thick and fast, but something has changed somewhere between 515 and 529. |
I'm still not getting an in 529. Are you still looking at SSTab_MouseMove? Remember not all controls used the specific dispid that triggers the issue. |
I am seeing a 5018 error on a Toolbar.mousedown where the toolbar is directly on the Form with no SStab involved. Most errors do relate to SStabs, and controls on tabs, but this is because I use SStab extensively. |
Just put a toolbar on a form, that will get the 5018 error in tB529. I did this in VB6 and imported it to tB, did not try doing it directly in tB, but importing VB projects/testing compatability is my priority. |
OK, if I create the form in tB there is no error because the mousedown definition includes byval, and y as ...Pixels. Private Sub Toolbar1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As stdole.OLE_YPOS_PIXELS) I assume that this is wrong as y should be single to be VB compatible??? |
Yes that's the bug here. Looking at the ocx, the IToolbarEvents dispinterface has one of those odd dispids (id(0xfffffda3)) for MouseDown that VB must be seeing and rewriting behind the scenes. This issue will occur with any control using these dispids for their standard events. tB is technically correct in that it's not rewriting the original:
But since VB is rewriting it, tB will need to do the same for compatibility. VB knows the real definition, which is why it works, it's doing the neccessary conversion. But if you use VB's definition, tB doesn't know to rewrite it yet, so no conversion is done and boom. What's VB doing with the arguments? Is it converting pixels to twips? Or to current scale mode? tB will have to replicate that too. One thing we could do to help Wayne with this is gather a list of dispid/event definitions for all the events that need to be rewritten. Compare the VB definition to the typelib definition (by opening the ocx with OLEView's 'View typelib' option). |
Describe the bug
The MouseMove event in an SStab control will give a crash when referencing any of the passed parameters.
To Reproduce
Put a SStab control on a Form
Private Sub SSTab1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error GoTo e
If Button = 0 Then ' ......this fails
End If
Exit Sub
e:
Debug.Print Err.Description
End Sub
The reference to "button" will give a run time access violation error.
The error trap does NOT catch this.
win11 tB 515
Note
Crashes in VB6 often result in everything just disappearing.
tB is pretty good at surviving and giving a message in the Debug Console, thankyou.
MouseMoveTab.zip
The text was updated successfully, but these errors were encountered: