Use VB to create screen dimming effect.

zhaozj2021-02-11  208

Use VB to create screen darkening effect. I want to use VB programming to implement the screen dimming effect (the effect of turning off Win95), just press the steps below.

1. Add two CommandButton and a Picturebox in Form1.

2, add the following code in the code window of the Form1:

Private Type Rect

LEFT As Long

Top as long

Right As long

Bottom as long

End Type

Private Declare Function Getdc LIB "User32" (BYVAL HWND As Long) AS Long

Private Declare Function ReleaseDC LIB "User32" (Byval HDC As Long) AS

Long

Private Declare Function CreatePatternbrush LIB "GDI32" (Byval Hbitmap As Long) AS Long

Private Declare Function Patblt Lib "GDI32" (Byval HDC As Long, Byval x as long, byval y

Long, Byval NWIDTH AS Long, Byval NHEIGHT AS Long, Byval DWrop As Long AS Long

Private Declare Function DeleteObject Lib "GDI32" (Byval Hobject As Long) AS LONG

Private Declare Function CreateBitmap LIB "GDI32" (Byval NHEight AS

Long, Byval Nplanes As Long, ByVal Nbitcount As Long, LPBITS AS ANY) AS LONG

Private Declare Function SelectObject LIB "GDI32" (Byval Hobject As Long)

As long

Private Declare Function InvalidateRect Lib "User32" (Byval Hwnd As Long, ByVal LPRECT AS

Long, BYVAL BERASE AS Long AS Long

Private bybits (1 to 16) as Byte

Private HbitMap As Long, Hbrush As Long

Private HDesktopWnd As Long

Private submmand1_click ()

DIM ROP AS Long, RES As Long

DIM HDC5 AS Long, Width5 As Long, Height5 As Long

HDC5 = getDC (0)

Width5 = Screen.width / Screen.TwipsPixelx

Height5 = Screen.height / Screen.twipsperpixely

ROP = & HA000C9

Call SelectObject (HDC5, HBRUSH)

Res = Patblt (HDC5, 0, 0, Width5, Height5, ROP)

Call DeleteObject (Hbrush)

Res = releasedc (0, HDC5)

End Sub

PRIVATE SUB Command2_Click () DIM AA As Long

AA = INVALIDATERECT (0, 0, 1)

End Sub

Private sub flow_load ()

Dim ary

DIM I as long

Ary = array (& H55, & H0, & HAA, & H0, _

& H55, & H0, & HAA, & H0, _

& H55, & H0, & HAA, & H0, _

& H55, & H0, & HAA, & H0)

For i = 1 to 16

Bybits (i) = ary (i - 1)

Next i

Hbitmap = CreateBitmap (8, 8, 1, 1, bybits (1))

Hbrush = creagepatternbrush (hbitmap)

Picture1.forecolor = RGB (0, 0, 0)

Picture1.backcolor = RGB (255, 255, 255)

Picture1.scalemode = 3

End Sub

Run the program, press Command1 to make the screen down, press COMMAND2 to recover.

转载请注明原文地址:https://www.9cbs.com/read-4626.html

New Post(0)