Minimize windowless form to System Tray/Task Bar

Minimize windowless form to System Tray/Task Bar

Post by Paul De » Fri, 11 Jul 2003 05:22:52



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?

 
 
 

Minimize windowless form to System Tray/Task Bar

Post by Mike D Sutto » Fri, 11 Jul 2003 06:07:59


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/

 
 
 

Minimize windowless form to System Tray/Task Bar

Post by Tom Es » Fri, 11 Jul 2003 06:25:55



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)

 
 
 

Minimize windowless form to System Tray/Task Bar

Post by Paul De » Sat, 12 Jul 2003 02:40:19


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.

 
 
 

1. Minimize an application in the task bar

Hi, all.

I'm trying to minimize my application. If I do:
Form->WindowState=wsMinimized, the application
minimizes, but not appears in the bar. It appears in the bottom of desktop,
like it was a MDI child
window into an MDI application.

Does anybody know how can I minimize my application?.

Thanks a lot.
Hristo,

2. Internal Server Error 500

3. Minimize to task bar

4. PC scripts

5. Minimize to the system tray

6. LW Final,m All images 24 bit?

7. Visual Minimize to System Tray

8. Artists Needed

9. Forms visible in the task bar

10. Task Tray Icon

11. Task switch minimize

12. Q: How to restore (repaint) the caption bar/title bar of a form

13. How do I get the size of form borders and title bar on a form