Results 1 to 5 of 5

Thread: Sticking windows

  1. #1

    Thread Starter
    Hyperactive Member wasiq's Avatar
    Join Date
    Jan 2000
    Location
    Karachi, Sindh, Pakistan
    Posts
    274
    How can I make sticky windows just like winamp. (which stick to the other windows of winamp)? and position form2 exactly under form1.

  2. #2
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    Something like:
    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
    *Gotten off PlanetSourceCode.com*

    Hope that helps,
    D!m
    Dim

  3. #3

    Thread Starter
    Hyperactive Member wasiq's Avatar
    Join Date
    Jan 2000
    Location
    Karachi, Sindh, Pakistan
    Posts
    274
    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?

  4. #4
    Guest
    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

  5. #5

    Thread Starter
    Hyperactive Member wasiq's Avatar
    Join Date
    Jan 2000
    Location
    Karachi, Sindh, Pakistan
    Posts
    274

    Talking

    thankx a lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width