VB Code:
Option Explicit Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Const WS_EX_TRANSPARENT = &H20& Private Const GWL_EXSTYLE = (-20) Private Const SWP_NOMOVE = &H2 Private Const SWP_NOSIZE = &H1 Private Const SWP_FRAMECHANGED = &H20 ' The frame changed: send WM_NCCALCSIZE Public Sub MakeFrameTransparent(ByVal fraThis As Frame) Dim lExStyle As Long lExStyle = GetWindowLong(fraThis.hwnd, GWL_EXSTYLE) lExStyle = lExStyle Or WS_EX_TRANSPARENT Call SetWindowLong(fraThis.hwnd, GWL_EXSTYLE, lExStyle) Call SetWindowPos(fraThis.hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_FRAMECHANGED) End Sub
Note that you can make other windows transparent as well - the effect with a rich text box is particularily pleasing....
HTH,
Duncan




Reply With Quote