資源描述:
《利用vb捕捉并保存屏幕圖像》由會員上傳分享,免費在線閱讀,更多相關內(nèi)容在應用文檔-天天文庫。
1、利用VB捕捉并保存屏幕圖像大家知道在VB下利用API函數(shù)Bitblt可以將屏幕或者窗口上的圖象拷貝到VB中的PictureBox對象中,但是如果簡單的利用PictureBox的SavePicture函數(shù)來保存圖象,會發(fā)現(xiàn)什么也保存不了。這篇文章就是介紹如何捕獲并利用Windows下的OLEAPI函數(shù)保存圖象?! ∈紫葋砜丛闯绦颍紫冉⒁粋€新的工程文件,然后在Form1中加入5個CommandButton對象和一個PictureBox對象,然后在Form1中加入以下代碼:OptionExplicitOptionB
2、ase0PrivateTypePALETTEENTRY peRedAsByte peGreenAsByte peBlueAsByte peFlagsAsByteEndTypePrivateTypeLOGPALETTE palVersionAsInteger palNumEntriesAsInteger palPalEntry(255)AsPALETTEENTRYEndTypePrivateTypeGUID Data1AsLong Data2AsInteger Data3AsInteger Data4(7)AsBy
3、teEndTypePrivateConstRASTERCAPSAsLong=38PrivateConstRC_PALETTEAsLong=&H100PrivateConstSIZEPALETTEAsLong=104PrivateTypeRECT LeftAsLong TopAsLong RightAsLong BottomAsLongEndTypePrivateDeclareFunctionCreateCompatibleDCLib"GDI32"(ByValhDCAsLong)AsLongPrivateDecla
4、reFunctionCreateCompatibleBitmapLib"GDI32"(ByValhDCAsLong,_ ByValnWidthAsLong,ByValnHeightAsLong)AsLongPrivateDeclareFunctionGetDeviceCapsLib"GDI32"(ByValhDCAsLong,ByVal_ iCapabilitiyAsLong)AsLongPrivateDeclareFunctionGetSystemPaletteEntriesLib"GDI32"(B
5、yValhDCAsLong,_ ByValwStartIndexAsLong,ByValwNumEntriesAsLong,lpPaletteEntries_ AsPALETTEENTRY)AsLongPrivateDeclareFunctionCreatePaletteLib"GDI32"(lpLogPaletteAsLOGPALETTE)_ AsLongPrivateDeclareFunctionSelectObjectLib"GDI32"(ByValhDCAsLong,ByValhObje
6、ct_ AsLong)AsLongPrivateDeclareFunctionBitBltLib"GDI32"(ByValhDCDestAsLong,ByValXDestAs_ Long,ByValYDestAsLong,ByValnWidthAsLong,ByValnHeightAsLong,_ ByValhDCSrcAsLong,ByValXSrcAsLong,ByValYSrcAsLong,ByValdwRop_ AsLong)AsLongPrivateDeclareFunction
7、DeleteDCLib"GDI32"(ByValhDCAsLong)AsLongPrivateDeclareFunctionGetForegroundWindowLib"USER32"()AsLongPrivateDeclareFunctionSelectPaletteLib"GDI32"(ByValhDCAsLong,ByValhPalette_ AsLong,ByValbForceBackgroundAsLong)AsLongPrivateDeclareFunctionRealizePaletteLib
8、"GDI32"(ByValhDCAsLong)AsLongPrivateDeclareFunctionGetWindowDCLib"USER32"(ByValhWndAsLong)AsLongPrivateDeclareFunctionGetDCLib"USER32"(ByValhWndAsLong)AsLongPrivateDeclareFunctionGetWindo