• VB6保存表单图像到文件


    下载FormImageSave - 2.14 KB IntroductionThis是示例代码将VB 6.0的图像形式保存到一个文件中。 BackgroundNormally表单。图像属性只提供图纸和印刷 位图图像的文本。但是如果有图像控制,按钮, 图标等形式,那么这个代码的照片。 使用codeThere是一个过程SaveFormImageToFile自我explainatory。使用API BitBlt形成图像转换为图片,并将其分配给图片框。然后图片框的图像属性用于存储图片使用SavePicture方法。 添加一个单独的图片框、命令按钮的形式属性如下考虑: 隐藏,收缩,复制Code

    Private 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
    
    Public Sub SaveFormImageToFile(ByRef ContainerForm As Form, _
                                   ByRef PictureBoxControl As PictureBox, _
                                   ByVal ImageFileName As String)
      Dim FormInsideWidth As Long
      Dim FormInsideHeight As Long
      Dim PictureBoxLeft As Long
      Dim PictureBoxTop As Long
      Dim PictureBoxWidth As Long
      Dim PictureBoxHeight As Long
      Dim FormAutoRedrawValue As Boolean
      
      With PictureBoxControl
        'Set PictureBox properties
        .Visible = False
        .AutoRedraw = True
        .Appearance = 0 ' Flat
        .AutoSize = False
        .BorderStyle = 0 'No border
        
        'Store PictureBox Original Size and location Values
        PictureBoxHeight = .Height: PictureBoxWidth = .Width
        PictureBoxLeft = .Left: PictureBoxTop = .Top
        
        'Make PictureBox to size to inside of form.
        .Align = vbAlignTop: .Align = vbAlignLeft
        DoEvents
        
        FormInsideHeight = .Height: FormInsideWidth = .Width
        
        'Restore PictureBox Original Size and location Values
        .Align = vbAlignNone
        .Height = FormInsideHeight: .Width = FormInsideWidth
        .Left = PictureBoxLeft: .Top = PictureBoxTop
        
        FormAutoRedrawValue = ContainerForm.AutoRedraw
        ContainerForm.AutoRedraw = False
        DoEvents
        
        'Copy Form Image to Picture Box
        BitBlt .hDC, 0, 0, _
        FormInsideWidth / Screen.TwipsPerPixelX, _
        FormInsideHeight / Screen.TwipsPerPixelY, _
        ContainerForm.hDC, 0, 0, _
        vbSrcCopy
        
        DoEvents
        SavePicture .Image, ImageFileName
        DoEvents
        
        ContainerForm.AutoRedraw = FormAutoRedrawValue
        DoEvents
      End With
    End Sub
    
    Private Sub Command1_Click()
      SaveFormImageToFile frmSaveFormImageToFile, Picture1, "C:Temp.bmp"
    End Sub

    否则,代码将它。图像的兴趣点的形式在VB 6以及控制和图像是新的。历史上这段代码是我第一次上传 本文转载于:http://www.diyabc.com/frontweb/news2457.html

  • 相关阅读:
    传智博客.NET培训第13季 Ajax教程(共十三季) 学习资源
    一些sql语句的常用总结(重要)
    处理oracle的死锁
    Adroid 总结--android ListView美化,个性化更改的属性
    如何远程备份sql server数据库
    VSS (Visual Source Safe 2005) 用法详解
    php插入代码数据库
    PHP之PHP文件引用详解
    需要引入库:vue-resource
    axios调用详解
  • 原文地址:https://www.cnblogs.com/Dincat/p/13457787.html
Copyright © 2020-2023  润新知