Using PtInRect in VB.NET with little success

C

Carl Gilbert

Hi
I have the following code (in VB.NET) but I can not get this to return true.


Declare Function PtInRect Lib "user32" (ByRef lpRect As Rectangle, ByVal pt
As Point) As Integer
-----------------------------------------------------
Dim tmpPnt As New Point(50, 50)
Dim tmpRect As New Rectangle(40, 40, 20, 20)
If PtInRect(tmpRect, tmpPnt) Then
Debug.WriteLine("TRUE")
Else
Debug.WriteLine("FALSE")
End If


Could anyone suggest where I am going wrong?
Regards, Carl Gilbert
 
K

Ken Tucker [MVP]

Hi,

Use the rectangle classes contains method instead



Dim rCheck As New Rectangle(40, 40, 20, 20)

Dim pt As New Point(50, 50)

Trace.WriteLine(rCheck.Contains(pt))





Ken

----------------------------

Hi
I have the following code (in VB.NET) but I can not get this to return true.


Declare Function PtInRect Lib "user32" (ByRef lpRect As Rectangle, ByVal pt
As Point) As Integer
-----------------------------------------------------
Dim tmpPnt As New Point(50, 50)
Dim tmpRect As New Rectangle(40, 40, 20, 20)
If PtInRect(tmpRect, tmpPnt) Then
Debug.WriteLine("TRUE")
Else
Debug.WriteLine("FALSE")
End If


Could anyone suggest where I am going wrong?
Regards, Carl Gilbert
 
B

Bob Butler

Carl Gilbert said:
Hi
I have the following code (in VB.NET) but I can not get this to
return true.
Could anyone suggest where I am going wrong?

Apart from using VB.Net in the first place, no...


--
<response type="generic" language="VB.Net">
This newsgroup is for users of Visual Basic and whatever
VB.Net is, Visual Basic it isn't. Solutions appropriate to
one will be meaningless in the other and you are more likely
to get the answers you need in newsgroups that are
frequented by others using the dotnet platform rather than
here where the focus is on VB "classic" . Look for
newsgroups with the words "dotnet" or "vsnet" in their name.

For the msnews.microsoft.com news server, try these:

microsoft.public.dotnet.general
microsoft.public.dotnet.languages.vb

</response>
 
K

Ken Halter

Bob said:
Sorry, I did not notice the cross-post between the Visual Fred and VB groups

OE (thunderbird here) needs more powerful filters so we can just ignore
the .Net questions all together. It's obvious that people just don't
know (or care) that there's a difference, also obvious that MS likes it
that way... sad.
 
C

Cablewizard

heh, might have something to do with the fact that there are something like
2,500+ newsgroups available. just navigating the NG's requires some skill and
experience. very possible that newcomers are completely overwhelmed and pick the
first .vb they recognize. but FWIW to all ya VB Classic programmers, many of us
over here in VB.Net agree it should be named something different. the same
animal they are not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top