|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Simple Graphics Question.... I want to draw a rectangle in that control using GDI+ ... something like: Dim g as graphics = creategraphics|() Dim r as Rectangle Dim b as new system.drawing.solidbrush(system.drawing.color.red) r.x = 100 r.y = 100 r.width = 400 r.height = 50 g.fillrectangle(b,r) How do I get the rectangle to appear in picControl and not the basic form itself? Somehow I would like to tell the creategraphics function that I want to put the graphics in picControl. Can I do that? Thanks for any help. Try using the CreateGraphics() call from the picturebox
e.g. Dim g as graphics = Dim g As Graphics = Me.PictureBox1.CreateGraphics() hth, Alan. AlanT wrote:
> Do it inside the OnPaint event of the picturebox if you want it to > Try using the CreateGraphics() call from the picturebox > > e.g. > > Dim g as graphics = Dim g As Graphics = > Me.PictureBox1.CreateGraphics() > > > hth, > Alan. > redraw every time the picturebox refreshes. If you do it in there you won't have to call CreateGraphics, it'll be passed to you as the event argument. Dim g as graphics = e.graphics Chris Thanks for the help ... I am (slowly) learning VB 2005 graphics. Since you
were so good at answering that question I'll ask another one! I know that with a bitmap object I can determine the color of an individual pixel by using the getpixel method but is there some way I can determine the color of a particular pixel in a picture box control? Thanks. Show quoteHide quote "Chris" <no@spam.com> wrote in mes?sage news:u6m$GWXPGHA.3264@TK2MSFTNGP11.phx.gbl... > AlanT wrote: >> >> Try using the CreateGraphics() call from the picturebox >> >> e.g. >> >> Dim g as graphics = Dim g As Graphics = >> Me.PictureBox1.CreateGraphics() >> >> >> hth, >> Alan. >> > > Do it inside the OnPaint event of the picturebox if you want it to redraw > every time the picturebox refreshes. If you do it in there you won't have > to call CreateGraphics, it'll be passed to you as the event argument. > > Dim g as graphics = e.graphics > > Chris fripper wrote:
Show quoteHide quote > Thanks for the help ... I am (slowly) learning VB 2005 graphics. Since you I don't know how you would do that. I believe the way you want to do > were so good at answering that question I'll ask another one! I know that > with a bitmap object I can determine the color of an individual pixel by > using the getpixel method but is there some way I can determine the color of > a particular pixel in a picture box control? > > Thanks. > > > "Chris" <no@spam.com> wrote in mes?sage > news:u6m$GWXPGHA.3264@TK2MSFTNGP11.phx.gbl... >> AlanT wrote: >>> Try using the CreateGraphics() call from the picturebox >>> >>> e.g. >>> >>> Dim g as graphics = Dim g As Graphics = >>> Me.PictureBox1.CreateGraphics() >>> >>> >>> hth, >>> Alan. >>> >> Do it inside the OnPaint event of the picturebox if you want it to redraw >> every time the picturebox refreshes. If you do it in there you won't have >> to call CreateGraphics, it'll be passed to you as the event argument. >> >> Dim g as graphics = e.graphics >> >> Chris > > that is "draw" onto a bitmap object that is shown in the picturebox. You should be able to find some info on drawing to a bitmap by searching your favorite engine. Chris Also, you can create a bitmap the size of the picturebox, draw your rectangle
or what ever on the bitmap then assign the bit map to the picture box image property. -- Show quoteHide quoteDennis in Houston "fripper" wrote: > > I have a VB 2005 app ... main window has a picture box control (picControl) > .... I want to draw a rectangle in that control using GDI+ ... something > like: > > Dim g as graphics = creategraphics|() > Dim r as Rectangle > Dim b as new system.drawing.solidbrush(system.drawing.color.red) > > r.x = 100 > r.y = 100 > r.width = 400 > r.height = 50 > > g.fillrectangle(b,r) > > How do I get the rectangle to appear in picControl and not the basic form > itself? Somehow I would like to tell the creategraphics function that I > want to put the graphics in picControl. Can I do that? > > Thanks for any help. > > > > |
|||||||||||||||||||||||