|
-
Aug 4th, 2001, 03:49 AM
#1
Thread Starter
Fanatic Member
How to draw a Line.
Hi I would like to know how to draw a Line in VB using GDi? I already know how to create a line... Just want to know how to create a line in Code.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Aug 4th, 2001, 04:05 AM
#2
transcendental analytic
Not so complicated, here's a sample that draws a line from x1,y1 to x2,y2, if you want to draw from 2 to another point you don't need to movetoex in between.
Code:
hdc = GetDC(hwnd)
MoveToEx hdc,x1, y1, 0
LineTo hdc, x2, y2
ReleaseDC hwnd, hdc
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.
-
Aug 4th, 2001, 05:57 AM
#3
Thread Starter
Fanatic Member
Missing a bud
It says it's missing GetDC not declared.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Aug 4th, 2001, 06:36 AM
#4
Member
You should declare GDI functions by adding the following code to the General Declerations part.
Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Long) As Long
Declare Function LineTo Lib "gdi32" Alias "LineTo" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function MoveToEx Lib "gdi32" Alias "MoveToEx" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal hwnd As Long, ByVal hdc As Long) As Long
-
Aug 4th, 2001, 07:02 AM
#5
transcendental analytic
You should be able to look up all GDI functions, types and constants in the windows api viewer, it should be in your addin list
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.
-
Aug 4th, 2001, 09:59 PM
#6
PowerPoster
or windows SDK
-
Aug 5th, 2001, 03:11 PM
#7
Thread Starter
Fanatic Member
Not working
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Doesn't work
Anyone?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Aug 6th, 2001, 03:22 AM
#8
transcendental analytic
what doesn't work, what does it say, what do you have?
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.
-
Aug 7th, 2001, 08:14 AM
#9
Frenzied Member
Re: Not working
Originally posted by prog_tom
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Doesn't work
Anyone?
That code will only work in a module...if you're trying to declare it from a form then add Private before each line.
You just proved that sig advertisements work.
-
Aug 7th, 2001, 10:41 AM
#10
PowerPoster
Originally posted by abdul
or windows SDK
Platform SDK is mainly explain for VC++, as for VB, you still need the VB build in API Viewer or download the latest APIViewer from www.AllApi.net
regards,
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
|