Results 1 to 6 of 6

Thread: Docking Windows

  1. #1
    Guest

    Talking

    How can I make a window dock to the edges of the screen?
    Like ICQ and Winamp do?
    And ICQ also "isolates" itself, I mean, all the desktop icons move and everything moves like the screen is only the part where ICQ is not.

    Any ideas?

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    The API you want is SHAppBarMessage.

    Code:
    Public Declare Function SHAppBarMessage Lib "shell32.dll" Alias "SHAppBarMessage" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
    and you need this udt and some constants

    Code:
    Public Type APPBARDATA
            cbSize As Long
            hwnd As Long
            uCallbackMessage As Long
            uEdge As Long
            rc As Rect
            lParam As Long '  message specific
    End Type
    Public Const ABM_ACTIVATE = &H6               
    Public Const ABM_GETAUTOHIDEBAR = &H7
    Public Const ABM_GETSTATE = &H4
    Public Const ABM_GETTASKBARPOS = &H5
    Public Const ABM_NEW = &H0
    Public Const ABM_QUERYPOS = &H2
    Public Const ABM_REMOVE = &H1
    Public Const ABM_SETAUTOHIDEBAR = &H8          
    Public Const ABM_SETPOS = &H3
    Public Const ABM_WINDOWPOSCHANGED = &H9
    I've never actually used it bafore, there's a lot to do, you need to set up an extra message handler to handle some messages specific to docked windows.

    Here's What MSDN has to say.

    And there's a couple of examples in Planet Source code, but one's cheating and I havn't downloaded the other one, but It looks promissing as it's complex.


    Cheating Way With Timer
    This Might be the SHAppBarMessage Meathod but I havn't downloaded it

  3. #3
    Guest
    Thanks Samantha

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Here's my work on the appbar stuff, never got finished but I think i succeded in reserving that appbar area. If you could improove somethimg, i would be glad to share the progress
    Code:
    ' // AppBar stuff
    
    Public Const ABM_NEW = &H0
    Public Const ABM_REMOVE = &H1
    Public Const ABM_QUERYPOS = &H2
    Public Const ABM_SETPOS = &H3
    Public Const ABM_GETSTATE = &H4
    Public Const ABM_GETTASKBARPOS = &H5
    Public Const ABM_ACTIVATE = &H6               '  lParam == TRUE/FALSE means activate/deactivate
    Public Const ABM_GETAUTOHIDEBAR = &H7
    Public Const ABM_SETAUTOHIDEBAR = &H8          '  this can fail at any time.  MUST check the result
                                            '  lParam = TRUE/FALSE  Set/Unset
                                            '  uEdge = what edge
    Public Const ABM_WINDOWPOSCHANGED = &H9
    
    
    '  these are put in the wparam of callback messages
    Public Const ABN_STATECHANGE = &H0
    Public Const ABN_POSCHANGED = &H1
    Public Const ABN_FULLSCREENAPP = &H2
    Public Const ABN_WINDOWARRANGE = &H3 '  lParam == TRUE means hide
    
    '  flags for get state
    
    Public Const ABS_AUTOHIDE = &H1
    Public Const ABS_ALWAYSONTOP = &H2
    Public Const ABE_LEFT = 0
    Public Const ABE_TOP = 1
    Public Const ABE_RIGHT = 2
    Public Const ABE_BOTTOM = 3
    
    Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type
    Type APPBARDATA
            cbSize As Long
            hwnd As Long
            uCallbackMessage As Long
            uEdge As Long
            rc As RECT
            lParam As Long '  message specific
    End Type
    
    
    Public Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
    Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Declare Function MoveWindow Lib "user32" (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
    
    Sub Newbar(hwnd&)
        Dim abd As APPBARDATA, rt As RECT, rc As RECT
        GetWindowRect hwnd, rt
        With rc
            .Left = 0
            .Top = 0
            .Bottom = 1200
            .Right = 1600
        End With
        With abd
            If (rt.Right - rt.Left) > (rt.Bottom - rt.Top) Then
                If (rt.Bottom + rt.Top) > Screen.Height / Screen.TwipsPerPixelY Then
                    .uEdge = ABE_BOTTOM
                Else
                    .uEdge = ABE_TOP
                End If
            Else
                If (rt.Right + rt.Left) > Screen.Width / Screen.TwipsPerPixelX Then
                    .uEdge = ABE_RIGHT
                Else
                    .uEdge = ABE_LEFT
                End If
            End If
            .hwnd = hwnd
            .uCallbackMessage = 123
            .cbSize = Len(abd)
            SHAppBarMessage ABM_NEW, abd
            '.uEdge = ABE_BOTTOM
            .rc = rc
            .cbSize = Len(abd)
            'SHAppBarMessage ABN_WINDOWARRANGE, abd
            SHAppBarMessage ABM_QUERYPOS, abd
            
            If (rt.Right - rt.Left) > (rt.Bottom - rt.Top) Then
                If (rt.Bottom + rt.Top) > Screen.Height / Screen.TwipsPerPixelY Then
                    .uEdge = ABE_BOTTOM
                    .rc.Top = .rc.Bottom - rt.Bottom + rt.Top
                Else
                    .uEdge = ABE_TOP
                    .rc.Bottom = .rc.Top - rt.Top + rt.Bottom
                End If
            Else
                If (rt.Right + rt.Left) > Screen.Width / Screen.TwipsPerPixelX Then
                    .uEdge = ABE_RIGHT
                    .rc.Left = .rc.Right - rt.Right + rt.Left
                Else
                    .uEdge = ABE_LEFT
                    .rc.Right = .rc.Left - rt.Left + rt.Right
                End If
            End If
            .cbSize = Len(abd)
            SHAppBarMessage ABM_SETPOS, abd
            MoveWindow hwnd, .rc.Left, .rc.Top, .rc.Right - .rc.Left, .rc.Bottom - .rc.Top, 1
            DoEvents
            SHAppBarMessage ABM_ACTIVATE, abd
        End With
        SHAppBarMessage ABM_REMOVE, abd
    
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guest
    Why did you set the callback to 123?

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    .uCallbackMessage = 123

    No idea, I got this idea a few months ago and then i started on a new project and leaved this. Could be that i tried to test what i did because that's what i did tested each function what they do..
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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