• 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

  • 相关阅读:
    基于小程序开发的藏书馆
    picker(级联)组件及组件封装经验
    秒杀组件开发-可实现多种倒计时功能
    async/await 与 generator、co 的对比
    nodejs项目总结
    小程序开发小结-线下服务器域名部署等
    性能提速:debounce(防抖)、throttle(节流/限频)
    vuex数据管理-数据模块化
    vue 项目其他规范
    vue路由管理-保留滚动位置功能、按需加载模块名自定义
  • 原文地址:https://www.cnblogs.com/Dincat/p/13457787.html
Copyright © 2020-2023  润新知