|
-
Oct 28th, 2001, 05:57 PM
#1
Thread Starter
Fanatic Member
Draw a line
Is there any simple function to draw a line from point a to point b?
-
Oct 28th, 2001, 06:15 PM
#2
Code:
MoveToEx(hDC, x1,y1,NULL);
LineTo(hDC,x2,y2);
-
Oct 28th, 2001, 06:30 PM
#3
Frenzied Member
If you're using Windows, there's the GDI function Line(). I forget the specifics of the parameters though.
Harry.
"From one thing, know ten thousand things."
-
Oct 28th, 2001, 07:12 PM
#4
transcendental analytic
I don't think there is a Line() function although there is LineTo, Polyline, PolylineTo
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 28th, 2001, 07:40 PM
#5
You could create your own Line() function with MoveToEx, and LineTo.
Code:
void Line(HDC hDC, int x1, int y1, int x2, int y2)
{
MoveToEx(hDC,x1,y1,NULL);
LineTo(hDC,x2,y2);
}
-
Oct 28th, 2001, 07:41 PM
#6
Frenzied Member
There isn't?... Umm... oh.... umm... well okay then ... I could have sworn there was. Never mind.
Harry.
"From one thing, know ten thousand things."
-
Oct 28th, 2001, 08:13 PM
#7
Thread Starter
Fanatic Member
Ok, thanks. Does this draw the line on the screen, or in the window? I was trying to create a class with some shapes (rectangle, point, segment, etc) and I didn't see any line being drawn.
-
Oct 28th, 2001, 08:22 PM
#8
transcendental analytic
It draws the line on a specified device context, (check out msdn in GDI programming)
If you want to draw to the window, you pass a device context handle you retrieve with GetDC(hwnd) where hwnd is the window handle
If you want to draw directly on the screen you pass the handle of GetDC(0)
If you want to draw lines with doublebuffering you create a memory dc with CreateCompatibleDC and pass that, then update the window with bitblt as needed.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|