如何制作这样的画刷:选择一张位图后,在picturebox1h上任意位置点左键即可画出该位图,点一次画一张,请高手赐教!!!!

解决方案 »

  1.   

    弄两个picturebox,打开文件后,装入到picturebox2中,当在1中点的时候,将2的图片bitblt过来。
      

  2.   

    VERSION 5.00
    Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
    Begin VB.Form Form1 
       Caption         =   "Form1"
       ClientHeight    =   6150
       ClientLeft      =   60
       ClientTop       =   450
       ClientWidth     =   7380
       LinkTopic       =   "Form1"
       ScaleHeight     =   410
       ScaleMode       =   3  'Pixel
       ScaleWidth      =   492
       StartUpPosition =   3  'Windows Default
       Begin VB.CommandButton Command1 
          Caption         =   "open"
          Height          =   510
          Left            =   5850
          TabIndex        =   2
          Top             =   3990
          Width           =   1320
       End
       Begin MSComDlg.CommonDialog CommonDialog1 
          Left            =   4785
          Top             =   4335
          _ExtentX        =   847
          _ExtentY        =   847
          _Version        =   393216
          CancelError     =   -1  'True
       End
       Begin VB.PictureBox Picture2 
          AutoRedraw      =   -1  'True
          AutoSize        =   -1  'True
          Height          =   1170
          Left            =   1560
          ScaleHeight     =   74
          ScaleMode       =   3  'Pixel
          ScaleWidth      =   149
          TabIndex        =   1
          Top             =   4050
          Visible         =   0   'False
          Width           =   2295
       End
       Begin VB.PictureBox Picture1 
          AutoRedraw      =   -1  'True
          AutoSize        =   -1  'True
          Height          =   3285
          Left            =   180
          ScaleHeight     =   215
          ScaleMode       =   3  'Pixel
          ScaleWidth      =   425
          TabIndex        =   0
          Top             =   105
          Width           =   6435
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Option ExplicitPrivate Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Private Const SRCCOPY = &HCC0020Private Sub Command1_Click()
        On Error GoTo errhandle
        CommonDialog1.ShowOpen
        Picture2.Picture = LoadPicture(CommonDialog1.FileName)
        Exit Sub
    errhandle:
        Err.Clear
    End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        BitBlt Picture1.hDC, CLng(X), CLng(Y), 10, 10, Picture2.hDC, CLng(X), CLng(Y), SRCCOPYEnd SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = 1 Then
            BitBlt Picture1.hDC, CLng(X), CLng(Y), 10, 10, Picture2.hDC, CLng(X), CLng(Y), SRCCOPY
        Picture1.Refresh
        End IfEnd SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Picture1.RefreshEnd Sub上述内容放到记事本中,存成form1.frm,用VB打开运行可见效果。
      

  3.   

    还是用3楼的思路,但不用bitblt这样就可以了
    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Picture1.PaintPicture Picture2.Picture, X, Y
    End Sub
    Picture2的图片将按鼠标位置拷贝到Picture1
      

  4.   

    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = 1 Then
            BitBlt Picture1.hDC, CLng(X), CLng(Y), 10, 10, Picture2.hDC, CLng(X), CLng(Y), SRCCOPY
        Picture1.Refresh
        End If
    End Sub
    提示“子程序或函数BitBlt”未定义错误,如何解决呢?
      

  5.   

    你建了picture1了吗?
    bitblt按俺的要求声明了吗?上面不是有整个文件,直接存成.frm就可以使用了。