There are now many software use transparent windows as the interface, how to implement it in your program? I found this support in Win2k, as long as the simple lines of code are implemented. (This example is currently only available for Win2K)
Take a dialog box as an example:
First step definition function
Typedef Bool (FAR Pascal * Func1) (HWND HWND, // Handle to the Layered Window ColorRef CRKEY, / / Specifies The Color Key Byte Balpha, // Value for the Blend Function DWORD DWFLAGS // Action)
Second step implementation code
In the following code is added OnInitDialog ..... HMODULE hModule = GetModuleHandle ( "user32.dll"); FUNC1 SetLayeredWindowAttributes; SetLayeredWindowAttributes = (FUNC1) GetProcAddress (hModule, _T ( "SetLayeredWindowAttributes"));
// Set hierarchical Extensible Markup SetWindowLong (GetSafeHwnd (), GWL_EXSTYLE, GetWindowLong (GetSafeHwnd (), GWL_EXSTYLE) | 0x80000L); // 70% alpha SetLayeredWindowAttributes (GetSafeHwnd (), 0, (255 * 70) / 100, 0x2) ;
Work, how, now you can run your program to view the effect, even if background changes can be reflected in your window, this is better than Jinshan word.
It is a new joining:
Step 3: How to remove transparent options?
// Remove the layered extension marker setWindowlong (GWL_EXSTYLE, GETWINDOWLON (GETSAFEHWND (), GWL_EXSTYLE) & ~ 0x80000L); // Heavy painting window RedRawwindow ();
The fourth part: VB transparent window (from MSDN)
Private Declare Function GetWindowLong Lib "user32" Alias _ "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As LongPrivate Declare Function SetLayeredWindowAttributes Lib "user32" _ (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, _ ByVal dwFlags As Long) As LongPrivate Const GWL_EXSTYLE = (-20) Private Const WS_EX_LAYERED = & H80000Private Const WS_EX_TRANSPARENT = & H20 & Private Const LWA_ALPHA = & H2 & Option ExplicitPrivate Sub Form_Load () Dim lOldStyle As Long Dim bTrans As Byte 'The level of transparency (0 - 255) bTrans = 128 lOldStyle = GetWindowLong (Me.hWnd, GWL_EXSTYLE) SetWindowLong Me.hWnd, GWL_EXSTYLE, LOLDSTYLE or WS_EX_LAYERED SETLAYEREDWINDOWATTRIBUTES me.hWnd, 0, BTRANS, LWA_ALPHAEND SUB is finally a bit. Thank you for watching.