Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to draw a Line with out using Line Control ?

Status
Not open for further replies.

nsskumar123

Technical User
Sep 9, 2003
7
IN
I need to draw a line using API.
How to do that?

with cheers,
kumar
 
MoveToEx will set the current point to the start of the line and LineTo will draw a line from the current to the specified point.
Code:
Declare Function LineTo Lib "gdi32.dll" _
(ByVal hdc As Long, ByVal x As Long, _
ByVal y As Long) As Long

Declare Function MoveToEx Lib "gdi32.dll" _
(ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
lpPoint As POINT_TYPE) As Long 

Type POINT_TYPE
  x As Long
  y As Long
End Type

'Draw a red line from (0,40) to (100,50) on Form1
Dim udtPT As POINT_TYPE  'receives the former current point
Dim lngRtn As Long  'return value

'set the drawing color of Form1 to red
Form1.ForeColor = RGB(255, 0, 0)
'set the current point to (0,40)
lngRtn = MoveToEx(Form1.hdc, 0, 40, udtPT)  
'Draw the line to (100,50)
lngRtn = LineTo(Form1.hdc, 100, 50)
Paul Bent
Northwind IT Systems
 
thanks Paul Bent for ur reply.

but I want to draw the line above the Rich text box or any (list box or list view control).
I tried the same thing but the line which i have drawn is going behind the control(Rich text box).
It's not visibling in foreground.
How to solve this problm?
 
I don't think you can with LineTo because a RichTextBox doesn't have a device context afaik. Perhaps someone else has a trick for doing this.

Paul Bent
Northwind IT Systems
 

How about a crayon?[lol]
I don't know what you mean by "above", but you could create a frame control and set it's height to something very minimal like 50, and play with the Appearance, BorderStye and Backcolor properties.
 
It's not going 'behind' the RTB; it isn't being drawn at all...

You can see this if you change the form's ClipControls property to false
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top