デスクトップ画面をキャプチャしてフォームに表示します。デスクトップのウィンドウハンドルの取得にはGetDesktopWindow、そのウィンドウハンドルのデバイスコンテキストの取得にはGetDCを使用します。
Private SubForm_Load()
DimhWndAllAs Long
DimhWndDCAs Long
DimlretAs Long
Form1.AutoRedraw =True
'画面のイメージをフォームにコピー
hWndAll = GetDesktopWindow()
hWndDC = GetDC(hWndAll)
lret = BitBlt(Form1.hDC, 0, 0, ScaleWidth, ScaleHeight, hWndDC, 0, 0, vbSrcCopy)
CallReleaseDC(hWndAll, hWndDC)
End Sub
'---------------------------------------------------
'module
'---------------------------------------------------DeclareFunctionBitBltLib"gdi32" (ByValhDestDCAs Long,ByValXAs Long,ByValYAs Long,ByValnWidthAs Long,ByValnHeightAs Long,ByValhSrcDCAs Long,ByValxSrcAs Long,ByValySrcAs Long,ByValdwRopAs Long)As Long
'ウィンドウハンドルを取得する関数
Declare FunctionGetDesktopWindowLib"user32" ()As Long
'ウィンドウのデバイスコンテキストのハンドルを取得する関数
Declare FunctionGetDCLib"user32" (ByValhwndAs Long)As Long
'デバイスコンテキストの開放
Declare FunctionReleaseDCLib"user32" (ByValhwndAs Long,ByValhdcAs Long)As Long
DownLoad vbtips031.lzh 2KB (VB6,0)