国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

在VB6和VB.NET中進行圖象捕獲

2024-07-10 13:07:08
字體:
來源:轉載
供稿:網友

最大的網站源碼資源下載站,

在vb6和vb.net中進行圖象捕獲

vb6中進行圖象捕獲

 

'----------------------------------------------------------------------------

'

'author:lihonggen0

'date:2002-6-19

'功能:抓屏

'----------------------------------------------------------------------------

private type pointapi

    x as long

    y as long

end type

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

private declare function getcursorpos lib "user32" (lppoint as pointapi) 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 declare function releasedc lib "user32" (byval hwnd as long, byval hdc as long) as long

 

private sub command1_click()

    dim hdc as long

    dim sw as integer

    dim sh as integer

    dim curpos as pointapi

    dim cur as long

    me.hide

    doevents

    picture1.autoredraw = true

    hdc = getdc(0)

    getcursorpos curpos

    cur = getcursor

    picture1.width = screen.width

    picture1.height = screen.height

    sw = screen.width / screen.twipsperpixelx

    sh = screen.height / screen.twipsperpixely

    bitblt picture1.hdc, 0, 0, sw, sh, hdc, 0, 0, vbsrccopy

    me.show

    drawicon picture1.hdc, curpos.x - 10, curpos.y - 10, cur

    releasedc 0, hdc

    picture1.autoredraw = false

 

end sub

'參考

'http://support.microsoft.com/?kbid=210108
http://support.microsoft.com/?id=161299


 

vb.net中進行圖象捕獲 ,需要先引用一些api,以下是聲明:

 

    private declare function createcompatibledc lib "gdi32" (byval hdc as integer) as integer

 

    private declare function createcompatiblebitmap lib "gdi32" (byval hdc as integer, byval nwidth as integer, byval nheight as integer) as integer

 

    private declare function selectobject lib "gdi32" (byval hdc as integer, byval hobject as integer) as integer

 

    private declare function bitblt lib "gdi32" (byval srchdc as integer, byval srcx as integer, byval srcy as integer, byval srcw as integer, byval srch as integer, byval desthdc as integer, byval destx as integer, byval desty as integer, byval op as integer) as integer

 

    private declare function deletedc lib "gdi32" (byval hdc as integer) as integer

 

    private declare function deleteobject lib "gdi32" (byval hobj as integer) as integer

 

    declare function getdc lib "user32" alias "getdc" (byval hwnd as integer) as integer

 

const srccopy as integer = &hcc0020

 

 

將以下代碼添加到button1_click事件中:

 

private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click

        dim hdc, hmdc as integer

        dim hbmp, hbmpold as integer

        dim sw, sh as integer

        hdc = getdc(0)

        hmdc = createcompatibledc(hdc)

        sw = screen.primaryscreen.bounds.width

        sh = screen.primaryscreen.bounds.height

 

        hbmp = createcompatiblebitmap(hdc, sw, sh)

        hbmpold = selectobject(hmdc, hbmp)

        bitblt(hmdc, 0, 0, sw, sh, hdc, 0, 0, srccopy)

        hbmp = selectobject(hmdc, hbmpold)

        picturebox1.image = image.fromhbitmap(new intptr(hbmp))

 

        deletedc(hdc)

        deletedc(hmdc)

        deleteobject(hbmp)

end sub

 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 庄浪县| 景谷| 天峻县| 隆德县| 桐庐县| 措美县| 乌鲁木齐市| 华池县| 淮南市| 丰顺县| 乌什县| 苏尼特左旗| 怀柔区| 西贡区| 莱西市| 专栏| 蓬溪县| 阜新市| 汕尾市| 平乡县| 泰宁县| 三亚市| 平度市| 南部县| 布尔津县| 偃师市| 登封市| 紫金县| 泗水县| 旺苍县| 婺源县| 汝州市| 顺义区| 沙雅县| 桂平市| 崇文区| 承德市| 东阿县| 积石山| 应用必备| 交城县|