'模块中
创新互联公司专注于企业成都营销网站建设、网站重做改版、下花园网站定制设计、自适应品牌网站建设、HTML5建站、商城网站定制开发、集团公司官网建设、成都外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为下花园等各大城市提供网站开发制作服务。
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) _
As Long
Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
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
'form1中
Private Sub Command1_Click()
Dim hDCtmp As Long, picWidth As Double, picHeight As Double
Dim x As Double
Dim y As Double
x = Val(Text2.Text)
y = Val(Text3.Text)
picWidth = Val(Text3.Text)
picHeight = Val(Text4.Text)
hDCtmp = GetDC(0)
BitBlt Picture1.hdc, 0, 0, picWidth, picHeight, hDCtmp, x, y, vbSrcCopy
ReleaseDC 0, hDCtmp
End Sub
目的: 将屏幕按照指定坐标和大小进行截取成图,在picture1显示
问题: 大小是相同了,为什么截取的坐标不对,只是屏幕上的左上
相信大家都用过QQ截图功能。不过很多人并没有真正掌握好它的用法。将QQ截图与其它截屏和制图软件配合使用,会有意想不到的效果。
获取颜色的RGB值
我们在编辑图片或网页的时候,经常需要获取某种颜色的“RGB值”,所以很多人都安装了第三方的颜色吸取工具。其时用QQ截图键即可获取屏幕上任意颜色的RGB值。
当按下“Ctrl+Shift+A”弹出“截图”提示框时,提示框中的“当前像素RGB”即为当前鼠标屏幕位置的颜色RGB值,将鼠标移动到你想查看的屏幕颜色上即可获得相应的RGB值(如图1)。
图1精确截取图片大小
有时我们对要使用的截图尺寸有严格要求,比如论坛签名或QQ头像等。用QQ截图键可以按尺寸精确截取,一步到位无需再进行后期裁剪了。
按下QQ截图键,按住鼠标不放选取截取范围时,在鼠标上方会有一个信息框显示当前范围的详细信息,其中“矩形大小”就是以像素来表示的图片的尺寸大小,括号内的数字分别表示的是长和高(如图2)。松开鼠标调整截图框时,对照“矩形大小”就可以按需要的尺寸来精确截图范围,然后用鼠标点住截图框将截图框拖到要截取的图片上,双击即可获得所需尺寸的图片了。
图2图片拼贴好帮手
大部分的截图软件一次只能截取一张图片,当要截取多张图片并进行拼贴组合时,就需要一张一张截取全部保存后再进行拼贴操作,非常麻烦。
我们知道用QQ截图键截取的图片可以在任一个可以粘贴图片的程序中使用,这样只需用截图软件进行一次截图操作,剩下的图片用QQ截图键来截取,然后依次粘贴到截图软件的窗口中即可快速进行拼贴操作了,是不是很方便啊。
小提示:QQ截图键无需打开聊天窗口即可使用,截取的图片在任一可粘贴图片的程序窗口中如画图、Word等,使用“粘贴”命令即可使用
既然能够取得整个屏幕,可以取到整个屏幕以后创建一个全屏窗体显示静态的屏幕图像,然后在窗体上实现部分截取。
估计别的截图也是这个原理,因为一点开始截图屏幕就变为静态不动了,肯定是在截图初期复制了当时的屏幕场景
用datagridview
排序的话datagridview自身的功能就能实现
你说的标签如果是指双击或者单击或者右击有相应的反应的话
需要在后台编写相应事件
操作还是比较方便的
可以将Webbroser的位置记录下来,然后按照位置屏幕截图,就截取到了webbroser里面的图片,再通过picture显示出来就可以了;
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' CreateBitmapPicture
' - Creates a bitmap type Picture object from a bitmap and
' palette.
'
' hBmp
' - Handle to a bitmap.
'
' hPal
' - Handle to a Palette.
' - Can be null if the bitmap doesn't use a palette.
'
' Returns
' - Returns a Picture object containing the bitmap.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
Public Function CreateBitmapPicture(ByVal hBmp As Long, ByVal hPal As Long) As Picture
Dim r As Long
Dim Pic As PicBmp
' IPicture requires a reference to "Standard OLE Types."
Dim IPic As IPicture
Dim IID_IDispatch As GUID
' Fill in with IDispatch Interface ID.
With IID_IDispatch
.Data1 = H20400
.Data4(0) = HC0
.Data4(7) = H46
End With
' Fill Pic with necessary parts.
With Pic
.Size = Len(Pic) ' Length of structure.
.Type = vbPicTypeBitmap ' Type of Picture (bitmap).
.hBmp = hBmp ' Handle to bitmap.
.hPal = hPal ' Handle to palette (may be null).
End With
' Create Picture object.
r = OleCreatePictureIndirect(Pic, IID_IDispatch, 1, IPic)
' Return the new Picture object.
Set CreateBitmapPicture = IPic
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' CaptureWindow
' - Captures any portion of a window.
'
' hWndSrc
' - Handle to the window to be captured.
'
' Client
' - If True CaptureWindow captures from the client area of the
' window.
' - If False CaptureWindow captures from the entire window.
'
' LeftSrc, TopSrc, WidthSrc, HeightSrc
' - Specify the portion of the window to capture.
' - Dimensions need to be specified in pixels.
'
' Returns
' - Returns a Picture object containing a bitmap of the specified
' portion of the window that was captured.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''
'
Public Function CaptureWindow(ByVal hWndSrc As Long, ByVal Client As Boolean, ByVal LeftSrc As Long, ByVal TopSrc As Long, ByVal WidthSrc As Long, ByVal HeightSrc As Long) As Picture
Dim hDCMemory As Long
Dim hBmp As Long
Dim hBmpPrev As Long
Dim r As Long
Dim hDCSrc As Long
Dim hPal As Long
Dim hPalPrev As Long
Dim RasterCapsScrn As Long
Dim HasPaletteScrn As Long
Dim PaletteSizeScrn As Long
Dim LogPal As LOGPALETTE
' Depending on the value of Client get the proper device context.
If Client Then
hDCSrc = GetDC(hWndSrc) ' Get device context for client area.
Else
hDCSrc = GetWindowDC(hWndSrc) ' Get device context for entire window.
End If
' Create a memory device context for the copy process.
hDCMemory = CreateCompatibleDC(hDCSrc)
' Create a bitmap and place it in the memory DC.
hBmp = CreateCompatibleBitmap(hDCSrc, WidthSrc, HeightSrc)
hBmpPrev = SelectObject(hDCMemory, hBmp)
' Get screen properties.
RasterCapsScrn = GetDeviceCaps(hDCSrc, RASTERCAPS) ' Raster
' capabilities.
HasPaletteScrn = RasterCapsScrn And RC_PALETTE ' Palette
' support.
PaletteSizeScrn = GetDeviceCaps(hDCSrc, SIZEPALETTE) ' Size of
' palette.
' If the screen has a palette make a copy and realize it.
If HasPaletteScrn And (PaletteSizeScrn = 256) Then
' Create a copy of the system palette.
LogPal.palVersion = H300
LogPal.palNumEntries = 256
r = GetSystemPaletteEntries(hDCSrc, 0, 256, LogPal.palPalEntry(0))
hPal = CreatePalette(LogPal)
' Select the new palette into the memory DC and realize it.
hPalPrev = SelectPalette(hDCMemory, hPal, 0)
r = RealizePalette(hDCMemory)
End If
' Copy the on-screen image into the memory DC.
r = BitBlt(hDCMemory, 0, 0, WidthSrc, HeightSrc, hDCSrc, LeftSrc, TopSrc, vbSrcCopy)
' Remove the new copy of the on-screen image.
hBmp = SelectObject(hDCMemory, hBmpPrev)
' If the screen has a palette get back the palette that was
' selected in previously.
If HasPaletteScrn And (PaletteSizeScrn = 256) Then
hPal = SelectPalette(hDCMemory, hPalPrev, 0)
End If
' Release the device context resources back to the system.
r = DeleteDC(hDCMemory)
r = ReleaseDC(hWndSrc, hDCSrc)
' Call CreateBitmapPicture to create a picture object from the
' bitmap and palette handles. Then return the resulting picture
' object.
Set CaptureWindow = CreateBitmapPicture(hBmp, hPal)
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' CaptureScreen
' - Captures the entire screen.
'
' Returns
' - Returns a Picture object containing a bitmap of the screen.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
Public Function CaptureScreen() As Picture
Dim hWndScreen As Long
Dim Wwidth As Long
Dim Wheight As Long
Wwidth = GetSystemMetrics(SM_CXSCREEN)
Wheight = GetSystemMetrics(SM_CYSCREEN)
' Get a handle to the desktop window.
hWndScreen = GetDesktopWindow()
' Call CaptureWindow to capture the entire desktop give the handle
' and return the resulting Picture object. Screen.width / Screen.TwipsPerPixelX**********Screen.Height / Screen.TwipsPerPixelY
Set CaptureScreen = CaptureWindow(hWndScreen, True, 0, 0, Wwidth, Wheight)
End Function
把上面的代码放到一个bas模块中,在窗体上放一个Picture控件,然后用类似下面的代码来抓屏:
Visual Basic code?
1
2
3
Private Sub Command1_Click()
Set Picture1.Picture = CaptureScreen
End Sub
另外代码中那个CaptureWindow是抓取窗口的。
参考:
这是捕捉键盘热键,例如QQ写的一个抓屏功能,同时按下Ctrl+Alt+A 就会自动 跳出抓屏。
也就是说上面这段代码自动获取到的热键符合Ctrl+Alt+A 的命令,所以才会执行事件。
If m.Msg = WM_SYSCOMMAND Then' 如果m 的热键码 有系统命令 执行以下事件。