Home » Category » Microsoft Visual Basic

Microsoft Visual Basic: Zoom in and out with graphics in VB

205| Mon, 02 Jun 2008 08:22:00 GMT| anonymous| Comments (7)
Hi All,

I have an application in which I project images and lines on a VB form
through so called Ropes and Boxes:

Boxes:
Public stdPic As StdPicture, X&, Y&, Text$, Text2$, Id$

Public Sub Draw(Obj As Form) 'vbWhite
Call Obj.PaintPicture(stdPic, X - 90, Y - 90) 'Obj
Obj.CurrentX = X + 180 - (Len(Text) \ 2) * 100
Obj.CurrentY = Y + 470
Obj.Print Text;
Obj.CurrentX = X + 180 - (Len(Text2) \ 2) * 100
Obj.CurrentY = Y + 670
Obj.Print Text2;
End Sub

Ropes:
Public a As Box, b As Box, Text$, color&

Public Sub Draw(Obj As Form)

On Error Resume Next
Obj.Line (a.X, a.Y)-(b.X, b.Y), color
Obj.CurrentX = (a.X + b.X) \ 2 - (Len(Text) \ 2) * 100
Obj.CurrentY = a.Y + 0.5 * (b.Y - a.Y) - 100
Obj.Print Text;
End Sub

The way they are projected is based on data from a database:

For LoopPts = 1 To MyDataCount
With CircPts(LoopPts)
Font.Size = 24
Boxes.Add
NewBox(ImageList1.ListImages(MyData(LoopPts).pIcon).Picture, .X, .Y,
MyData(LoopPts).sLabel, MyData(LoopPts).sID, MyData(LoopPts).sLabel2)
Font.Size = 8
If MyData(LoopPts).pIcon = 1 Then 'Bios
Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1),
MyData(LoopPts).sLink, vbBlack)
ElseIf MyData(LoopPts).pIcon = 2 Then 'Orgs
Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1),
MyData(LoopPts).sLink, vbBlack)
ElseIf MyData(LoopPts).pIcon = 3 Then 'Events
Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1),
MyData(LoopPts).sLink, vbBlack)
End If
End With
Next LoopPts

At the moment I can choose between 16x16 and 32x32 images to be
displayed but I was
wondering if it is possible to have a zoom function like with Pictures.
All the graphics are displayed in a Picture so I think it should be
possible.

MArco

Keywords & Tags: zoom, out, graphics, vb, microsoft, visual basic

URL: http://www.programmerbase.com/visual-basic/560734/
 
«« Prev - Next »» 7 helpful answers below.
Use API StretchBlt to Add Zoom Functionality.
If your application deals with Graphics then it is better to use GDI+ which
is much more powerfull , flexible and can add professional touch to your
application.
Zooming is used in one such example (Posted in VB6) using GDI+ see below
mentioned link
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=66543&txtForceRefresh=101120061275557879

"Co" wrote:

> Hi All,
> I have an application in which I project images and lines on a VB form
> through so called Ropes and Boxes:
> Boxes:
> Public stdPic As StdPicture, X&, Y&, Text$, Text2$, Id$
> Public Sub Draw(Obj As Form) 'vbWhite
> Call Obj.PaintPicture(stdPic, X - 90, Y - 90) 'Obj
> Obj.CurrentX = X + 180 - (Len(Text) \ 2) * 100
> Obj.CurrentY = Y + 470
> Obj.Print Text;
> Obj.CurrentX = X + 180 - (Len(Text2) \ 2) * 100
> Obj.CurrentY = Y + 670
> Obj.Print Text2;
> End Sub
>
> Ropes:
> Public a As Box, b As Box, Text$, color&
> Public Sub Draw(Obj As Form)
> On Error Resume Next
> Obj.Line (a.X, a.Y)-(b.X, b.Y), color
> Obj.CurrentX = (a.X + b.X) \ 2 - (Len(Text) \ 2) * 100
> Obj.CurrentY = a.Y + 0.5 * (b.Y - a.Y) - 100
> Obj.Print Text;
> End Sub
> The way they are projected is based on data from a database:
> For LoopPts = 1 To MyDataCount
> With CircPts(LoopPts)
> Font.Size = 24
> Boxes.Add
> NewBox(ImageList1.ListImages(MyData(LoopPts).pIcon).Picture, .X, .Y,
> MyData(LoopPts).sLabel, MyData(LoopPts).sID, MyData(LoopPts).sLabel2)
> Font.Size = 8
> If MyData(LoopPts).pIcon = 1 Then 'Bios
> Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1),
> MyData(LoopPts).sLink, vbBlack)
> ElseIf MyData(LoopPts).pIcon = 2 Then 'Orgs
> Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1),
> MyData(LoopPts).sLink, vbBlack)
> ElseIf MyData(LoopPts).pIcon = 3 Then 'Events
> Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1),
> MyData(LoopPts).sLink, vbBlack)
> End If
> End With
> Next LoopPts
> At the moment I can choose between 16x16 and 32x32 images to be
> displayed but I was
> wondering if it is possible to have a zoom function like with Pictures.
> All the graphics are displayed in a Picture so I think it should be
> possible.
> MArco
>

rajneesh | Mon, 02 Jun 2008 08:23:00 GMT |

Rajneesh,

Great thankx

Marco
Rajneesh Noonia schreef:

> Use API StretchBlt to Add Zoom Functionality.
> If your application deals with Graphics then it is better to use GDI+ which
> is much more powerfull , flexible and can add professional touch to your
> application.
> Zooming is used in one such example (Posted in VB6) using GDI+ see below
> mentioned link
> http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=66543&txtForceRefresh=101120061275557879
> "Co" wrote:
> > Hi All,
> >
> > I have an application in which I project images and lines on a VB form
> > through so called Ropes and Boxes:
> >
> > Boxes:
> > Public stdPic As StdPicture, X&, Y&, Text$, Text2$, Id$
> >
> > Public Sub Draw(Obj As Form) 'vbWhite
> > Call Obj.PaintPicture(stdPic, X - 90, Y - 90) 'Obj
> > Obj.CurrentX = X + 180 - (Len(Text) \ 2) * 100
> > Obj.CurrentY = Y + 470
> > Obj.Print Text;
> > Obj.CurrentX = X + 180 - (Len(Text2) \ 2) * 100
> > Obj.CurrentY = Y + 670
> > Obj.Print Text2;
> > End Sub
> >
> >
> > Ropes:
> > Public a As Box, b As Box, Text$, color&
> >
> > Public Sub Draw(Obj As Form)
> >
> > On Error Resume Next
> > Obj.Line (a.X, a.Y)-(b.X, b.Y), color
> > Obj.CurrentX = (a.X + b.X) \ 2 - (Len(Text) \ 2) * 100
> > Obj.CurrentY = a.Y + 0.5 * (b.Y - a.Y) - 100
> > Obj.Print Text;
> > End Sub
> >
> > The way they are projected is based on data from a database:
> >
> > For LoopPts = 1 To MyDataCount
> > With CircPts(LoopPts)
> > Font.Size = 24
> > Boxes.Add
> > NewBox(ImageList1.ListImages(MyData(LoopPts).pIcon).Picture, .X, .Y,
> > MyData(LoopPts).sLabel, MyData(LoopPts).sID, MyData(LoopPts).sLabel2)
> > Font.Size = 8
> > If MyData(LoopPts).pIcon = 1 Then 'Bios
> > Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1),
> > MyData(LoopPts).sLink, vbBlack)
> > ElseIf MyData(LoopPts).pIcon = 2 Then 'Orgs
> > Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1),
> > MyData(LoopPts).sLink, vbBlack)
> > ElseIf MyData(LoopPts).pIcon = 3 Then 'Events
> > Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1),
> > MyData(LoopPts).sLink, vbBlack)
> > End If
> > End With
> > Next LoopPts
> >
> > At the moment I can choose between 16x16 and 32x32 images to be
> > displayed but I was
> > wondering if it is possible to have a zoom function like with Pictures.
> > All the graphics are displayed in a Picture so I think it should be
> > possible.
> >
> > MArco
> >
> >

hbb | Mon, 02 Jun 2008 08:24:00 GMT |

Rajneesh,

I tried the wrapper.vbp but I can't get it to work.
It keeps telling me that it is unable to load the graph.ocx.
Could you help me with an example on how to to this?

I have a form with a picture on which I load some lines and images.

Marco

Rajneesh Noonia schreef:

> Use API StretchBlt to Add Zoom Functionality.
> If your application deals with Graphics then it is better to use GDI+ which
> is much more powerfull , flexible and can add professional touch to your
> application.
> Zooming is used in one such example (Posted in VB6) using GDI+ see below
> mentioned link
> http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=66543&txtForceRefresh=101120061275557879
> "Co" wrote:
> > Hi All,
> >
> > I have an application in which I project images and lines on a VB form
> > through so called Ropes and Boxes:
> >
> > Boxes:
> > Public stdPic As StdPicture, X&, Y&, Text$, Text2$, Id$
> >
> > Public Sub Draw(Obj As Form) 'vbWhite
> > Call Obj.PaintPicture(stdPic, X - 90, Y - 90) 'Obj
> > Obj.CurrentX = X + 180 - (Len(Text) \ 2) * 100
> > Obj.CurrentY = Y + 470
> > Obj.Print Text;
> > Obj.CurrentX = X + 180 - (Len(Text2) \ 2) * 100
> > Obj.CurrentY = Y + 670
> > Obj.Print Text2;
> > End Sub
> >
> >
> > Ropes:
> > Public a As Box, b As Box, Text$, color&
> >
> > Public Sub Draw(Obj As Form)
> >
> > On Error Resume Next
> > Obj.Line (a.X, a.Y)-(b.X, b.Y), color
> > Obj.CurrentX = (a.X + b.X) \ 2 - (Len(Text) \ 2) * 100
> > Obj.CurrentY = a.Y + 0.5 * (b.Y - a.Y) - 100
> > Obj.Print Text;
> > End Sub
> >
> > The way they are projected is based on data from a database:
> >
> > For LoopPts = 1 To MyDataCount
> > With CircPts(LoopPts)
> > Font.Size = 24
> > Boxes.Add
> > NewBox(ImageList1.ListImages(MyData(LoopPts).pIcon).Picture, .X, .Y,
> > MyData(LoopPts).sLabel, MyData(LoopPts).sID, MyData(LoopPts).sLabel2)
> > Font.Size = 8
> > If MyData(LoopPts).pIcon = 1 Then 'Bios
> > Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1),
> > MyData(LoopPts).sLink, vbBlack)
> > ElseIf MyData(LoopPts).pIcon = 2 Then 'Orgs
> > Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1),
> > MyData(LoopPts).sLink, vbBlack)
> > ElseIf MyData(LoopPts).pIcon = 3 Then 'Events
> > Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1),
> > MyData(LoopPts).sLink, vbBlack)
> > End If
> > End With
> > Next LoopPts
> >
> > At the moment I can choose between 16x16 and 32x32 images to be
> > displayed but I was
> > wondering if it is possible to have a zoom function like with Pictures.
> > All the graphics are displayed in a Picture so I think it should be
> > possible.
> >
> > MArco
> >
> >

hbb | Mon, 02 Jun 2008 08:25:00 GMT |

did you register the ocx?

"Co" <vonclausowitz...gmail.com> wrote in message
news:1160568280.035901.13130...i3g2000cwc.googlegroups.com...
> Rajneesh,
> I tried the wrapper.vbp but I can't get it to work.
> It keeps telling me that it is unable to load the graph.ocx.
> Could you help me with an example on how to to this?
>

hbb | Mon, 02 Jun 2008 08:26:00 GMT |

I did.

I got it to work.

Marco

MP schreef:

> did you register the ocx?
>
> "Co" <vonclausowitz...gmail.com> wrote in message
> news:1160568280.035901.13130...i3g2000cwc.googlegroups.com...
> > Rajneesh,
> >
> > I tried the wrapper.vbp but I can't get it to work.
> > It keeps telling me that it is unable to load the graph.ocx.
> > Could you help me with an example on how to to this?
> >

hbb | Mon, 02 Jun 2008 08:27:00 GMT |

Open Graph.vbp and create OCX file in Bin Directory..
Open Wrapper.vbp
if it say some thing like error loading oGraph etc.. then open form frmTest.
Remove picture box Convas1
Click on add Component and click on browse
locate the oGraph.ocx in bin directory and click ok
Drag and drop oConvas Control and rename it to Convas1
Save the project and run it...
Let me know if this doen't help

"Co" wrote:

> I did.
> I got it to work.
> Marco
> MP schreef:
> > did you register the ocx?
> >
> >
> > "Co" <vonclausowitz...gmail.com> wrote in message
> > news:1160568280.035901.13130...i3g2000cwc.googlegroups.com...
> > > Rajneesh,
> > >
> > > I tried the wrapper.vbp but I can't get it to work.
> > > It keeps telling me that it is unable to load the graph.ocx.
> > > Could you help me with an example on how to to this?
> > >
>

rajneeshnoonia | Mon, 02 Jun 2008 08:28:00 GMT |

It worked,

Thank you very much

MArco

Rajneesh Noonia schreef:

> Open Graph.vbp and create OCX file in Bin Directory..
> Open Wrapper.vbp
> if it say some thing like error loading oGraph etc.. then open form frmTest.
> Remove picture box Convas1
> Click on add Component and click on browse
> locate the oGraph.ocx in bin directory and click ok
> Drag and drop oConvas Control and rename it to Convas1
> Save the project and run it...
> Let me know if this doen't help
>
> "Co" wrote:
> > I did.
> >
> > I got it to work.
> >
> > Marco
> >
> > MP schreef:
> >
> > > did you register the ocx?
> > >
> > >
> > > "Co" <vonclausowitz...gmail.com> wrote in message
> > > news:1160568280.035901.13130...i3g2000cwc.googlegroups.com...
> > > > Rajneesh,
> > > >
> > > > I tried the wrapper.vbp but I can't get it to work.
> > > > It keeps telling me that it is unable to load the graph.ocx.
> > > > Could you help me with an example on how to to this?
> > > >
> >
> >

hbb | Mon, 02 Jun 2008 08:29:00 GMT |

Microsoft Visual Basic Hot Answers

Microsoft Visual Basic New questions

Microsoft Visual Basic Related Categories