Wanted: Tips on Flicker-Free Draw Scrolling
Author |
Message |
Webbi #1 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
Hello. An old project of mine draws stock charts on a picturebox called pctChart. On this pctChart, a routine called DrawChart is used to draw OHLC or Candlestick price bars. After the bars are drawn, the chart tools are drawn over them, such as lines, boxes, etc. This is done in RedrawTools. Currently, I can scroll this chart by either double-clicking the chart, holding down the mouse button on the second click, and dragging the mouse to a new location. After the mouse is let up, then the draw is redrawn in the new location. Or, I can press and hold the Left or Right arrow keys and it will scroll the chart (slowly) to the right or left. Problem: With the arrow keys, in order to show the chart actually scrolling, it runs the DrawChart and RedrawTools over and over, one day (bar) at a time. This looks really rickety, and moves so slow. Watching it redraw each time is a flickering hodge-podge. It would be nice if the chart would scroll smoothly and quickly. As for scrolling with the mouse, I'd like it to actually show the bars scrolling, also smoothly and as quick as the mouse is being moved, while the mouse is being moved. Right now, I don't do any of the redraw with the mouse until it has stopped at the new location, because of the flickering issue. There is just all these redraws. Because I have purchased programs that seem to do this without any problem, I believe it should be possible to do the same with my project. Yet, I'm wondering if this is a VB6 problem, and that I'd have to program with C to achieve the above. And yes, I have a decently quick computer and graphics card, so that's not the problem. Any suggestions, tips and otherwise? Thanks. Webbiz
|
Sat, 12 May 2012 03:36:09 GMT |
|
 |
Nobod #2 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
Use the same technique used by games. It's called double buffering. Draw everything on another PictureBox that has AutoRedraw=True, and Visible=False. Once you are done, copy from the off screen PictureBox to the on screen PictureBox. Example copying code: Set pctChartOnScreen.Picture = pctChartOffScreen.Picture pctChartOnScreen.Refresh ' Only use if pctChartOnScreen.AutoRedraw=True
|
Sat, 12 May 2012 03:51:23 GMT |
|
 |
Mike William #3 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
Quote: > With the arrow keys, in order to show the chart actually > scrolling and using it runs the DrawChart and RedrawTools > over and over, one day (bar) at a time.
If you are using key events then the scroll rate will be limited by the current keyboard repeat rate, but I imagine you are already aware of that and are reading the state of the arrow keys in a way that overcomes that problem? Quote: > This looks really rickety, and moves so slow.
Are you redrawing the entire PictureBox each time, or are you drawing only the new data and scrolling any unchanged existing data by blitting the unchanged block a little to the left? (although which will be the faster of these two methods depends on the complexity of your drawings). Quote: > Watching it redraw each time is a flickering hodge-podge
With many kinds of drawings you need to use double buffering in order to eliminate the flicker, as has already been mentioned by "Nobody". By the way, are you using the most appropriate GDI functions for your drawings? For example, are you using PolyLine and Rectangle etc rather than individual LineTo calls? Most GDI drawing functions are very much slower in Vista than they are in XP (because most Vista systems do not use your video card's GDI accelerated hardware, whereas XP systems almost always do) but even in Vista using things like Polyline can be up to two or three times faster than the equivalent bunch of LineTo calls (and of course often very much faster still on the same system running XP). Also, if you are using a system that does use the video card's accelerated 2D hardware (Win98 / XP) you will find that Polyline is very much slower if there is a "clipping hole" in the window that covers even a single pixel of the complete Polyline drawing (a Command Button or other Control or something that VB is displaying on the window whilst its ClipControls property is at its default value of True), because GDI hardware is not usually used by Polyline under such conditions. I think the first thing I would do in your specific case would be to put a high resolution timer on both the DrawChart and RedrawTools functions, to see which of those is taking the most time, on the grounds that it's always best to tackle the biggest bottleneck first before you look at other smaller things. If your system is using your video cards GDI accelerated hardware then it might be wise for test purposes to place a function call at the very end of both of these routines that will cause the routine to wait until the video card hardware has actually finished the drawing that was triggered by your code, otherwise you will get misleading timings (changing the Form's Caption property usually serves to perform the wait). Other than that, it is really hard to think of anything concrete to suggest without being able to actually see and run your code. Mike
|
Sat, 12 May 2012 05:54:23 GMT |
|
 |
Larry Serflate #4 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
<...> Quote: > Currently, I can scroll this chart by either double-clicking the > chart, holding down the mouse button on the second click, and dragging > the mouse to a new location. After the mouse is let up, then the draw > is redrawn in the new location. <...> > With the arrow keys, in order to show the chart actually scrolling, it > runs the DrawChart and RedrawTools over and over, one day (bar) at a > time. This looks really rickety, and moves so slow. Watching it redraw > each time is a flickering hodge-podge. It would be nice if the chart > would scroll smoothly and quickly. <...> > Any suggestions, tips and otherwise?
As other have said, using a second buffer is going to help. Do remember that your whole application is just so many pixels on a screen. As long as you can draw something that looks like a chart, people will believe its a chart. If you can draw something that looks like a button, people will believe its a button, until shown otherwise. One method to help reduce the flicker would be to draw the whole chart to an invisible picturebox, and then just show what you need to fill the form area. For an example, add a picturebox to a new form and paste in the code below.... As posted it only handles the mouse drag operation, I've left it up to you to handle the others. HTH LFS Option Explicit Private imgLeft As Long Private MX As Single Private Sub Form_Load() Dim X ' Draw chart Picture1.BorderStyle = vbBSNone Picture1.Move 0, 0, 30000, 4000 Picture1.AutoRedraw = True Picture1.BackColor = vbWhite Picture1.Line (90, 90)-(29780, 3920), vbBlack, B For X = 105 To 29800 Step 900 Picture1.PSet (X, 90), vbBlack Picture1.Line -Step(0, 3810), &HCCCCCC Picture1.PSet (X + 30, 1600), vbWhite Picture1.Print CStr(X \ 90 - 1) Next Me.Move 1000, 1000, 8000, 4600 Picture1.Visible = False End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) MX = X End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbLeftButton Then imgLeft = imgLeft + (X - MX) ' Test boundries If imgLeft > 0 Then imgLeft = 0 If imgLeft < (Me.Width - Picture1.Width) Then imgLeft = (Me.Width - Picture1.Width) MX = X ' Paint chart PaintPicture Picture1.Image, imgLeft, 0 End If End Sub Private Sub Form_Paint() PaintPicture Picture1.Image, imgLeft, 0 End Sub
|
Sat, 12 May 2012 07:04:08 GMT |
|
 |
Webbi #5 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
On Mon, 23 Nov 2009 21:54:23 -0000, "Mike Williams" Quote:
>> With the arrow keys, in order to show the chart actually >> scrolling and using it runs the DrawChart and RedrawTools >> over and over, one day (bar) at a time. >If you are using key events then the scroll rate will be limited by the >current keyboard repeat rate, but I imagine you are already aware of that >and are reading the state of the arrow keys in a way that overcomes that >problem?
Ah...no. I'm not that sophisticated, remember. :-0 Quote: >> This looks really rickety, and moves so slow. >Are you redrawing the entire PictureBox each time, or are you drawing only >the new data and scrolling any unchanged existing data by blitting the >unchanged block a little to the left? (although which will be the faster of >these two methods depends on the complexity of your drawings).
Drawing the whole picturebox each time. Quote: >> Watching it redraw each time is a flickering hodge-podge >With many kinds of drawings you need to use double buffering in order to >eliminate the flicker, as has already been mentioned by "Nobody".
That sounds so easy. (Thanks Nobody!). So what I am currently drawing directly to the pctChart, instead draw to a non visible picturebox and THEN copy it over. That's it? Quote: >By the way, are you using the most appropriate GDI functions for your >drawings? For example, are you using PolyLine and Rectangle etc rather than >individual LineTo calls? Most GDI drawing functions are very much slower in >Vista than they are in XP (because most Vista systems do not use your video >card's GDI accelerated hardware, whereas XP systems almost always do) but >even in Vista using things like Polyline can be up to two or three times >faster than the equivalent bunch of LineTo calls (and of course often very >much faster still on the same system running XP). Also, if you are using a >system that does use the video card's accelerated 2D hardware (Win98 / XP) >you will find that Polyline is very much slower if there is a "clipping >hole" in the window that covers even a single pixel of the complete Polyline >drawing (a Command Button or other Control or something that VB is >displaying on the window whilst its ClipControls property is at its default >value of True), because GDI hardware is not usually used by Polyline under >such conditions.
Mostly, I use the Picturebox.Line method. Just drawing a line from here to there, here to there, here to there. For example, each price bar is simply a vertical line with a small horizontal line off the left side and one on the right side. The chart may show anywhere from 100 to 200 of these vertical lines representing the high/low/open/close of each trading day. Take a look at this video. It will show you what my chart looks like, and also show the redraw stuff. http://www.screencast.com/t/Y2FhMDY2Z I know that it probably doesn't look that bad. But I've seen smoother, faster. The video also shows a couple tools being redrawn as part of RedrawTools. Quote: >I think the first thing I would do in your specific case would be to put a >high resolution timer on both the DrawChart and RedrawTools functions, to >see which of those is taking the most time, on the grounds that it's always >best to tackle the biggest bottleneck first before you look at other smaller >things. If your system is using your video cards GDI accelerated hardware >then it might be wise for test purposes to place a function call at the very >end of both of these routines that will cause the routine to wait until the >video card hardware has actually finished the drawing that was triggered by >your code, otherwise you will get misleading timings (changing the Form's >Caption property usually serves to perform the wait). >Other than that, it is really hard to think of anything concrete to suggest >without being able to actually see and run your code. >Mike
Thanks. Webbiz
|
Sat, 12 May 2012 08:35:54 GMT |
|
 |
Webbi #6 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
Thanks Larry. :-) This code is very instructional. Best regards, Webbiz On Mon, 23 Nov 2009 17:04:08 -0600, "Larry Serflaten" Quote:
><...> >> Currently, I can scroll this chart by either double-clicking the >> chart, holding down the mouse button on the second click, and dragging >> the mouse to a new location. After the mouse is let up, then the draw >> is redrawn in the new location. ><...> >> With the arrow keys, in order to show the chart actually scrolling, it >> runs the DrawChart and RedrawTools over and over, one day (bar) at a >> time. This looks really rickety, and moves so slow. Watching it redraw >> each time is a flickering hodge-podge. It would be nice if the chart >> would scroll smoothly and quickly. ><...> >> Any suggestions, tips and otherwise? >As other have said, using a second buffer is going to help. >Do remember that your whole application is just so many pixels on >a screen. As long as you can draw something that looks like a chart, >people will believe its a chart. If you can draw something that looks >like a button, people will believe its a button, until shown otherwise. >One method to help reduce the flicker would be to draw the whole >chart to an invisible picturebox, and then just show what you need >to fill the form area. >For an example, add a picturebox to a new form and paste in the >code below.... >As posted it only handles the mouse drag operation, I've left it up >to you to handle the others. >HTH >LFS >Option Explicit >Private imgLeft As Long >Private MX As Single >Private Sub Form_Load() >Dim X >' Draw chart > Picture1.BorderStyle = vbBSNone > Picture1.Move 0, 0, 30000, 4000 > Picture1.AutoRedraw = True > Picture1.BackColor = vbWhite > Picture1.Line (90, 90)-(29780, 3920), vbBlack, B > For X = 105 To 29800 Step 900 > Picture1.PSet (X, 90), vbBlack > Picture1.Line -Step(0, 3810), &HCCCCCC > Picture1.PSet (X + 30, 1600), vbWhite > Picture1.Print CStr(X \ 90 - 1) > Next > Me.Move 1000, 1000, 8000, 4600 > Picture1.Visible = False >End Sub >Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) > MX = X >End Sub >Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) > If Button = vbLeftButton Then > imgLeft = imgLeft + (X - MX) > ' Test boundries > If imgLeft > 0 Then imgLeft = 0 > If imgLeft < (Me.Width - Picture1.Width) Then imgLeft = (Me.Width - Picture1.Width) > MX = X > ' Paint chart > PaintPicture Picture1.Image, imgLeft, 0 > End If >End Sub >Private Sub Form_Paint() > PaintPicture Picture1.Image, imgLeft, 0 >End Sub
|
Sat, 12 May 2012 08:39:26 GMT |
|
 |
Dave O #7 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
Quote: > Hello. > An old project of mine draws stock charts on a picturebox called > pctChart. > On this pctChart, a routine called DrawChart is used to draw OHLC or > Candlestick price bars. > After the bars are drawn, the chart tools are drawn over them, such as > lines, boxes, etc. This is done in RedrawTools. > Currently, I can scroll this chart by either double-clicking the > chart, holding down the mouse button on the second click, and dragging > the mouse to a new location. After the mouse is let up, then the draw > is redrawn in the new location. > Or, I can press and hold the Left or Right arrow keys and it will > scroll the chart (slowly) to the right or left. > Problem: > With the arrow keys, in order to show the chart actually scrolling, it > runs the DrawChart and RedrawTools over and over, one day (bar) at a > time. This looks really rickety, and moves so slow. Watching it redraw > each time is a flickering hodge-podge. It would be nice if the chart > would scroll smoothly and quickly. > As for scrolling with the mouse, I'd like it to actually show the bars > scrolling, also smoothly and as quick as the mouse is being moved, > while the mouse is being moved. Right now, I don't do any of the > redraw with the mouse until it has stopped at the new location, > because of the flickering issue. There is just all these redraws. > Because I have purchased programs that seem to do this without any > problem, I believe it should be possible to do the same with my > project. Yet, I'm wondering if this is a VB6 problem, and that I'd > have to program with C to achieve the above. > And yes, I have a decently quick computer and graphics card, so that's > not the problem. > Any suggestions, tips and otherwise? > Thanks. > Webbiz
If all you want to do is move the image about when scrolled another option is to put a very big picture box inside a much smaller picture box, plot your stuff on the large one then with scroll bars you can move the whole box but only the part visible through the smaller box would be seen. Dave O.
|
Sat, 12 May 2012 17:42:33 GMT |
|
 |
Nobod #8 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
Quote: > If all you want to do is move the image about when scrolled another option > is to put a very big picture box inside a much smaller picture box, plot > your stuff on the large one then with scroll bars you can move the whole > box but only the part visible through the smaller box would be seen.
The sample that Larry Serflaten posted did just that, except he used a large PictureBox and the form.
|
Sat, 12 May 2012 18:38:12 GMT |
|
 |
Larry Serflate #9 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
Quote: > Thanks Larry. :-) > This code is very instructional.
You're welcome. However, typical for one-off replies, there was a line that needs replacement: If imgLeft < (Me.Width - Picture1.Width) Then imgLeft = (Me.Width - Picture1.Width) Because different people have different form borders, that Me.Width should have been Me.ScaleWidth, with the apporpreate adjustments to the boundry checks.... Have fun! LFS
|
Sat, 12 May 2012 20:14:07 GMT |
|
 |
Mike William #10 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
Quote: > Drawing the whole picturebox each time.
Right. In that case perhaps you might like to consider drawing it just once into an offscreen Autoredraw PictureBox and painting or positioning only the required part into the display as you scroll, as has already been suggested by Dave and Larry. I do seem to vaguely recall you posting something about your stock chart drawing program a long time ago and saying that there was a reason you could not do that when I suggested it at the time, but I can't remember what that reason was now. Was there a specific reason that you could not do that, something to do with the data changing on the fly or something? I can't remember now. If not then it certainly is a good way of doing it, and you will be able to use more than one offscreen PictureBox to predraw a very large amount of data, perhaps about 30 or 40 screen widths of data, before you begin to eat too much into the RAM available for other applications, and much more than that if you use DIBs instead of PictureBoxes or other screen compatible bitmaps, because DIBs will quite happily live in the swapfile. Quote: > Mostly, I use the Picturebox.Line method. Just drawing > a line from here to there, here to there, here to there.
The PictureBox Line method is about as fast as the alternative API MoveTo / LineTo method (which is understandable of course because that's what it uses under the hood), but the only problem is that (as with all native VB drawing methods) it effectively triggers a Refresh on an Autoredraw PictureBox, which is somehting that you often do not want. But as far as actual drawing speed is concerned it is much the same. One thing to note is that according to the video you posted you are using lines more than one pixel wide. These are drawn slower than single pixel lines of course, but in Vista (which disables the video card's accelerated GDI hardware) the speed is comparable with drawing more than one separate single pixel line (although this was not the case in XP as I recall, which does use the video card's accelerated GDI functions and in which the drawing of single pixel thick lines was blindingly fast). In Vista, also, the speed of the different GDI drawing functions is affected by whether or not the system is currently running at the "disable desktop composition" setting, but generally it is faster to draw horizontal or vertical lines of more than one pixel thickness using the API FillRect function rather than the API LineTo function (or the VB Line method). The amount of extra speed you get from using FillRect is not a lot when Vista is running its standard Aero desktop, and is much more when Vista is running in "disable desktop composition" mode, but in all cases (in Vista) it is faster than LineTo, at least on the systems I've personally tried it on. In XP things were very different of course, but the Win32 GDI is now effectively crippled on almost all Vista machines. How sad :-( Quote: > [in respnse to a statement regarding the keyboard repeat > rate] Ah...no. I'm not that sophisticated, remember. :-0
You can overcome that by creating a keymap in memory (a simple array) and using a Key event to set the curreent state of the keys as they are pressed and released by the user. In that way your code can examine the key map at any time you wish and you will know whether any specific key is currently down or up. So, instead of using an arrow key event to scroll your image you can use a timer or a code loop to repeatedly react to the current state of the required key. Mike
|
Sat, 12 May 2012 20:38:33 GMT |
|
 |
Dee Earle #11 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
Quote: > rolling with the mouse, I'd like it to actually show the bars > scrolling, also smoothly and as quick as the mouse is being moved, > while the mouse is being moved. Right now, I don't do any of the > redraw with the mouse until it has stopped at the new location, > because of the flickering issue. There is just all these redraws. > Because I have purchased programs that seem to do this without any > problem, I believe it should be possible to do the same with my > project. Yet, I'm wondering if this is a VB6 problem, and that I'd
Firstly, use double buffering so you don't draw bits at a time. You draw the data to an off screen buffer, then draw when needed. Even with this, I was getting some flickering as VB insisted on redrawing some parts of the screen in WM_PAINT before firing the Paint event, despite me eating the WM_ERASEBACKGROUND message. I ended up handling WM_PAINT myself then passing direct to the paint event: Case WM_PAINT 'We handle WM_PAINT ourselves as VB6 seems to explicitly draw the background in its handler hDC = BeginPaint(hWnd, PaintInfo) GraphFrame_Paint EndPaint hWnd, PaintInfo 'We've handled it so VB doesn't do anything further SubClassed_WindowProc = 0 Handled = True --
i-Catcher Development Team iCode Systems
|
Sat, 12 May 2012 21:02:22 GMT |
|
 |
Mike William #12 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
. . . the other thing I wanted to mention as far as the drawing side of your code is concerned (except that it went out of my mind as I began to get more and more angry thinking about how GDI hardware acceleration has been destroyed on almost all Vista machines!) is the GDI PolyLine function, which even in Vista can be faster than the equivalent bunch of Line (or LineTo) methods. PolyLine draws a set of continuously connected lines, but if that does not suit your purposes then you can instead use the PolyPolyLine function, which can draw any number of separate groups of lines at different places. The only problem with that, judging by the video you posted, is you are using a number of different line colours, and PolyLine (or PolyPolyLine) draws all lines the same specified colour. You could get around that though by using one call to PolyPolyLine to first draw all black lines, then another call to PolyPolyLine to draw all red lines, etc, etc. This might add a bit of complexity to your drawing logic (setting up the different POINTAPI arrays) but it might still be worth it. You'd need to try it in practice on your own specific drawings though, to see whether it ends up with a speed increase worth bothering about. Also, you still need to look at the offscreen buffer that has been suggested by a number of people, but even when you have done that it is still best to get the most speed you can out of whatever drawing operations you perform, regardless of when you actually perform them. Mike
|
Sat, 12 May 2012 21:44:22 GMT |
|
 |
Webbi #13 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
On Tue, 24 Nov 2009 13:44:22 -0000, "Mike Williams" Quote:
>. . . the other thing I wanted to mention as far as the drawing side of your >code is concerned (except that it went out of my mind as I began to get more >and more angry thinking about how GDI hardware acceleration has been >destroyed on almost all Vista machines!) is the GDI PolyLine function, which >even in Vista can be faster than the equivalent bunch of Line (or LineTo) >methods. PolyLine draws a set of continuously connected lines, but if that >does not suit your purposes then you can instead use the PolyPolyLine >function, which can draw any number of separate groups of lines at different >places. The only problem with that, judging by the video you posted, is you >are using a number of different line colours, and PolyLine (or PolyPolyLine) >draws all lines the same specified colour. You could get around that though >by using one call to PolyPolyLine to first draw all black lines, then >another call to PolyPolyLine to draw all red lines, etc, etc. This might add >a bit of complexity to your drawing logic (setting up the different POINTAPI >arrays) but it might still be worth it. You'd need to try it in practice on >your own specific drawings though, to see whether it ends up with a speed >increase worth bothering about. Also, you still need to look at the >offscreen buffer that has been suggested by a number of people, but even >when you have done that it is still best to get the most speed you can out >of whatever drawing operations you perform, regardless of when you actually >perform them. >Mike
Now I remember the headache I had trying to assimilate all that high tech talk in my head. Ooh. I'm going to try the two pic box idea first, just to see what happens. So if I undertand correctly, I should replace the picturebox being referenced by my current drawing code to one that is not visible and has Autoredraw = true, correct? And then, when the drawing is completed, have it sent to the picture box I'm currently using. Is that right? Webbiz
|
Sun, 13 May 2012 11:00:30 GMT |
|
 |
Webbi #14 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
Quote:
>> Hello. >> An old project of mine draws stock charts on a picturebox called >> pctChart. >> On this pctChart, a routine called DrawChart is used to draw OHLC or >> Candlestick price bars. >> After the bars are drawn, the chart tools are drawn over them, such as >> lines, boxes, etc. This is done in RedrawTools. >> Currently, I can scroll this chart by either double-clicking the >> chart, holding down the mouse button on the second click, and dragging >> the mouse to a new location. After the mouse is let up, then the draw >> is redrawn in the new location. >> Or, I can press and hold the Left or Right arrow keys and it will >> scroll the chart (slowly) to the right or left. >> Problem: >> With the arrow keys, in order to show the chart actually scrolling, it >> runs the DrawChart and RedrawTools over and over, one day (bar) at a >> time. This looks really rickety, and moves so slow. Watching it redraw >> each time is a flickering hodge-podge. It would be nice if the chart >> would scroll smoothly and quickly. >> As for scrolling with the mouse, I'd like it to actually show the bars >> scrolling, also smoothly and as quick as the mouse is being moved, >> while the mouse is being moved. Right now, I don't do any of the >> redraw with the mouse until it has stopped at the new location, >> because of the flickering issue. There is just all these redraws. >> Because I have purchased programs that seem to do this without any >> problem, I believe it should be possible to do the same with my >> project. Yet, I'm wondering if this is a VB6 problem, and that I'd >> have to program with C to achieve the above. >> And yes, I have a decently quick computer and graphics card, so that's >> not the problem. >> Any suggestions, tips and otherwise? >> Thanks. >> Webbiz >If all you want to do is move the image about when scrolled another option >is to put a very big picture box inside a much smaller picture box, plot >your stuff on the large one then with scroll bars you can move the whole box >but only the part visible through the smaller box would be seen. >Dave O.
Unfortunately, that would be one very large picturebox. The chart may show only 120 price bars, but if all the price bars are drawn ahead of time on that larger picturebox, you'd be talking a minimum of 3000 bars. Thanks. Webbiz
|
Sun, 13 May 2012 12:27:18 GMT |
|
 |
Webbi #15 / 25
|
 Wanted: Tips on Flicker-Free Draw Scrolling
On Tue, 24 Nov 2009 13:02:22 +0000, Dee Earley Quote:
>> rolling with the mouse, I'd like it to actually show the bars >> scrolling, also smoothly and as quick as the mouse is being moved, >> while the mouse is being moved. Right now, I don't do any of the >> redraw with the mouse until it has stopped at the new location, >> because of the flickering issue. There is just all these redraws. >> Because I have purchased programs that seem to do this without any >> problem, I believe it should be possible to do the same with my >> project. Yet, I'm wondering if this is a VB6 problem, and that I'd >Firstly, use double buffering so you don't draw bits at a time. >You draw the data to an off screen buffer, then draw when needed. >Even with this, I was getting some flickering as VB insisted on >redrawing some parts of the screen in WM_PAINT before firing the Paint >event, despite me eating the WM_ERASEBACKGROUND message. >I ended up handling WM_PAINT myself then passing direct to the paint event: > Case WM_PAINT > 'We handle WM_PAINT ourselves as VB6 seems to explicitly draw the >background in its handler > hDC = BeginPaint(hWnd, PaintInfo) > GraphFrame_Paint > EndPaint hWnd, PaintInfo > 'We've handled it so VB doesn't do anything further > SubClassed_WindowProc = 0 > Handled = True
Forgive my inexperience, but exactly where did you place this Select...Case code? Thx. Webbiz
|
Sun, 13 May 2012 12:30:00 GMT |
|
|
Page 1 of 2
|
[ 25 post ] |
|
Go to page:
[1]
[2] |
|