none
[VB6]API不規則圖形填色 RRS feed

  • 問題

  • 但不知怎麼,都不能填色...

    原始檔如下:
    Private Sub cmdP_Click()

    ReDim myX(ss), myY(ss) '設定動態陣列
      Dim mBrush As Long
      mBrush = CreateSolidBrush(vbred)
      SelectObject Pic1.hdc, mBrush
     
        For i = 0 To ss - 1
          myX(i) = MainFrame.List1.List(i) '讀入另一個表單所畫的圖的點座標
          myY(i) = MainFrame.List2.List(i)
        Next i
       
       Pic1.DrawWidth = 2
       a = 0
        While a < (ss - 1)
           Pic1.Line (myX(a), myY(a))-(myX(a + 1), myY(a + 1)), vbBlue '畫線
           a = a + 1
        Wend
          Pic1.Line (myX(a), myY(a))-(myX(0), myY(0)), vbBlue '將最後一點和第一點連起來
         
       aa = Int((tMaxX - tMinX) / 2 + tMinX)  'tmaxX.tminX.tMaxY,tminY分別是把之前另一表單所畫的圖先做完大小比較.
       bb = Int((tMaxY - tMinY) / 2 + tMinY)  'aa bb是要算現在這個表單的pic1的中心點
       Print "aa=" & aa
       Print "bb=" & bb
      
      
        FloodFill Pic1.hdc, aa, bb, vbBlue '填色在多邊形裡
        DeleteObject mBrush
      end sub
    ----------------------------------------------------------------
    而在formload裡有設
    Pic1.Scale (tMinX, tMinY)-(tMaxX, tMaxY)
    最開頭也有宣告
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Declare Function FloodFill Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    感覺卡在這一行
     FloodFill Pic1.hdc, aa, bb, vbBlue

    可以幫幫我嗎?謝謝!

    2009年4月29日 上午 07:22

解答

所有回覆