Re: Drawing a line
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Sun, 16 Apr 2006 23:25:03 -0400
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.Joseph M. Newcomer [MVP]
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.Joseph M. Newcomer [MVP]
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.
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
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
.
- References:
- Drawing a line
- From: Ed
- Re: Drawing a line
- From: Joseph M . Newcomer
- Re: Drawing a line
- From: Ed
- Drawing a line
- Prev by Date: Re: Program can't display a jpeg on a Dialog with default CDialog::OnPaint()
- Next by Date: I am new to OOP
- Previous by thread: Re: Drawing a line
- Next by thread: Re: Drawing a line
- Index(es):
Relevant Pages
|