Re: Graph Plotting - Mike
- From: "WebBiz" <justask@xxxxxxxxxxxxxxxxx>
- Date: Sat, 18 Feb 2006 23:09:17 -0600
Okay, I guess I'll start at the beginning and try to figure out what your
code does.
======= this is obvious ======
Dim n As Long
Me.WindowState = vbMaximized
Me.Show
DoEvents
=======================
With Picture1
.AutoRedraw = False
.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
DoEvents
pixWide = Me.ScaleX(.ScaleWidth, .ScaleMode, vbPixels)
pixHigh = Me.ScaleY(.ScaleHeight, .ScaleMode, vbPixels)
End With
Okay. The above you're setting up the picturebox. Turning off .AutoRedraw
disables the picturebox's ability to redraw its contents. But why do we want
to do this? I'm not sure.
We're getting the form's scalewidth and height in pixel scale and assigning
this to the picturebox.
myDC = CreateCompatibleDC(Form1.hdc)
This creates a memory device context that is 1 pixel wide/high? Why isn't
the picturebox being referenced instead of the form for the DC? Isn't the
picturebox what we are altimately going to draw in?
myBmp = CreateCompatibleBitmap(Form1.hdc, pixWide, pixHigh)
Returns a handle to a compatible bitmap that is the size of the picturebox.
oldBmp = SelectObject(myDC, myBmp)
This places our new bitmap (myBmp) into the device context and removes the
old bitmap and places that in oldBmp. It is a bitmap swap? What are we
swapping. When did we ever have anything in it?
pen1 = CreatePen(myDC, PS_SOLID, vbWhite)
A solid white line pen is created and referenced by Pen1.
penOld = SelectObject(myDC, pen1)
We swap our white pen with whatever the original pen happened to be, which
is now referenced by penOld. This part is easy to understand since there is
a default pen. But a default bitmap? Or was oldBmp = SelectObject(myDC,
myBmp) actually fore-thought to adding it to my project which will have a
chart in the background? I'm still confused.
Randomize Timer
For n = 1 To 200
LineTo myDC, Rnd * pixWide, Rnd * pixHigh
Next n
Draw lines all over the device context referenced by myDC. This confuses me
because myDC came from Form1 rather than Picture1.
BitBlt Picture1.hdc, 0, 0, pixWide, pixHigh, _
myDC, 0, 0, vbSrcCopy
Okay! Okay! I get it. (I think). myDC is just a memory placeholder so
drawing in it will not actually show up. Right? But then we transfer it with
BitBlt from the non-visible memory to the picturebox which will make it
visible? Is that it?
Okay. My eyes are strained and my head hurts. Time to turn off the monitor
and get a life.
:-)
"WebBiz" <justask@xxxxxxxxxxxxxxxxx> wrote in message
news:9qRJf.395859$0l5.233634@xxxxxxxxxxxxx
Mike.
I've placed the Blt code into my project but having a heck of a time
trying to make it work. Since your code contains instructions to draw the
background which I don't need (because I have the price bar chart there),
I either get a black background and the red lines moving as they should,
or I comment a few of those Pen lines and I get a bunch of red lines that
eventually make the whole screen red as the old lines are not erased.
Just to show how well I blend with graphics, I've still got to try and
find what line is causing the black background. Then I have to figure out
how to leave my own background in place. I'm assuming we go back to
picture1.picture = picture1.image?
While I await your reply, I'll go try and read up on this BitBlt
thingamajiggy. Not sure what it is suppose to do since we're seem to still
be using the picture1.line method. I recall it has something to do with
putting data into graphic memory or something like that. I should be more
up on it by the time you get back.
Thanks.
Rick
.
- Follow-Ups:
- Re: Graph Plotting - Mike
- From: Mike Williams
- Re: Graph Plotting - Mike
- From: Mike Williams
- Re: Graph Plotting - Mike
- From: Mike Williams
- Re: Graph Plotting - Mike
- References:
- Graph Plotting
- From: Mike Williams
- Re: Graph Plotting
- From: WebBiz
- Re: Graph Plotting
- From: Mike Williams
- Re: Graph Plotting
- From: WebBiz
- Re: Graph Plotting
- From: Mike Williams
- Re: Graph Plotting
- From: WebBiz
- Re: Graph Plotting - Mike
- From: WebBiz
- Graph Plotting
- Prev by Date: Re: DirListBox question
- Next by Date: Re: DirListBox question
- Previous by thread: Re: Graph Plotting - Mike
- Next by thread: Re: Graph Plotting - Mike
- Index(es):
Relevant Pages
|