I am converting a FF31/PB9 program to FF35/PB10 and have run into a local
variable the is defined as PointApi that is causing a problem. Here's the code:
Function FORMDGMSG_LIST1_CUSTOM ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
wMsg As Long, _ ' type of message
wParam As Dword, _ ' first message parameter
lParam As Long _ ' second message parameter
) As Long
Local rc As Rect
Local t As Long
Local itd As Long
Local pt As PointApi
Select Case wMsg
Case %WM_KEYDOWN
If wParam = %VK_SPACE Then 'Respond to space bar
t = SendMessage(hWndControl, %LB_GETCURSEL, 0, 0) 'get selected
itd = Not SendMessage(hWndControl, %LB_GETITEMDATA, t, 0) 'get toggled item data
Call SendMessage(hWndControl, %LB_SETITEMDATA, t, itd) 'set toggleded item data
Call SendMessage(hWndControl, %LB_GETITEMRECT, t, VarPtr(rc)) 'get sel. item's rect
InvalidateRect hWndControl, rc, 0 : UpdateWindow hWndControl 'update sel. item only
Function = 0 : Exit Function 'return zero
End If
Case %WM_LBUTTONDOWN
If wParam = %MK_LBUTTON Then 'respond to mouse click
pt.x = LoWrd(lParam) : pt.y = HiWrd(lParam) 'get cursor pos
t = SendMessage(hWndControl, %LB_ITEMFROMPOINT, 0, MakLng(pt.x, pt.y)) 'get sel. item
SendMessage hWndControl, %LB_GETITEMRECT, t, VarPtr(rc) 'get sel. item's rect
rc.nLeft = 2 : rc.nRight = 15 'checkbox cordinates
If PtInRect(rc, pt.x, pt.y) Then 'if in checkbox
itd = Not SendMessage(hWndControl, %LB_GETITEMDATA, t, 0) 'get toggled item data
SendMessage hWndControl, %LB_SETITEMDATA, t, itd 'set toggled item data
InvalidateRect hWndControl, rc, 0 : UpdateWindow hWndControl 'update sel. item only
End If
End If
End Select
End Function
This is the statement causing the problem: PtInRect(rc, pt.x, pt.y)
attached is error message.
Hi Marty,
strange error description indeed.
What I can see is that your code has the parameters for the PtInRect function wrong. You have 3 params where 2 are required. Both need to be structures. (See text from the Win32 helpfile below.)
Try this instead:
If PtInRect(rc, pt) Then
Quote from Win32 helpfile:
The PtInRect function determines whether the specified point lies within the specified rectangle. A point is within a rectangle if it lies on the left or top side or is within all four sides. A point on the right or bottom side is considered outside the rectangle.
BOOL PtInRect(
CONST RECT *lprc, // address of structure with rectangle
POINT pt // structure with point
);
Parameters
lprc
Points to a RECT structure that contains the specified rectangle.
pt
Specifies a POINT structure that contains the specified point.
Rolf is right, that is how it is described in the WinAPI help and at MSDN. It is correct for the way PB defined it in the PB9 include files however. If you look at WinUser.inc in Jose Roca's includes, you will find it is defined as having two parameters as Rolf stated. You could probably call it like so: PtInRect(rc, pt). But if you look at this excerpt from Winuser.inc (mentioned above) you can see the next function declaration below PtInRect is PtInRectXY:DECLARE FUNCTION PtInRect IMPORT "USER32.DLL" ALIAS "PtInRect" ( _
BYREF lprc AS RECT _ ' __in CONST RECT *lprc
, BYVAL pt AS POINT _ ' __in POINT pt
) AS LONG ' BOOL
' Same as above, but using x, y coordinates
DECLARE FUNCTION PtInRectXY IMPORT "USER32.DLL" ALIAS "PtInRect" ( _
BYREF lprc AS RECT _ ' __in CONST RECT *lprc
, BYVAL x AS LONG _ ' __in x
, BYVAL y AS LONG _ ' __in y
) AS LONG ' BOOL
Meaning you could just change your call to: PtInRectXY(rc, pt.x, pt.y)
Don't be afraid to just check Jose's includes to see what the correct parameters are. He has done a great deal of work getting them to match the MicroSoft documentation.
David
Thanks for the hint, David. Good one. Nice wrapper of Josè (like so many he has created).
In case of using the wrapper I would suggest to define x, y vars as long and leave the pt structure out and use:
PtInRectXY(rc, x, y)
Rolf
Rolf and David,
Thanks for the help. Some of this stuff is just
above my level of knowledge.
David changing the function call was what was needed.
That worked !
That was the last correction I had to make to convert a rather
large FF31/PB90 programs to FF35/PB10. The program now
compiles with out any errors. What a relief !
2,082,480 bytes of compiled code.
Tomorrow I need to do some testing to make sure I don't
have any run-time problems. But I am feeling good about it.
You're up late, Marty. Full moon bothering you?
Rolf