Home > Software engineering >  Vb full screen many times problems after the figure - a great god for help ah, be urgent!
Vb full screen many times problems after the figure - a great god for help ah, be urgent!

Time:09-27

Option Explicit

'====================================================
Private Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
Private Declare Function SetDIBits Lib "gdi32" (ByVal HDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
'====================================================
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
'the left key click
'====================================================
Private Declare Function GetDC Lib "user32" (ByVal HWND) As Long As Long 'access to handle
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 'access to image data

Private Declare Function ReleaseDC Lib "user32" (ByVal HWND As Long, ByVal HDC) As Long As Long 'release DC

Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal HDC) As Long As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal HDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal HDC) As Long As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal HDC As Long, ByVal hObject As Long) As Long
Private Const SRCCOPY=& amp; HCC0020 '(DWORD) dest=source



'
the color tablePrivate Type RGBQUAD
RgbBlue As Byte
RgbGreen As Byte
RgbRed As Byte
RgbAlpha As Byte 'transparent channel
End Type

Private Type BITMAPINFOHEADER
BiSize As Long 'bitmap size
BiWidth As Long
BiHeight As Long
BiPlanes As Integer
Head length biBitCount As Integer 'information
BiCompression As Long 'compression way
BiSizeImage As Long
BiXPelsPerMeter As Long
BiYPelsPerMeter As Long
BiClrUsed As Long
BiClrImportant As Long
End Type

Private Type BITMAPINFO
BmiHeader As BITMAPINFOHEADER
BmiColors As RGBQUAD
End Type

'the image file header
Dim BI As BITMAPINFO
Dim BI1 As BITMAPINFO
Dim PP As New Form1


'to find the picture in picture 1 2, whether to find all
Public Function NFindPic (, Top Left As Long As Long, Right, As Long As Bottom Long, Fileurl As String)

Dim P2 As Picture, P2W P2H, P2Handle
Set the P2=LoadPicture (Fileurl)
P2W=P2. Width
P2H=P2. Height
P2Handle=P2. Handle


H is Dim W As Long As Long, I As Long, j As Long
Dim W2 As Long, H2 As Long, I2 As Long, J2 As Long

Dim zPic () As Byte, -fpic () As Byte
Dim R As Byte, G, b As Byte As Byte

Picture 2 data obtained '1
W2=Form1. ScaleX (P2W vbHimetric, vbPixels)
H2=Form1. ScaleY (P2H, 8, 3)

With BI. BmiHeader
BiSize=Len (BI. BmiHeader)
. BiWidth=W2
. BiHeight=- H2
. BiBitCount=32
. The biPlanes=1
End With

H2 ReDim zPic (3, W2-1, 1)

I=GetDIBits (Form1. HDC, P2Handle, 0, H2, zPic (0, 0, 0), BI, 0)
Set the P2=Nothing
'the Debug. Print I
'if here processing, image large, may be a bit faster,

Picture 1 data obtained '2
W=Right
H=Bottom

With BI1. BmiHeader
BiSize=Len (BI1. BmiHeader)
. BiWidth=W
. BiHeight=-h
. BiBitCount=32
. The biPlanes=1
End With

For J2=0 To H2-2 'circulation judge small picture
For I2=0 To W2-2
J2, PP. PSet (I2), RGB (zPic (2, I2, J2), zPic (1, I2, J2), zPic (0, I2, J2))
Next I2
Next J2
PP. Refresh

ReDim -fpic (3, W - 1, H - 1)

Dim hBMPhDC
Dim hDCmem As Long
Dim Pic1Handle As Long
Dim hBmpPrev As Long
HBMPhDC=GetDC (0)
'regular screenshots code, get a hBmp:
HDCmem=CreateCompatibleDC (hBMPhDC)
Pic1Handle=CreateCompatibleBitmap (hBMPhDC, Right, Bottom)
HBmpPrev=SelectObject (hDCmem Pic1Handle)
BitBlt hDCmem, 0, 0, Right, Bottom, hBMPhDC, Left, Top, SRCCOPY
'the SelectObject hDCmem, hBmpPrev
DeleteDC hDCmem

I=GetDIBits (hBMPhDC, Pic1Handle, 0 H, -fpic (0, 0, 0), BI1, 0)

ReleaseDC 0, hBMPhDC


'the Debug. Print I
'analysis to find the
For j=0 To H - H2-1
VBA. DoEvents
For I=0 To W - W2-1

For J2=0 To H2-2 'circulation judge small picture
For I2=0 To W2-2

If the -fpic (2, I + I2, j + J2) & lt;> ZPic (2, I2, J2) Then GoTo ExitLine: 'R
If the -fpic (1, I + I2, j + J2) & lt;> ZPic (1, I2, J2) Then GoTo ExitLine: 'G
If the -fpic (0, I + I2, j + J2) & lt;> ZPic (0, I2, J2) Then GoTo ExitLine: 'B

Next I2
Next J2

'the Debug Print ":", I, J

NFindPic=I & amp; ", "& amp; J
ExitLine:
Next I
Next j

'get the current cursor coordinates,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related