# Polyline with rounded edges - Polyline with solid and dashed lines

Hello,
I have two similar questions/problems:
First:
How can I create a polyline with rounded edges?
Second:
How can I create a polyline with solid horizontal lines and dashed vertical lines (crooked lines dont occure)?

For both lines I need a Funciton or something similar with a Window-Handle hWnd to work (click, copy etc.) with the lines later
Bye
Ramoni
Asked:
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Business Systems Analyst , ex-Senior Application EngineerCommented:
Try below to create some rounded edges, etc:

Private Declare Function Arc Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function Pie Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function RoundRect Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As Any, ByVal nCount As Long) As Long
Private Type POINT
X As Long
Y As Long
End Type

Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'Set graphical mode to persistent
Me.AutoRedraw = True
'Draw to arcs
Arc Me.hdc, 0, 0, 100, 100, 100, 50, 50, 100
Arc Me.hdc, 49, 49, 149, 149, 49, 99, 99, 49

Ellipse Me.hdc, 133, 163, 63, 129
Rectangle Me.hdc, 150, 180, 300, 250
RoundRect Me.hdc, 160, 200, 230, 100, 25, 25

Dim poly(1 To 4) As POINT
poly(1).X = 225
poly(1).Y = 230
poly(2).X = 215
poly(2).Y = 260
poly(3).X = 300
poly(3).Y = 310
poly(4).X = 370
poly(4).Y = 195
Polygon Me.hdc, poly(1), 4
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Hello,
thats not what I'm looking for:
Please read my question again: I need a Polygon with rounded edges: My data-source is a type like your POINT...
Bye
Ramoni
Business Systems Analyst , ex-Senior Application EngineerCommented:
>>Polygon with rounded edges
Can send me an image example, i have no idea what you gonna create. Try find my email from my profile. Do to indicate Q_20774366 in your email subject.

regards
Business Systems Analyst , ex-Senior Application EngineerCommented:
Try save this code as a vb form document, then put your picture into the picture1 control:

VERSION 5.00
Begin VB.Form Form3
BorderStyle     =   0  'None
ClientHeight    =   7425
ClientLeft      =   45
ClientTop       =   330
ClientWidth     =   10440
LinkTopic       =   "Form3"
MaxButton       =   0   'False
MinButton       =   0   'False
ScaleHeight     =   7425
ScaleWidth      =   10440
ShowInTaskbar   =   0   'False
StartUpPosition =   1  'CenterOwner
Begin VB.PictureBox Picture1
Height          =   7335
Left            =   120
Picture         =   "Form3.frx":0000
ScaleHeight     =   7275
ScaleWidth      =   9195
TabIndex        =   0
Top             =   0
Width           =   9255
End
Begin VB.Menu mnuPopUp
Caption         =   "mnuPopUp"
Visible         =   0   'False
Begin VB.Menu item1
Caption         =   "item1"
End
Begin VB.Menu item2
Caption         =   "item2"
End
End
Begin VB.Menu mnuPop
Caption         =   "mnuPop"
Visible         =   0   'False
Begin VB.Menu item3
Caption         =   "item3"
End
Begin VB.Menu item4
Caption         =   "item4"
End
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long

Private Declare Function RoundRect Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long

Const RGN_AND = 1
Const RGN_COPY = 5
Const RGN_OR = 2
Const RGN_XOR = 3
Const RGN_DIFF = 4

Private Sub Form_Load()
Dim rgn(4) As Long, drawRgn As Long

Me.ScaleMode = vbPixels
Picture1.ScaleMode = vbPixels
Picture1.AutoRedraw = True
Me.BackColor = RGB(155, 223, 252)

'rgn(0) = RoundRect(Picture1.hdc, 152, 215, 193, 430, 8, 8)
'rgn(1) = RoundRect(Picture1.hdc, 152, 330, 486, 464, 58, 58)
'rgn(2) = RoundRect(Picture1.hdc, 252, 240, 340, 464, 28, 28)
'rgn(3) = RoundRect(Picture1.hdc, 193, 180, 252, 335, 15, 15)
'rgn(4) = RoundRect(Picture1.hdc, 340, 180, 500, 335, 15, 15)

rgn(0) = CreateRoundRectRgn(153, 215, 197, 430, 8, 8)
rgn(1) = CreateRoundRectRgn(153, 330, 486, 464, 58, 58)
rgn(2) = CreateRoundRectRgn(252, 240, 340, 464, 28, 28)
rgn(3) = CreateRoundRectRgn(197, 180, 252, 337, 15, 15)
rgn(4) = CreateRoundRectRgn(340, 180, 500, 337, 15, 15)

drawRgn = rgn(0)
CombineRgn drawRgn, drawRgn, rgn(1), RGN_OR
CombineRgn drawRgn, drawRgn, rgn(2), RGN_OR
CombineRgn drawRgn, drawRgn, rgn(3), RGN_DIFF
CombineRgn drawRgn, drawRgn, rgn(4), RGN_DIFF

SetWindowRgn Picture1.hWnd, drawRgn, True

End Sub

Hope this give you idea on how to do it.

cheers
Business Systems Analyst , ex-Senior Application EngineerCommented:
oh, the more difficult the shape to create, the more difficult to adjust the points!
Author Commented:
Oh,
this looks like very very difficult for me (I'm a beginner in programing)
to get all the points, because i dont know of how many points this polygon consists,
and how can i identify the pologon on the screen by a mouse click to copy it or get further preferences of it????
Bye
Business Systems Analyst , ex-Senior Application EngineerCommented:
Or you can try use the TransparentBlt API. Where the last parameter determine what color you want to make it as transparent.

Example:

Private Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean

Private Sub Form_Activate()
DoEvents
TransparentBlt Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbWhite
Picture2.Refresh
End Sub

Private Sub Form_Load()
Picture1.ScaleMode = vbPixels
Picture2.ScaleMode = vbPixels
Picture2.Refresh
End Sub

'To do the test, put your picture into Picture1 control.

regards
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.