Re: Which component to use to display mathematical graphs with VB6



On 27 Dec, 21:49, Stefan Mueller <seekw...@xxxxxxxxx> wrote:

Question 1: To display the graphical stuff in a
window I guess that I take a normal Form (Project
- Add Form - Form - Open). Correct?

Yes. Your code can then draw into that Form's client area (the area
inside its borders) or alternatively into a PictureBox that you can
place on the Form.

Question 2:
Which component should I use to draw my mathematical
graphs as fast as possible (several times per second)?

I'm not sure what you mean by "which component". If you mean "what can
I use to actually draw my graph" I would suggest that you initially
look at the native VB Pset method (to draw a single dot) and the
native VB Line method to draw a line. The native VB methods are fairly
easy to use but are usually a bit slower than the alternative API
methods (SetPixel and LineTo for example). Much depends on how deeply
you are prepared to look into this but if you don't mind a bit of
extra work and a slightly steeper learning curve I would suggest that
you use the GDI drawing methods, partly because they are generally a
bit faster but also because they offer you a greater choice of
functions. For example, the GDI has a PolyLine method which is
generally very fast at drawing a set of many lines in one call using a
set of data points whereas the native VB drawing methods do not have
the equivalent of PolyLine.

Question 3:
How can I display my mathematical graphs
full screen without a border?

Do you mean you want your graph to cover all of the available screen
area leaving just the Windows task bar visible, or do you want it to
cover the entire screen including covering the Windows task bar? Both
are possible.

Question 4:
Is it also possible to have e.g. X-axis and Y-axis
or some small pictures fix drawed in front of my
graphs? The axes or the small pictures should always
be visible while drawing the mathematical graphs
behind them as if they would be stuck on the display
itself.

Yes. If the y and y axis data covers all or part of the drawing area
of the graph (a set of grid lines for example) you would normally draw
that first and then draw your graph lines over the top of it, but if
it is not inside the graph drawing area (perhaps just at the left and
bottom edges) then you can draw it just once because your graph data
will never be drawn on top of it.

As far as your small pictures are concerned you can use small
PictureBoxes placed on the Form (or placed inside the main Picture so
that the main PictureBox is their container if you are drawing to a
PictureBox instead of to the Form). In such a case your drawn graph
lines will automatically go "underneath" the small pictures.
Alternatively (instead of using small picture boxes) you can draw your
graph first and then draw your small pictures over the top of it
(using the native VB PaintPicture method or the alternative StretchBlt
method if you are using the API for your drawings). One point to note
if you are using the fast GDI PolyLine method to draw your graph or
parts of your graph is that having a small PictureBox (or any other
control) anywhere in the drawing area where it would cover even a
pixel or two of the any part of the PolyLine drawing will on some
machines result in PolyLine slowing down a great deal, almost to a
crawl by comparison. There are ways to overcome this but the easiest
and quickest way is to use the alternative "draw the small picture on
top of the graph" method rather than using small PictureBoxes. This
GDI PolyLine slowdown is a result of the system drawing the lines in
software if part of any one of them touches a Control in the drawing
area (at standard settings) rather than passing PolyLine on to the
graphics card hardware (on machines which have graphics cards with
accelerated 2D graphics) and so it does not apply to Vista machines,
which draw all the lines relatively slowly in software anyway because
Vista disables the graphics card's accelerated 2D hardware.

Personally if you are just starting out on this stuff, as it appears
you are, I would stick (at least initially) to using the relatively
simple native VB drawing methods into a VB PictureBox. You'll probably
be pleasantly surprised at how fast even the native VB methods can
draw graphs.

Mike



.



Relevant Pages

  • Re: Anchors and Objects
    ... Now drawing a line is no big deal. ... your main display PictureBox and once into a hidden Autoredraw PictureBox. ... PictureBox using a draw width two pixels greater than the draw width you ...
    (microsoft.public.vb.general.discussion)
  • Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
    ... When the user moves the scroll bar you just need to compare the start and end points of the "already drawn" data and compare it to the new required start and end points and blit the appropriate "already drawn" part into its new position and then clear the rest of the graph and draw the new data points. ... The total amount of blitting is the same of course, because with either method you need to blit the full width of the graph, but the number of lines you need to draw is less because you are drawing only the newly required lines. ... Personally when drawing graphs consiting of single pixel thickness lines I usually I opt for the simplicity of clearing the entire graph and drawing the entire new set of data on the grounds that drawing single pixel thickness lines is usually very fast. ...
    (microsoft.public.vb.general.discussion)
  • Re: Polygon API in a VB picturebox does not draw anything?
    ... but I have already tried to call the Refresh method and it does ... Does the pen need to be compatible with the dc it is drawing on, ... >> I'am trying to draw lines in a VB picturebox using Polygon API instead ...
    (microsoft.public.vb.winapi.graphics)
  • Re: Inside PictureBox questions
    ... Mostly fine except you don't need to explicitly draw the image in the Paint ... PictureBox is for drawing images with.... ... Find great Windows Forms articles in Windows Forms Tips and Tricks ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
    ... I am drawing a graph ... horizontal scroll bar. ... Try drawing into a backbuffer first. ... One very easy way of doing this is to simply set the Autoredraw property of the PictureBox to True, ...
    (microsoft.public.vb.general.discussion)