How to make your program minimize into the task bar?

Posts 1–9 of 9 · Page 1 of 1
How to make your program minimize into the task bar?
How do you make your program when you minimize it, it hides in the task bar.
Thanks if you know

Isn't it Hide? -.-
Are you spamming my thread or something?
Try:

me.minimizebox()
me.hide()
If it doesn't work, then i don't know
I'm working on it.

Final edit: This works:
Code:
'add a notify Icon

Public Class Form1
    Inherits System.Windows.Forms.Form
#Region " Minimize To System Tray "
    Structure RECT
        Public left As Integer
        Public top As Integer
        Public right As Integer
        Public bottom As Integer
    End Structure

    Structure APPBARDATA
        Public cbSize As Integer
        Public hWnd As IntPtr
        Public uCallbackMessage As Integer
        Public uEdge As ABEdge
        Public rc As RECT
        Public lParam As IntPtr
    End Structure

    Enum ABMsg
        ABM_NEW = 0
        ABM_REMOVE = 1
        ABM_QUERYPOS = 2
        ABM_SETPOS = 3
        ABM_GETSTATE = 4
        ABM_GETTASKBARPOS = 5
        ABM_ACTIVATE = 6
        ABM_GETAUTOHIDEBAR = 7
        ABM_SETAUTOHIDEBAR = 8
        ABM_WINDOWPOSCHANGED = 9
        ABM_SETSTATE = 10
    End Enum

    Enum ABNotify
        ABN_STATECHANGE = 0
        ABN_POSCHANGED
        ABN_FULLSCREENAPP
        ABN_WINDOWARRANGE
    End Enum

    Enum ABEdge
        ABE_LEFT = 0
        ABE_TOP
        ABE_RIGHT
        ABE_BOTTOM
    End Enum

    Public Declare Function SHAppBarMessage Lib "shell32.dll" Alias "SHAppBarMessage" (ByVal dwMessage As Integer, ByRef pData As APPBARDATA) As Integer
    Private Const ABM_GETTASKBARPOS As Integer = &H5&
    Private Const WM_SYSCOMMAND As Integer = &H112
    Private Const SC_MINIMIZE As Integer = &HF020

    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If m.Msg = WM_SYSCOMMAND AndAlso m.WParam.ToInt32() = SC_MINIMIZE Then
            AnimateWindow(True)
            Exit Sub
        End If
        MyBase.WndProc(m)
    End Sub

    Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
        AnimateWindow(False)
    End Sub

    Private Sub AnimateWindow(ByVal ToTray As Boolean)
        Dim screenRect As Rectangle = Screen.GetBounds(Me.Location)
        Dim destPoint As Point
        Dim BarData As APPBARDATA
        BarData.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(BarData)
        SHAppBarMessage(ABMsg.ABM_GETTASKBARPOS, BarData)
        Select Case BarData.uEdge
            Case ABEdge.ABE_BOTTOM, ABEdge.ABE_RIGHT
                destPoint = New Point(screenRect.Width, screenRect.Height)
            Case ABEdge.ABE_LEFT
                destPoint = New Point(0, screenRect.Height)
            Case ABEdge.ABE_TOP
                destPoint = New Point(screenRect.Width, 0)
        End Select
        Dim a, b, s As Single
        If ToTray Then
            a = 0
            b = 1
            s = 0.05
        Else
            a = 1
            b = 0
            s = -0.05
        End If
        Dim curPoint As Point, curSize As Size
        Dim startPoint As Point = Me.Location
        Dim dWidth As Integer = destPoint.X - startPoint.X
        Dim dHeight As Integer = destPoint.Y - startPoint.Y
        Dim startWidth As Integer = Me.Width
        Dim startHeight As Integer = Me.Height
        Dim i As Single
        For i = a To b Step s
            curPoint = New Point(startPoint.X + i * dWidth, startPoint.Y + i * dHeight)
            curSize = New Size((1 - i) * startWidth, (1 - i) * startHeight)
            ControlPaint.DrawReversibleFrame(New Rectangle(curPoint, curSize), Me.BackColor, FrameStyle.Thick)
            System.Threading.Thread.Sleep(15)
            ControlPaint.DrawReversibleFrame(New Rectangle(curPoint, curSize), Me.BackColor, FrameStyle.Thick)
        Next
        If ToTray Then
            Me.Hide()
            NotifyIcon1.Visible = True
        Else

            NotifyIcon1.Visible = False
            Me.Show()
        End If
    End Sub
#End Region


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
I didn't make that code, I just fixed the bugs and made it look really cool
Quote Originally Posted by Lolland View Post
I'm working on it.

Final edit: This works:
Code:
'add a notify Icon

Public Class Form1
    Inherits System.Windows.Forms.Form
#Region " Minimize To System Tray "
    Structure RECT
        Public left As Integer
        Public top As Integer
        Public right As Integer
        Public bottom As Integer
    End Structure

    Structure APPBARDATA
        Public cbSize As Integer
        Public hWnd As IntPtr
        Public uCallbackMessage As Integer
        Public uEdge As ABEdge
        Public rc As RECT
        Public lParam As IntPtr
    End Structure

    Enum ABMsg
        ABM_NEW = 0
        ABM_REMOVE = 1
        ABM_QUERYPOS = 2
        ABM_SETPOS = 3
        ABM_GETSTATE = 4
        ABM_GETTASKBARPOS = 5
        ABM_ACTIVATE = 6
        ABM_GETAUTOHIDEBAR = 7
        ABM_SETAUTOHIDEBAR = 8
        ABM_WINDOWPOSCHANGED = 9
        ABM_SETSTATE = 10
    End Enum

    Enum ABNotify
        ABN_STATECHANGE = 0
        ABN_POSCHANGED
        ABN_FULLSCREENAPP
        ABN_WINDOWARRANGE
    End Enum

    Enum ABEdge
        ABE_LEFT = 0
        ABE_TOP
        ABE_RIGHT
        ABE_BOTTOM
    End Enum

    Public Declare Function SHAppBarMessage Lib "shell32.dll" Alias "SHAppBarMessage" (ByVal dwMessage As Integer, ByRef pData As APPBARDATA) As Integer
    Private Const ABM_GETTASKBARPOS As Integer = &H5&
    Private Const WM_SYSCOMMAND As Integer = &H112
    Private Const SC_MINIMIZE As Integer = &HF020

    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If m.Msg = WM_SYSCOMMAND AndAlso m.WParam.ToInt32() = SC_MINIMIZE Then
            AnimateWindow(True)
            Exit Sub
        End If
        MyBase.WndProc(m)
    End Sub

    Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
        AnimateWindow(False)
    End Sub

    Private Sub AnimateWindow(ByVal ToTray As Boolean)
        Dim screenRect As Rectangle = Screen.GetBounds(Me.Location)
        Dim destPoint As Point
        Dim BarData As APPBARDATA
        BarData.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(BarData)
        SHAppBarMessage(ABMsg.ABM_GETTASKBARPOS, BarData)
        Select Case BarData.uEdge
            Case ABEdge.ABE_BOTTOM, ABEdge.ABE_RIGHT
                destPoint = New Point(screenRect.Width, screenRect.Height)
            Case ABEdge.ABE_LEFT
                destPoint = New Point(0, screenRect.Height)
            Case ABEdge.ABE_TOP
                destPoint = New Point(screenRect.Width, 0)
        End Select
        Dim a, b, s As Single
        If ToTray Then
            a = 0
            b = 1
            s = 0.05
        Else
            a = 1
            b = 0
            s = -0.05
        End If
        Dim curPoint As Point, curSize As Size
        Dim startPoint As Point = Me.Location
        Dim dWidth As Integer = destPoint.X - startPoint.X
        Dim dHeight As Integer = destPoint.Y - startPoint.Y
        Dim startWidth As Integer = Me.Width
        Dim startHeight As Integer = Me.Height
        Dim i As Single
        For i = a To b Step s
            curPoint = New Point(startPoint.X + i * dWidth, startPoint.Y + i * dHeight)
            curSize = New Size((1 - i) * startWidth, (1 - i) * startHeight)
            ControlPaint.DrawReversibleFrame(New Rectangle(curPoint, curSize), Me.BackColor, FrameStyle.Thick)
            System.Threading.Thread.Sleep(15)
            ControlPaint.DrawReversibleFrame(New Rectangle(curPoint, curSize), Me.BackColor, FrameStyle.Thick)
        Next
        If ToTray Then
            Me.Hide()
            NotifyIcon1.Visible = True
        Else

            NotifyIcon1.Visible = False
            Me.Show()
        End If
    End Sub
#End Region


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
I didn't make that code, I just fixed the bugs and made it look really cool
Really advanced code
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Need help?