Minimize windowless form to System Tray/Task Bar 
Author Message
 Minimize windowless form to System Tray/Task Bar

I remeber seeing an API/Graphics trick that simulates the Minimize and
Restore graphical zip down/zip up look when a Minimize/Maximize button
is not present on a form(windowless).

Ive searched for sometime in the winapi for a solution but I cant seem
to find the the combination.

Does anyone remember this trick?



Mon, 26 Dec 2005 04:22:52 GMT  
 Minimize windowless form to System Tray/Task Bar

Quote:
> I remeber seeing an API/Graphics trick that simulates the Minimize and
> Restore graphical zip down/zip up look when a Minimize/Maximize button
> is not present on a form(windowless).

> Ive searched for sometime in the winapi for a solution but I cant seem
> to find the the combination.

AnimateWindow() perhaps?
http://msdn.microsoft.com/library/en-us/winui/WinUI/WindowsUserInterf...
Hope this helps,

    Mike

 - Microsoft Visual Basic MVP -

WWW: Http://www.mvps.org/EDais/



Mon, 26 Dec 2005 05:07:59 GMT  
 Minimize windowless form to System Tray/Task Bar

Quote:
>I remeber seeing an API/Graphics trick that simulates the Minimize and
>Restore graphical zip down/zip up look when a Minimize/Maximize button
>is not present on a form(windowless).

>Ive searched for sometime in the winapi for a solution but I cant seem
>to find the the combination.

>Does anyone remember this trick?

This maybe?

('scuse the line wraps)

Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

'Private Const IDANI_OPEN = 1
'Private Const IDANI_CLOSE = 2
Private Const IDANI_CAPTION = 3
Private Declare Function DrawAnimatedRects Lib "user32" (ByVal hwnd As
Long, ByVal idAni As Long, lprcFrom As RECT, lprcTo As RECT) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As
Long, lpRect As RECT) As Long
Private Declare Function FindWindowEx Lib "user32" Alias
"FindWindowExA" (ByVal hWndParent As Long, ByVal hWndChildAfter As
Long, ByVal lpClassName As String, ByVal lpWindowName As String) As
Long

Public Sub Effect_Implode(oFrm As Form, Optional bImplode As Boolean =
True)
    'Implodes or Explodes Form from its center.
    'bImplode: True(default)=Implode, False=reverse(explode)
    Dim rMin As RECT, rNorm As RECT

    'Get the rect for oFrm...
    GetWindowRect oFrm.hwnd, rNorm

    'Define the rMin rect as the center of oFrm's rect...
    With rMin
        .Left = rNorm.Left + ((rNorm.Right - rNorm.Left) \ 2)
        .Right = .Left
        .Top = rNorm.Top + ((rNorm.Bottom - rNorm.Top) \ 2)
        .Bottom = .Top
    End With
    If bImplode Then 'implode
        DrawAnimatedRects oFrm.hwnd, IDANI_CAPTION, rNorm, rMin
    Else 'reverse (explode)
        DrawAnimatedRects oFrm.hwnd, IDANI_CAPTION, rMin, rNorm
    End If
End Sub

Public Sub Effect_MinToTray(oFrm As Form, Optional bMinimize As
Boolean = True)
    'Creates the effect of a form minimizing to / restoring from
    'the tray notification area instead of the normal (taskbar button)
position.
    'bMinimize: True(default)=minimize, False=reverse(restore)
    Dim rTray As RECT, rNorm As RECT
    Dim hTaskBar As Long, hTray As Long

    'get current "normal" window rect
    GetWindowRect oFrm.hwnd, rNorm

    'set an arbitrary default position (bottom right of screen) in
case there's no tray area...
    With Screen
        rTray.Left = .Width \ .TwipsPerPixelX
        rTray.Top = .Height \ .TwipsPerPixelY
    End With

    'get taskbar hwnd...
    hTaskBar = FindWindowEx(0&, 0&, "Shell_TrayWnd", vbNullString)
    If hTaskBar <> 0& Then 'found taskbar
        'get tray nofication area hwnd...
        hTray = FindWindowEx(hTaskBar, 0&, "TrayNotifyWnd",
vbNullString)
        If hTray <> 0& Then 'found tray notification area window
            'get it's rect...
            GetWindowRect hTray, rTray
        End If
    End If

    If bMinimize Then 'minimize effect
        DrawAnimatedRects oFrm.hwnd, IDANI_CAPTION, rNorm, rTray
    Else 'reverse(restore) effect
        DrawAnimatedRects oFrm.hwnd, IDANI_CAPTION, rTray, rNorm
    End If
End Sub

-Tom
MVP - Visual Basic
(please post replies to the newsgroup)



Mon, 26 Dec 2005 05:25:55 GMT  
 Minimize windowless form to System Tray/Task Bar
YES!! Thats the one -- DrawAnimatedRects(great usage by the way), I
was origonaly thinking it had something to do with AnimateWindow, but
I see now that DrawAnimatedRects was intended for this purpose.

Thanks for all the help.



Tue, 27 Dec 2005 01:40:19 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. System Tray vs Task Bar

2. Task bar and system tray.

3. Minimise to the System Tray Not Task Bar

4. system tray not task bar !

5. Having program show up in system tray instead of task bar

6. System tray and task bar issue

7. CoolHide - Help you hide/minimize window to Tray and hide icons from the system tray

8. CoolHide - Help you hide/minimize window to Tray and hide icons from the system tray

9. Minimizing a form to the system tray instead of the taskbar

10. Form not on task bar, vanishes on minimize

11. HELP: How to Minimize a Form in Task Bar

12. Minimize AC00 to system tray

 

 
Powered by phpBB® Forum Software