How can I make sticky windows just like winamp. (which stick to the other windows of winamp)? and position form2 exactly under form1.
Printable View
How can I make sticky windows just like winamp. (which stick to the other windows of winamp)? and position form2 exactly under form1.
Something like:
*Gotten off PlanetSourceCode.com*Code:Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Timer1_Timer()
Dim tRect As RECT
If Me.Left < 700 Then Me.Left = 0
If Me.Left > 7500 Then Me.Left = Screen.Width - Width
If Me.Top < 700 Then Me.Top = 0
If Me.Top > 7500 Then
Call GetWindowRect(FindWindowEx(0&, 0&, "Shell_TrayWnd", vbNullString), tRect)
Top = ScaleY(tRect.Top, vbPixels, vbTwips) - Height
Exit Sub
End If
End Sub
Hope that helps,
D!m
thanx for the above code, its perfect.
there is another question
i have two forms, form1 and form2,
form1 is movable and form2 is not.
i want form2 to move when form1 moves and place it exactly under form1. how do i do that?
Wow, I'm glad you like that code wasiq. Anyway, to stick your form2 under form1:
Code:'Timer interval set at 1
Private Sub Form_Load()
Form2.Show
End Sub
Private Sub Timer1_Timer()
Form2.Left = Form1.Left
Form2.Top = Form1.Top + 2700
End Sub
thankx a lot