drawing in picture boxes

drawing in picture boxes

Post by Brent Pertee » Fri, 05 Nov 1999 04:00:00



Here's what i wanna do:   i have a picture box and am loading an image into
it (a map), i can draw stuff on top of it with no problem, but what i want
to do is be able to draw another image on top of it and be able to move it
to another location and erase where it was last and restore the screen.  By
XOR-ing it with the background i can do this, however the consequence is
that the colors change when doing it on a multicolor background, like a
photo.  Basically, I want to be able to do what the mouse cursor does in
windows...does that makes sense? :)

i know i need to use WinAPI routines to do this but i'm not quite sure how
to go about it (it's gotta be a common thing though)

thanks in advance,

Brent Perteet

 
 
 

drawing in picture boxes

Post by Gustavo A Monteir » Sat, 06 Nov 1999 04:00:00


Hey brent:

Why don't you try using an auxiliary control, like shape or line,to mark
the coordinates in which you wanna draw. Let me make myself clear :

Dim X1
Dim Y1

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    Shape1.Visible = True
    X1 = X
    Y1 = Y
    Shape1.Top = Y
    Shape1.Left = X
    Shape1.Height = 0
    Shape1.Width = 0
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    If Shape1.Visible = True Then
        If X > X1 Then
            Shape1.Left = X1
            Shape1.Width = X - X1
        End If
        If X < X1 Then
            Shape1.Left = X
            Shape1.Width = X1 - X
        End If
        If Y > Y1 Then
            Shape1.Top = Y1
            Shape1.Height = Y - Y1
        End If
        If Y < Y1 Then
            Shape1.Top = Y
            Shape1.Height = Y1 - Y
        End If
    End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    x2 = X
    y2 = Y
    Shape1.Visible = False
    Picture1.Line(x1,y1)-(x2,y2),0,B 'Will draw a box
End Sub

Gustavo Monteiro
Salvador, Brazil

Brent Perteet escreveu na mensagem ...

>Here's what i wanna do:   i have a picture box and am loading an image into
>it (a map), i can draw stuff on top of it with no problem, but what i want
>to do is be able to draw another image on top of it and be able to move it
>to another location and erase where it was last and restore the screen.  By
>XOR-ing it with the background i can do this, however the consequence is
>that the colors change when doing it on a multicolor background, like a
>photo.  Basically, I want to be able to do what the mouse cursor does in
>windows...does that makes sense? :)

>i know i need to use WinAPI routines to do this but i'm not quite sure how
>to go about it (it's gotta be a common thing though)

>thanks in advance,

>Brent Perteet



 
 
 

drawing in picture boxes

Post by Brent Pertee » Sat, 06 Nov 1999 04:00:00


Thanks for the reply!  however, that's not exactly what i meant (sorry)
here's my app:  i have a map in a picture box, and i'm reading in
coordinates thru the serial port (from GPS).  When i get "ID1  coordinate
x,y" from the serial port i want to draw a filled box with a number on the
map where that coordinate would appear, then when i get another coordinate,
erase the last position and draw the new one...it would all be done
automatically rather than with the mouse.  does that clarify it? :)

Thanks again,

Brent Perteet



> Hey brent:

> Why don't you try using an auxiliary control, like shape or line,to mark
> the coordinates in which you wanna draw. Let me make myself clear :

> Dim X1
> Dim Y1

> Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As
> Single, Y As Single)
>     Shape1.Visible = True
>     X1 = X
>     Y1 = Y
>     Shape1.Top = Y
>     Shape1.Left = X
>     Shape1.Height = 0
>     Shape1.Width = 0
> End Sub

> Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As
> Single, Y As Single)
>     If Shape1.Visible = True Then
>         If X > X1 Then
>             Shape1.Left = X1
>             Shape1.Width = X - X1
>         End If
>         If X < X1 Then
>             Shape1.Left = X
>             Shape1.Width = X1 - X
>         End If
>         If Y > Y1 Then
>             Shape1.Top = Y1
>             Shape1.Height = Y - Y1
>         End If
>         If Y < Y1 Then
>             Shape1.Top = Y
>             Shape1.Height = Y1 - Y
>         End If
>     End If
> End Sub

> Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As
> Single, Y As Single)
>     x2 = X
>     y2 = Y
>     Shape1.Visible = False
>     Picture1.Line(x1,y1)-(x2,y2),0,B 'Will draw a box
> End Sub

> Gustavo Monteiro
> Salvador, Brazil

> Brent Perteet escreveu na mensagem ...
> >Here's what i wanna do:   i have a picture box and am loading an image
into
> >it (a map), i can draw stuff on top of it with no problem, but what i
want
> >to do is be able to draw another image on top of it and be able to move
it
> >to another location and erase where it was last and restore the screen.
By
> >XOR-ing it with the background i can do this, however the consequence is
> >that the colors change when doing it on a multicolor background, like a
> >photo.  Basically, I want to be able to do what the mouse cursor does in
> >windows...does that makes sense? :)

> >i know i need to use WinAPI routines to do this but i'm not quite sure
how
> >to go about it (it's gotta be a common thing though)

> >thanks in advance,

> >Brent Perteet


 
 
 

drawing in picture boxes

Post by Stephen Smit » Mon, 08 Nov 1999 04:00:00




> Thanks for the reply!  however, that's not exactly what i meant (sorry)
> here's my app:  i have a map in a picture box, and i'm reading in
> coordinates thru the serial port (from GPS).  When i get "ID1  coordinate
> x,y" from the serial port i want to draw a filled box with a number on the
> map where that coordinate would appear, then when i get another coordinate,
> erase the last position and draw the new one...it would all be done
> automatically rather than with the mouse.  does that clarify it? :)
> Brent Perteet


pic.autoredraw=true ' (so pic holds the underlying bmp in addition to
the display bmp)
do
  get info from port
  pic.refresh ' (repaints the underlying bmp to the display)
  draw the new box ' (draws box to the display, not the underlying bmp)
loop

Steve.

 
 
 

drawing in picture boxes

Post by Jeff » Mon, 08 Nov 1999 04:00:00


If THATS all you need to do:

Load the map into the picture property.
Leave AUTOREDRAW as false.
Put a label on the picture box.
Set its x,y co-ordinate and text when you get the serial port message.
Thats all you need to do!
You can even make the label transparent...


Quote:> Thanks for the reply!  however, that's not exactly what i meant (sorry)
> here's my app:  i have a map in a picture box, and i'm reading in
> coordinates thru the serial port (from GPS).  When i get "ID1  coordinate
> x,y" from the serial port i want to draw a filled box with a number on the
> map where that coordinate would appear, then when i get another
coordinate,
> erase the last position and draw the new one...it would all be done
> automatically rather than with the mouse.  does that clarify it? :)