BeginPath,EndPath API函数在Visual Basic中有何用途?

解决方案 »

  1.   

    Public Delcare Function BeginPath Lib "gdi32" Alias "BeginPath" (ByVal hdc As Long) As Long
    Public Delcare Function EndPath Lib "gdi32" Alias "EndPath" (ByVal hdc As Long) As Long【函数】
    BeginPath【操作系统】
    Win9X:Yes
    WinNT:Yes【声明】
    BeginPath Lib "gdi32" Alias "BeginPath" (ByVal hdc As Long) As Long【说明】  启动一个路径分支。在这个命令后执行的GDI绘图命令会自动成为路径的一部分。对线段的连接会结合到一起。设备场景中任何现成的路径都会被清除。参考下表,其中列出的函数都可记录到路径中 【返回值】  Long,非零表示成功,零表示失败。会设置GetLastError 【其它】
    【参数表】
      hdc ------------  Long,欲在其中记录的设备场景
      合法的路径函数
      函数
      Windows NT
      Windows 95
      函数
      Windows NT
      Windows 95
      AngleArc
      Yes
      No
      Arc
      Yes
      No
      ArcTo
      Yes
      No
      Chord
      Yes
      No
      Ellipse
      Yes
      No
      ExtTextOut
      Yes
      Yes
      LineTo
      Yes
      Yes
      MoveToEx
      Yes
      Yes
      Pie
      Yes
      No
      PolyBezier
      Yes
      Yes
      PolyBezierTo
      Yes
      Yes
      PolyDraw
      Yes
      No
      Polygon
      Yes
      Yes
      Polyline
      Yes
      Yes
      PolylineTo
      Yes
      Yes
      PolyPolygon
      Yes
      Yes
      PolyPolyline
      Yes
      Yes
      Rectangle
      Yes
      No
      RoundRect
      Yes
      No
      TextOut
      Yes
      Yes【函数】
    EndPath【操作系统】
    Win9X:Yes
    WinNT:Yes【声明】
    EndPath Lib "gdi32" Alias "EndPath" (ByVal hdc As Long) As Long【说明】  停止定义一个路径。如执行成功,BeginPath函数调用和这个函数之间发生的所有绘图操作都会正式成为指定设备场景的路径 【返回值】  Long,非零表示成功,零表示失败。会将GetLastError设置为下述值之一:ERROR_CAN_NOT_COMPLETE 
      或 ERROR_INVALID_PARAMETER 【其它】
    【参数表】
      hdc ------------  Long,设备场景
      

  2.   

    例子:
    Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long
    Private Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long
    Private Declare Function PathToRegion Lib "gdi32" (ByVal hdc As Long) As Long
    Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount 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 DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Sub Form_Click()
        'end..
        Unload Me
    End Sub
    Private Sub Form_Load()
        Dim hRgn As Long
        Const sText = "Click Here!"
        'set the font to 'Times New Romen, size 72'
        Me.FontName = "Times New Roman"
        Me.FontSize = 72
        'set the backcolor to Red
        Me.BackColor = vbRed
        'open a path bracket
        BeginPath Me.hdc
        'draw the text
        TextOut Me.hdc, 0, 0, sText, Len(sText)
        'close the path bracket
        EndPath Me.hdc
        'convert the path to a region
        hRgn = PathToRegion(Me.hdc)
        'set the Window-region
        SetWindowRgn Me.hWnd, hRgn, True
        'destroy our region
        DeleteObject hRgn
    End Sub