Re: Drawing a line



The place where you create new classes is where you specify the base class, so you would
specify CStatic as the base class.

And a complete specification would give the line width,

Also, the question about how you create a static control with a 256-bit-wide client area
is important. You have not indicated how you have done this.
joe

On Mon, 17 Apr 2006 02:21:08 GMT, "Ed" <eddie@xxxxxxxxxx> wrote:

I am totally new to graphics in VC++ 6.0 so please bear with me.
What is stated below is exactly what I want to do.
But, I want the line to appear inside of a picture box.
My application is dialog based.
How do I create a "subclass" of CStatic?
I see where I can create new classes in the class wizzard but no subclasses.


"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:aor042d4nn1rvappf5msi3p7ducq9ftig6@xxxxxxxxxx
This is not a particularly good description, since you need to say
something about the
nature of the "line".

For example, if you want a "line" that is 256 pixels long where each pixel
has a different
value, the simplest mechanism would be

Create a subclass of CStatic:

class CMyDrawing : public CStatic {
...
}

using the ClassWizard. Then add an OnPaint handler

void CMyDrawing::OnPaint()
{
CPaintDC dc(this);
int y = ...some value of where you want this horizontal line to appear
BYTE bytes[256];
...load up the array of bytes, or have the array be in the class as a
... class variable

for(int i = 0; i < 256; i++)
{
dc.SetPixel(i, y, RGB(bytes[i], 0, 0);
}
}

This draws a 1-pixel horizontal line where every pixel has a color based
on the value in
bytes[i]

Note the advice about looking at the Scribble tutorial; you need to get
some familiarity
with how all graphics are done.
joe

On Thu, 13 Apr 2006 12:35:27 GMT, "Ed" <eddie@xxxxxxxxxx> wrote:

I have a string of 256 numbers ranging in value from 0 to 255.
Lets say I want to draw a horizontal Red 256 point line of these points
with
each point a shade of red equal to the value of each point.
I created a picture box which will accommodate the length of this line
called IDC_PIC1
How do I do this in a Visual C++ 6 MFC App.
Thanks in advance.

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
--
NewsGuy.Com 30Gb $9.95 Carry Forward and On Demand Bandwidth

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
--
NewsGuy.Com 30Gb $9.95 Carry Forward and On Demand Bandwidth
.



Relevant Pages

  • Re: why make non-pure virtual functions?
    ... > jeffc wrote: ... > You have to specify it as virtual in the base class. ... My point is you still have to look at the base class regardless of how it's ... defined in the subclass. ...
    (comp.lang.cpp)
  • Re: page is too wide even
    ... You have nested tables, so you need to specify each table as 100%, and then ... specify the width percentage for each cell individually. ... search for "width=" and change the pixel value to a %. ... I'm getting ready to sign off, Susan, but if you need additional help, feel ...
    (microsoft.public.frontpage.programming)
  • OpenGL Correctness tips
    ... To obtain exact two-dimensional rasterization, carefully specify both the ... reliably fills the lower-left pixel of the viewport, and glRasterPos2i(0, ... model matrix because this cancels my 0.375 translation. ...
    (comp.graphics.api.opengl)
  • Re: Pythonic use of CSV module to skip headers?
    ... Michael> cumbersome idiom every single time. ... In my example I flubbed and failed to specify the delimiter to the ... You can create a subclass of DictReader that plucks the first line out as a ...
    (comp.lang.python)
  • Region.IsEmpty() without a Graphics object
    ... to specify a Graphics object, i.e. an override that specifies the pixel ... determining whether not the sum of width * height for all rectangles ...
    (microsoft.public.dotnet.framework.drawing)