VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)

VB爱好者乐园(VBGood)

 找回密码
 立即注册
搜索
查看: 548|回复: 2

BITBLT实例讨论求助

[复制链接]
发表于 2017-6-13 21:16:51 | 显示全部楼层 |阅读模式
模块
Option Explicit

Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long
Public 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

窗体
Option Explicit
Dim ScreenhDC As Long
Dim ret

Private Sub command1_Click()
    Form1.Hide
    DoEvents
    ScreenhDC = GetDC(0)
    Picture1.Height = Screen.Height
    Picture1.Width = Screen.Width
    ret = BitBlt(Picture1.hDC, 0, 0, Screen.Width, Screen.Height, ScreenhDC, 0, 0, vbSrcCopy)
    ret = BitBlt(Picture2.hDC, 0, 0, Picture2.Width, Picture2.Height, Picture1.hDC, 0, 0, vbSrcCopy)
    ret = ReleaseDC(0, hDC)
    Form1.Show
    Command2.Enabled = True
  
   
End Sub

Private Sub Command2_Click()
    Set Picture1.Picture = Picture1.Image
    On Error GoTo trip
    CommonDialog1.ShowSave
    SavePicture Picture1.Picture, CommonDialog1.FileName
trip: End Sub

Private Sub Command3_Click()
    End
End Sub

Private Sub Command4_Click()
    Picture2.Cls
    Picture1.Cls
    Command2.Enabled = False
End Sub

Private Sub Form_Load()
    HScroll1.Min = 0
    HScroll1.Max = Screen.Width
    HScroll1.SmallChange = 15
    HScroll1.LargeChange = 1000
    VScroll1.Min = 0
    VScroll1.Max = Screen.Height
    VScroll1.SmallChange = 15
    VScroll1.LargeChange = 1000
End Sub

Private Sub HScroll1_Change()
        ret = BitBlt(Picture2.hDC, 0, 0, Picture2.Width, Picture2.Height, Picture1.hDC, HScroll1.Value / 33.3, 0, vbSrcCopy)
        Picture2.Refresh
End Sub

Private Sub VScroll1_Change()
        ret = BitBlt(Picture2.hDC, 0, 0, Picture2.Width, Picture2.Height, Picture1.hDC, 0, VScroll1.Value / 37, vbSrcCopy)
        Picture2.Refresh
End Sub

 楼主| 发表于 2017-6-13 21:18:58 | 显示全部楼层
本帖最后由 lwjohn 于 2017-6-13 21:26 编辑

窗体布局
4个命令控件
2个图片框
2个滚动条
1个通用会话框
回复 支持 反对

使用道具 举报

发表于 2017-6-18 15:48:06 | 显示全部楼层
具体是什么问题?
说明清楚

还有把整个文件打包放上,方便测试,放代码是不行的,
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

文字版|手机版|小黑屋|VBGood  

GMT+8, 2017-9-26 01:06

VB爱好者乐园(VBGood)
快速回复 返回顶部 返回列表