您的位置:程序门 -> vb -> 多媒体



vb 截屏问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


vb 截屏问题
发表于:2007-12-22 23:44:21 楼主
我不想截取全屏,我只想截取frame1或picture1的屏
下面是截取全屏的两个例子
一:
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      
    private       declare       function       getdc       lib       "user32"       (byval       hwnd       as       long)       as       long      
       
    const       srccopy       =       &hcc0020      
       
    private       sub       form_activate()      
                    me.hide      
                    for       i       =       1       to       10000           '延时      
                                    doevents      
                    next       i      
                    bitblt       picture1.hdc,       0,       0,       screen.width       /       15,       screen.height       /       15,       getdc(0),       0,       0,       srccopy      
                    savepicture       picture1.image,       "sss.bmp"      
                    end      
    end       sub      
       
    private       sub       form_load()      
                    with       picture1      
                                    .autoredraw       =       true      
                                    .width       =       screen.width      
                                    .height       =       screen.height      
                    end       with      
    end       sub


二:

private   declare   sub   keybd_event   lib   "user32"   (byval   bvk   as   byte,   byval   bscan   as   byte,   byval   dwflags   as   long,   byval   dwextrainfo   as   long)
const   thescreen   =   1
const   theform   =   0  

private   sub   command1_click()


      call   keybd_event(vbkeysnapshot,   theform,   0,   0)
      '若theform改成thescreen则copy整个screen
      doevents
      picture1.picture   =   clipboard.getdata(vbcfbitmap)
end   sub
发表于:2008-01-03 18:35:451楼 得分:0
该回复于2008-01-03 22:47:52被管理员删除
发表于:2008-01-05 10:04:032楼 得分:0
这是我写的一个简单屏幕放大程序也许对你有用
dim   rtc   as   rect

dim   scrnwidth   as   integer
dim   scrnhight   as   integer
dim   cap   as   string
dim   deskdc   as   long   '存储桌面窗口设备句柄
dim   imgdc   as   long   'imagedc
dim   picdc   as   long   '放大后的dc
dim   downpos   as   pointapi   'mousedownpos   x,y
dim   uppos   as   pointapi   'mouseuppos   x,y
dim   mflag   as   boolean

'初始化
private   sub   initme()
'
cap   =   caption
scrnwidth   =   screen.width
scrnhight   =   screen.height
deskdc   =   getdc(0)   '获取桌面窗口设备场景句柄
imgdc   =   imgs.hdc
end   sub

private   sub   form_load()

initme

end   sub

private   sub   form_unload(cancel   as   integer)
releasedc   0,   deskdc   '释放桌面窗口设备句柄
releasedc   0,   imgdc
end   sub

private   sub   getmousepos_timer()   '显示鼠标位置
dim   cp   as   pointapi
getcursorpos   cp
caption   =   cap   &   space(10)   &   cp.x   &   ", "   &   cp.y


'主要就是下面两句,你要用的bitblt那句,因为你只是抓图..我用的是下面那句.因为我要放大变形...
'bitblt   imgdc,   0,   0,   200,   200,   deskdc,   cp.x   -   100,   cp.y   -   100,   srccopy
stretchblt   imgdc,   0,   0,   400,   400,   deskdc,   cp.x   -   50,   cp.y   -   50,   100,   100,   srccopy
end   sub
发表于:2008-01-05 10:09:413楼 得分:0

我只贴了一部分.所以上面的变量看起来有些没用上..
bitblt       imgdc,       0,       0,       200,       200,       deskdc,       cp.x       -       100,       cp.y       -       100,       srccopy
我抓取的大小是长宽都为200的正方形区域..也就是..(cp.x-100,cp.y-100)-(cp.x+100,cp.y+100)
imgdc是用来显示抓取的图的dc,,deskdc是被抓的源dc..


快速检索

最新资讯
热门点击