我想在窗体中画一条直线,然后在直线的尽头画一个箭头!
    箭头是平时我们看到的那种有封闭区域的,封闭区域里面有黑色的填充色 ,也不知道怎么做,希望大哥指点指点
    也可以告诉我怎么画一个三角形状,里面有填充色,谢谢大哥,帮帮我吧!

解决方案 »

  1.   

    '以下例子用Polygon函数画一个三角形
    '并同时用当前Brush填充(创建新Brush并选进DC,用完后恢复原Brush)
    '其中点的坐标请根据实际情况自己赋值
    '要注意API函数中的坐标为象素
    '一个picturebox,一个commandbuttonOption Explicit
    Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
    Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Type POINTAPI
        x As Long
        y As Long
    End TypePrivate Sub Command1_Click()
        Dim hPen As Long
        Dim hPenOld As Long
        Dim hBrush As Long
        Dim hBrushOld As Long
        
        Dim pt(2) As POINTAPI
        pt(0).x = 20
        pt(0).y = 20
        pt(1).x = 100
        pt(1).y = 20
        pt(2).x = 100
        pt(2).y = 100
        
        Dim 边_color As Long, 填充_color As Long
        边_color = vbBlack
        填充_color = vbRed
        
        hPen = CreatePen(0, 1, 边_color)
        hPenOld = SelectObject(Picture1.hdc, hPen)
        hBrush = CreateSolidBrush(填充_color)
        hBrushOld = SelectObject(Picture1.hdc, hBrush)
        Polygon Picture1.hdc, pt(0), 3
        
        SelectObject Picture1.hdc, hPenOld
        SelectObject Picture1.hdc, hBrushOld
        DeleteObject hPen
        DeleteObject hBrush
    End Sub
      

  2.   

    我晕,怕你看不懂,特意用汉字定义的变量,看不见吗?
    边_color = vbBlack
    填充_color = vbRed
    填充颜色用的红色,你要用黑的,改为vbBlack好了
      

  3.   

    真的是没办法,把Viena都弄晕啦!哈!!