文書番号: 410503
最終更新日: 1999/03/23
VERSION 2.00 Begin Form frmTriangle Caption = "Triangle" Height = 2775 Left = 975 LinkTopic = "Form1" ScaleHeight = 2400 ScaleWidth = 1740 Top = 1230 Width = 1830 Begin CommandButton cmdPaint Caption = "&Paint" Height = 495 Left = 360 TabIndex = 0 Top = 1680 Width = 1095 End End Option Explicit Declare Function FloodFill Lib "GDI" (ByVal hDC As Integer, ByVal x As Intege r, ByVal y As Integer, ByVal lColor As Long) As Integer Declare Function CreateSolidBrush Lib "GDI" (ByVal lColor As Long) As Integer Declare Function SelectObject Lib "GDI" (ByVal hDC As Integer, ByVal hObject As Integer) As Integer Declare Function DeleteObject Lib "GDI" (ByVal hObject As Integer) As Integer Sub cmdPaint_Click () Dim n As Integer Dim nS As Integer nS = Me.ScaleMode Me.ScaleMode = 3 Me.Line (10, 10)-(100, 100), 0 Me.Line -(100, 10), 0 Me.Line -(10, 10), 0 n = Paint(CInt(Me.hDC), 50, 25, RGB(0, 192, 0), 0) Me.CurrentY = 100 If n = 0 Then Print "error" End If Me.ScaleMode = nS End Sub ' Paint 関数 ' ' 機能 指定したエリアの塗りつぶしをおこないます。 ' 構文 Paint(hDC, x, y, PaintCol, BorderCol) ' 解説 引数 hDC に塗りつぶしをおこなうコントロールのデバイス コンテキス ' トを、引数 x および y にピクセル単位の座標を、引数 PaintCol に塗 ' りつぶす色を、引数 BorderCol に境界色を指定してください。 ' 正常終了の場合には 0 以外の値が返ります。 ' Function Paint (hDC As Integer, x As Integer, y As Integer, Paintcol As Long, Bordercol As Long) As Integer Dim hBrush As Integer Dim hBackBrush As Integer Dim n As Integer hBrush = CreateSolidBrush(Paintcol) hBackBrush = SelectObject(hDC, hBrush) Paint = FloodFill(hDC, x, y, Bordercol) n = DeleteObject(SelectObject(hDC, hBackBrush)) End Function
Keywords: KBHOWTO VB2 塗りつぶし KB410503
Technology: kbAudDeveloper kbVBSearch