Option Compare Database
Private Declare Function MoveWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hwndParent&, ByVal hwndChildAfter&, ByVal lpszClass$, ByVal lpszWindow$) As Long
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd&, ByRef lpRect As RECT) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, _
ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex 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 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 hwnd As Long, _
ByVal hdc As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _
ByVal nIndex As Long) As Long
Const HWND_DESKTOP As Long = 0
Const LOGPIXELSX As Long = 88
Const LOGPIXELSY As Long = 90
'--------------------------------------------------
Function TwipsPerPixelX() As Single
'--------------------------------------------------
'Returns the width of a pixel, in twips.
'--------------------------------------------------
Dim lngDC As Long
lngDC = GetDC(HWND_DESKTOP)
TwipsPerPixelX = 1440& / GetDeviceCaps(lngDC, LOGPIXELSX)
ReleaseDC HWND_DESKTOP, lngDC
End Function
'--------------------------------------------------
Function TwipsPerPixelY() As Single
'--------------------------------------------------
'Returns the height of a pixel, in twips.
'--------------------------------------------------
Dim lngDC As Long
lngDC = GetDC(HWND_DESKTOP)
TwipsPerPixelY = 1440& / GetDeviceCaps(lngDC, LOGPIXELSY)
ReleaseDC HWND_DESKTOP, lngDC
End Function
'hWnd - ìàíèïóëÿòîð îêíà, Layered - ñòåïåíü ïðîçðà÷íîñòè îò 0 äî 255
Private Sub SetTransparent(hwnd As Long, Layered As Byte)
Dim Ret As Long
'Îïðåäåëÿåì ñòèëü íóæíîãî îêíà
Ret = GetWindowLong(hwnd, GWL_EXSTYLE)
'Çàäà¸ì ñòèëü îêíà êàê çàñëî¸ííûé
Ret = Ret Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, Ret
'Çàä¸ì ñòåïåíü ïðîçðà÷íîñòè îêíà
SetLayeredWindowAttributes hwnd, 0, Layered, LWA_ALPHA
End Sub
Private Sub Form_Load()
Dim Xtwip As Integer
Dim Ytwip As Integer
Dim Y As Integer, Ymax As Integer
Dim rctMain As RECT
Dim Timer As Long
Dim tmr
Dim hDesktop As Long
hDesktop = GetDesktopWindow
Xtwip = CInt(TwipsPerPixelX)
Ytwip = CInt(TwipsPerPixelY)
Call GetClientRect(hDesktop, rctMain)
Call SetTransparent(Me.hwnd, 150)
Ymax = 200
For Y = 0 To Ymax
Call MoveWindow(Me.hwnd, rctMain.Right - 25 - (Me.Width / Xtwip), rctMain.Bottom - (Me.WindowHeight / Ytwip) - 30, 190, Y, 1)
Next
Me.txtMessage = ReceivedMessage
End Sub |