Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As LongPrivate Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Command1_Click()
    Dim wscreen As Long
    Dim hscreen As Long
    Dim w As Long
    Dim h As Long
    Dim i As Long
    Picture1.Cls
    wscreen = screen.Width / screen.TwipsPerPixelX
    hscreen = screen.Height / screen.TwipsPerPixelY
    w = Picture1.ScaleWidth
    h = Picture1.ScaleHeight
    hdcscreen = GetDC(0)
    i = StretchBlt(Picture1.hdc, 0, 0, w, h, hdcscreen, 0, 0, wscreen, hscreen, vbSrcCopy)End SubPrivate Sub Command2_Click()
EndEnd SubPrivate Sub Command3_Click()
    Dim filename As String
    With dlgcommondialog
        .Flags = cdlOFNOveriteprompt
        .dialogtitle = "另存为"
        .cancelerror = False
        'to do: 设置commondialog的标志和属性
        .Filter = "位图文件(*.bmp)|*.bmp"
        .showsave
    End With
    filename = dlgcommondialog.filename
    Open filename For Output As #1
    Print #1, Picture1.Picture
    Close #1
End Sub
抓到图之后 放在picture1中 怎么把这个存为图片文件呢 郁闷ing 谢谢大家的帮助

解决方案 »

  1.   

    savepicture picture1.image "c:\XXX.bmp"
      

  2.   

    savepicture 没这个东东吧 而且 最后加不了存盘路径
      

  3.   

    试了 可以我把他用在 图标抓取里 可得到的图片 是蛋黄色的一个方框哎Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
    Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
    Private Sub iconout()
        Dim x As Integer
        outicon.Cls
        '提取图标
        hIcon = ExtractIcon(0, filename.Text, 0)
        '在图片控件中显示图标
        x = DrawIcon(outicon.hdc, 5, 5, hIcon)
    End SubPrivate Sub Command1_Click()
    End
    End SubPrivate Sub Command2_Click()
       Dim filename As String
        With dialog
            .Flags = cdlOFNOveriteprompt
            .DialogTitle = "另存为"
            .CancelError = False
            'to do: 设置commondialog的标志和属性
            .Filter = "位图文件(*.bmp)|*.bmp"
            .ShowSave
        End With
            SavePicture outicon.Image, dialog.filename
    End SubPrivate Sub filename_Change()
     Dim icons As Integer
        If filename.Text = "" Then
            Exit Sub
        End If
            icons = ExtractIcon(hInst, filename, -1)
            iconout
    End SubPrivate Sub openfile_Click()
        dialog.ShowOpen
        filename.Text = dialog.filename
    End Sub
      

  4.   

    Picture1.Autoredraw = True
    ...'''这里抓图
    Picture1.refresh savepicture Picture1.picture ,"c:\1.bmp"