English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

改變下列程式的Form1.ScaleMode=7 為啥填滿顏色的地方會不ㄧ樣
如何才可解決
可以加的註解嗎 ? GetPixel(Form1.hdc, 8, 5)==>這一行是啥意思
----------------------------------------------------------------------------------------------------------
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 GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long

Private Sub Form_Activate()
Line (5, 5)-(9, 1)
Line (9, 1)-(10, 10)
Line (10, 10)-(8, 6)
Line (8, 6)-(5, 5)
mBrush = CreateSolidBrush(RGB(255, 0, 0))
SelectObject Form1.hdc, mBrush
Form1.ScaleMode = vbPixels
ExtFloodFill Form1.hdc, 8, 4, GetPixel(Form1.hdc, 8, 5), &H1
Form1.Picture = Form1.Image
DeleteObject mBrush
End Sub

Private Sub Form_Load()
Form1.ScaleMode = 3
Form1.AutoRedraw = True
End Sub

2006-10-10 18:55:25 · 1 個解答 · 發問者 .... 2 in 電腦與網際網路 程式設計

1 個解答

'看來戊大可能沒空,我越俎代庖幫他回一下好了XD(API函數宣告就不再寫上,免得爆掉)Private Sub Form_Activate()    Line (5, 5)-(9, 1)    Line -(10, 10)    Line -(8, 6)    Line -(5, 5)    mBrush = CreateSolidBrush(RGB(255, 0, 0))    SelectObject hdc, mBrush    'Form1.ScaleMode = vbPixels '此行Mark掉    'ScaleMode=7表示表單每個點是以公分計,而ScaleMode=3則為像素,但ExtFloodFill這個函數所要求傳入的XY值必須是像素,所以當你改成,ScaleMode=7時,XY這點就沒有落到你要的區域,而會落在外面,當然塗色就會塗在外面了,所以只要把公分轉成像素就行    Dim sX&, sY&    '像素X=公分X*567\Screen.TwipsPerPixelX    sX = 8 * 567 \ Screen.TwipsPerPixelX    '像素Y=公分Y*567\Screen.TwipsPerPixelY    sY = 4 * 567 \ Screen.TwipsPerPixelY    '至於GetPixel這函數是要擷取螢幕上某一點的顏色值,在此可用VB內建的Point取代(GetPixel(Form1.hdc, 8, 5)改成Point(8, 5)    ExtFloodFill hdc, sX, sY, Point(8, 5), &H1    Picture = Image    DeleteObject mBrush    '這樣懂了嗎?若還不了解,請參考 ExtFloodFill方法 ,或是上 Google 查吧!End SubPrivate Sub Form_Load()    ScaleMode = 7    AutoRedraw = TrueEnd Sub

2006-10-11 11:51:30 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers