程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB綜合教程 >> 用VB捕捉屏幕圖象

用VB捕捉屏幕圖象

編輯:VB綜合教程
聲明:
  PrivateDeclareFunctionReleaseDCLib"user32"(ByValhwndAsLong,ByValhdcAsLong)AsLong
  PrivateDeclareFunctionOpenClipboardLib"user32"(ByValhwndAsLong)AsLong
  PrivateDeclareFunctionEmptyClipboardLib"user32"()AsLong
  PrivateDeclareFunctionSetClipboardDataLib"user32"(ByValwFormatAsLong,ByValhMemAsLong)AsLong
  PrivateDeclareFunctionSelectObjectLib"gdi32"(ByValhdcAsLong,ByValhObjectAsLong)AsLong
  PrivateDeclareFunctionDeleteDCLib"gdi32"(ByValhdcAsLong)AsLong
  PrivateDeclareFunctionBitBltLib"gdi32"(ByValhDestDCAsLong,
  ByValxAsLong,ByValyAsLong,ByValnWidthAsLong,ByValnHeightAsLong,ByValhSrcDCAsLong,ByValxSrcAsLong,ByValySrcAsLong,ByValdwRopAsLong)AsLong
  PrivateDeclareFunctionCreateDCLib"gdi32"Alias"CreateDCA"(ByVallpDriverNameAsString,ByVallpDeviceNameAsString,ByVallpOutputAsString,lpInitDataAsLong)AsLong
  PrivateDeclareFunctionCreateCompatibleDCLib"gdi32"(ByValhdcAsLong)AsLong
  PrivateDeclareFunctionCreateCompatibleBitmapLib"gdi32"(ByValhdcAsLong,ByValnWidthAsLong,ByValnHeightAsLong)AsLong
  PrivateDeclareFunctionCloseClipboardLib"user32"()AsLong
  函數:
  SubScrnCap(Lt,Top,Rt,Bot)
  rWidth=Rt-Lt
  rHeight=Bot-Top
  SourceDC=CreateDC("DISPLAY",0,0,0)
  DestDC=CreateCompatibleDC(SourceDC)
  BHandle=CreateCompatibleBitmap(SourceDC,rWidth,rHeight)
  SelectObjectDestDC,BHandle
  BitBltDestDC,0,0,rWidth,rHeight,SourceDC,Lt,Top,&HCC0020
  Wnd=Screen.ActiveForm.hwnd
  OpenClipboardWnd
  EmptyClipboard
  SetClipboardData2,BHandle
  CloseClipboard
  DeleteDCDestDC
  ReleaseDCDHandle,SourceDC
  EndSub
  以下的示例把屏幕圖象捕捉後,放到Picture1中。
  SubCommand1_Click()
  Form1.Visible=False
  ScrnCap0,0,640,480
  Form1.Visible=True
  picture1=Clipboard.GetData()
  EndSub->

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved