Home All Groups Group Topic Archive Search About
Author
11 Aug 2006 10:25 AM
Jaap Bos
In VB2005 I use a rectangle (50,50,910,600) into which to display my
graphics.
After graphing my X-Y data I want to do some measurements on that curve
using a crosshair cursor.

So I a made a MouseDoubleClick event with the following code:

Dim position as Point
position=Control.MousePostion
tijd=position.X
height=position.Y

Now it seems that the height is in screencoordinates, not in
graphicscoordinates, e.g. if I doubleclick on the topline of my rectangle I
get height=76 pixels, instead of 50 pixels (the difference of 26 pixels is
the height of the forms titelbar). This difference of course becomes larger
with a form that is not maximized.

Now I can live with that by always using a maximized screen and substracting
26 from the position.Y,  but that does not seems not very elegant.

Is there a better way to get the coordinates in a graphics window in
graphicscoordinates?


--
Groeten,


Jaap Bos

Author
11 Aug 2006 1:36 PM
Larry Lard
Jaap Bos wrote:
> Is there a better way to get the coordinates in a graphics window in
> graphicscoordinates?

Control.PointToClient and Control.PointToScreen will convert back and
forth for you.


--
Larry Lard
larryl***@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Author
11 Aug 2006 9:23 PM
Jaap Bos
"Larry Lard" <larryl***@googlemail.com>
> Jaap Bos wrote:
>> Is there a better way to get the coordinates in a graphics window in
>> graphicscoordinates?
>
> Control.PointToClient and Control.PointToScreen will convert back and
> forth for you.
>

Thank you Larry, you solved my problem!

As an afterthought, I find, as a newbie, that it is rather difficult to get
a grasp of the possibilities of using graphics in VB2005.
I read the Michael Halvorson Step by Step book and watched the Microsoft
online video's.
After this I have some knowledge about VB-programming, but I still know nil
about graphics, apart from drawing a line or a rectangle.
Befor I asked my question I looked into the Help-index of VB but really
could not find the answer that you gave me.
Can you point me to a (not to advanced :-) ) book or online material on
VB-graphics?

Thanks again,

Jaap
Author
14 Aug 2006 11:18 AM
Larry Lard
Jaap Bos wrote:
Show quoteHide quote
> "Larry Lard" <larryl***@googlemail.com>
>> Jaap Bos wrote:
>>> Is there a better way to get the coordinates in a graphics window in
>>> graphicscoordinates?
>> Control.PointToClient and Control.PointToScreen will convert back and
>> forth for you.
>>
>
> Thank you Larry, you solved my problem!
>
> As an afterthought, I find, as a newbie, that it is rather difficult to get
> a grasp of the possibilities of using graphics in VB2005.
> I read the Michael Halvorson Step by Step book and watched the Microsoft
> online video's.
> After this I have some knowledge about VB-programming, but I still know nil
> about graphics, apart from drawing a line or a rectangle.
> Befor I asked my question I looked into the Help-index of VB but really
> could not find the answer that you gave me.
> Can you point me to a (not to advanced :-) ) book or online material on
> VB-graphics?

Bob Powell's excellent website is my first port of call whenever I have
a graphics issue:

<http://www.bobpowell.net/>

--
Larry Lard
larryl***@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Author
14 Aug 2006 2:11 PM
Jaap Bos
"Larry Lard" <larryl***@googlemail.com> schreef
Jaap Bos wrote:
>> Can you point me to a (not to advanced :-) ) book or online material on
>> VB-graphics?
>
> Bob Powell's excellent website is my first port of call whenever I have a
> graphics issue:
>
> <http://www.bobpowell.net/>
>
> --
> Larry Lard

Thanks Larry. Looks like that this site will keep me occupied for a while
:-) .

Jaap Bos