Windows has been out for more than N years. Let's first introduce the Unique API of windows !! Animatewindow is a new function that produces animation effects when a window is opened or closed. Because it is a new function, it cannot be found in API viewer and must be defined by yourself:
Public declare function setlayeredwindowattributes lib "USER32" (byval hwnd as long, byval crkey as long, byval balpha as byte, byval dwflags as long) as long
'The specific constants that can be used and their usage
Const lwa_alpha = & H2 'indicates that the form is set to a translucent style.
Const lwa_colorkey = & H1 'indicates that the transparent color in the form is not displayed.
Example
ProgramCode
Module1
Public declare function setlayeredwindowattributes lib "USER32" (byval hwnd as long, byval crkey as long, byval balpha as byte, byval dwflags as long) as long
Public const ws_ex_layered = & h80000
Public const gwl_exstyle = (-20)
Public const lwa_alpha = & H2
Public const lwa_colorkey = & H1
Public declare function getwindowlong lib "USER32" alias "getwindowlonga" (byval hwnd as long, byval nindex as long) as long
Public declare function setwindowlong lib "USER32" alias "setwindowlonga" (byval hwnd as long, byval nindex as long, byval dwnewlong as long) as long
Form1
Private sub form_load ()
Dim RTN as long
RTN = getwindowlong (Me. hwnd, gwl_exstyle) 'obtains the original style of the window.
RTN = RTN or ws_ex_layered: Add a new style ws_ex_layered to the form.
Setwindowlong me. hwnd, gwl_exstyle, rtn' assign the new style to the form
Setlayeredwindowattributes me. hwnd, 0,192, lwa_alpha
'Set the form to a translucent style. The second parameter indicates the transparency.
'Value range: 0--255. If it is 0, it is a fully transparent form.
End sub
Method 2
Setlayeredwindowattributes me. hwnd, & H0, 0, lwa_colorkey
'Indicates that the transparent color in the form is not displayed.
'And the second parameter indicates that the transparent color is black, and you can use the RGB function to specify the color value.
Download source code: