Solved

Polyline with rounded edges - Polyline with solid and dashed lines

Posted on 2003-10-22
9
454 Views
Last Modified: 2013-12-26
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
0
Comment
Question by:Ramoni
  • 5
  • 2
9 Comments
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 80 total points
ID: 9604908
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
0
 

Author Comment

by:Ramoni
ID: 9605489
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
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 9605531
>>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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 49

Expert Comment

by:Ryan Chong
ID: 9606042
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
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 9606056
oh, the more difficult the shape to create, the more difficult to adjust the points!
0
 

Author Comment

by:Ramoni
ID: 9627186
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
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 9641217
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now