xer_soft
asked on
bad DLL calling convention or something like that...
I do this
If PtInRect(InterData(i).Inte r_HotBox, thepoint) > 0 Then
InterData(i).Inter_HotBox is a RECT and thepoint is a pointapi
and I get a bad dll calling convention.. Why
Heres my declares
Type POINTAPI
x As Long
y As Long
End Type
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Declare Function PtInRect Lib "user32" (lpRect As RECT, pt As POINTAPI) As Long
If PtInRect(InterData(i).Inte
InterData(i).Inter_HotBox is a RECT and thepoint is a pointapi
and I get a bad dll calling convention.. Why
Heres my declares
Type POINTAPI
x As Long
y As Long
End Type
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Declare Function PtInRect Lib "user32" (lpRect As RECT, pt As POINTAPI) As Long
First, replace "> 0" with "<> 0"
"The return value is nonzero if the point lies within the given rectangle. Otherwise, it is zero."
Then, post code to get rectangle and thepoint.
"The return value is nonzero if the point lies within the given rectangle. Otherwise, it is zero."
Then, post code to get rectangle and thepoint.
Or maybe not...
rwilson changed the proposed answer to a comment
Just noticed, I use myPtInRect
Public Function myPtInRect(lpRect As RECT, pt As POINTAPI) As Long
' replacement for PtInRect api, which gives Bad DLL convention. Wrong declaration?
Dim tmp As Long
tmp = 0
If pt.X >= lpRect.Left Then
If pt.X <= lpRect.Right Then
If pt.Y >= lpRect.Top Then
If pt.Y <= lpRect.Bottom Then
tmp = 1
End If
End If
End If
End If
myPtInRect = tmp
End Function
Public Function myPtInRect(lpRect As RECT, pt As POINTAPI) As Long
' replacement for PtInRect api, which gives Bad DLL convention. Wrong declaration?
Dim tmp As Long
tmp = 0
If pt.X >= lpRect.Left Then
If pt.X <= lpRect.Right Then
If pt.Y >= lpRect.Top Then
If pt.Y <= lpRect.Bottom Then
tmp = 1
End If
End If
End If
End If
myPtInRect = tmp
End Function
That was old version, this is new
Public Function myPtInRect(lpRect As RECT, pt As POINTAPI) As Long
' replacement for PtInRect api, which gives Bad DLL convention.
If pt.X >= lpRect.Left Then
If pt.X <= lpRect.Right Then
If pt.Y >= lpRect.Top Then
If pt.Y <= lpRect.Bottom Then
myPtInRect = 1
End If
End If
End If
End If
End Function
Public Function myPtInRect(lpRect As RECT, pt As POINTAPI) As Long
' replacement for PtInRect api, which gives Bad DLL convention.
If pt.X >= lpRect.Left Then
If pt.X <= lpRect.Right Then
If pt.Y >= lpRect.Top Then
If pt.Y <= lpRect.Bottom Then
myPtInRect = 1
End If
End If
End If
End If
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I didn't test it, but I trust Erick37
Part one of the problem is passing the variables to Windows. Windows is expecting the two longs in the POINTAPI structure to be Longs passed by value. User Defined Types are always passed by reference. Declare the function like this:
Declare Function PtInRect Lib "user32.dll" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
Also, I think I have a problem with the following
If PtInRect(interdata(i).Inte
Perhaps you left something out but the array looks like a user defined type where one element of the User defined type is a user defined type of RECT.
Clear?
Is that right?
If it’s just an array of UDT’s then
Dim interdata(1 To 10) As RECT
Then assign values to each RECT in the array:
interdata(1).Bottom = 100
interdata(1).Left = 1
interdata(1).Right = 200
interdata(1).Top = 1
etc.
Dim y as long, z as long
Then call the function:
If PtInRect(interdata(1), y, z) > 0 Then …
If Inter_HotBox is a RECT within a user definded type like:
Type interdataX
Something as long
Otherthing as string
Inter_HotBox as RECT
End Type
Dim interdata(1 to 10) as interdataX
That’s fine. That should work. Okay dokay.
RobMWilliams
Ameba and myself have already commented on the issues you have proposed as an answer.
Ameba and myself have already commented on the issues you have proposed as an answer.
Okay, thanks, sorry about that.
I’m new to this forum and I didn’t realize this point system.
I see that “comments” is information, and “answers” is some contest thing for points.
I don’t want to seem cynical but what’s the point with the points? Is there a car or something at the end?
I’ve already had a perfectly fine answer “rejected” quite soundly. I don’t see how someone who doesn’t understand what they’re talking about (that’s why they’re asking) can reject the answer to their problem (because they don’t understand what they’re talking about)
If there IS as car at the end, I’m interested, otherwise, why should anyone bother?
I’m new to this forum and I didn’t realize this point system.
I see that “comments” is information, and “answers” is some contest thing for points.
I don’t want to seem cynical but what’s the point with the points? Is there a car or something at the end?
I’ve already had a perfectly fine answer “rejected” quite soundly. I don’t see how someone who doesn’t understand what they’re talking about (that’s why they’re asking) can reject the answer to their problem (because they don’t understand what they’re talking about)
If there IS as car at the end, I’m interested, otherwise, why should anyone bother?
No, there is no car.
To understand, maybe you can read JimMorgan's profile, he is number 67 on https://www.experts-exchange.com/bin/Top100
But I think this might not be for you (helping others, exchanging knowledge).
To understand, maybe you can read JimMorgan's profile, he is number 67 on https://www.experts-exchange.com/bin/Top100
But I think this might not be for you (helping others, exchanging knowledge).
> But I think this might not be for you (helping others, exchanging knowledge).
Ouch!
This place IS tough.
Ouch!
This place IS tough.
This is how I see it. I usually post a comment if others have already commented on a question, especially if the questioner has not replied yet.
If I am certain I have a solution to a particular question (and no other comments have addressed the point) I will post as answer.
Also, if you get a certain number of points, there is a free tee shirt waiting for you.
If I am certain I have a solution to a particular question (and no other comments have addressed the point) I will post as answer.
Also, if you get a certain number of points, there is a free tee shirt waiting for you.
ASKER
This seems to not be a hard problem... I see that the API text viewer gives the wrong declare! At least mine does... The lower one is the one my viewer gives me it uses a pointapi. The one every one sujested i use does not use this type. Thanks to every one who helped. I'll give the points to the first person who used the right code. But for now on I am only giveing my points to the first correct Answer not comment. I always feel bad when making theese decisions but no more. Only the correct Answer not a comment. -For any one who cares.
Futher: does any one else have the problem with the API viewer?
Private Declare Function PtInRect Lib "user32" (lpRect As RECT, ByVal ptx As Long, ByVal pty As Long) As Long
Private Declare Function PtInRect Lib "user32" (lpRect As RECT, pt As POINTAPI) As Long
Futher: does any one else have the problem with the API viewer?
Private Declare Function PtInRect Lib "user32" (lpRect As RECT, ByVal ptx As Long, ByVal pty As Long) As Long
Private Declare Function PtInRect Lib "user32" (lpRect As RECT, pt As POINTAPI) As Long
ASKER
Looks like this is the first post that uses the correct API declare. (Why did EE every make it so comments could be used as answers...) Sorry if I made any one mad...
Public Declare Function PtInRect Lib "user32" stdcall (lpRect As RECT, pt As POINTAPI) As Long
(I think) Look in the help for exact syntax for calling convention on functions if this doesn't quite fly!
Cheers,
Raymond.