Page 1 of 1

Application Bar Update - Browse Folders

Posted: Thu Nov 12, 2009 4:23 pm
by CodenStuff
Hello,

If you want to add the option to browse for files to add to the Icon Bar then first add a new option to the "ContextMenuStrip" control, I called it 'Browse' and then add this code in its click_event:
Code: Select all
 Dim browse As New OpenFileDialog
        If browse.ShowDialog = Windows.Forms.DialogResult.OK Then
            RichTextBox1.AppendText(browse.FileName + vbNewLine)
            Dim w As New PictureBox
            '**********************************************
            Try
                Dim shortcut, starget As String
                Dim oshelllink
                Dim wsh As Object = CreateObject("WScript.Shell")
                wsh = CreateObject("WScript.Shell")
                shortcut = browse.FileName
                oshelllink = wsh.CreateShortcut(shortcut)
                starget = oshelllink.TargetPath
                '**********************************************
                Using ico As Icon = Drawing.Icon.ExtractAssociatedIcon(starget)
                    Dim s = ico.ToBitmap
                    w.Image = s
                End Using
            Catch ex As Exception
                Try
                    Using ico As Icon = Drawing.Icon.ExtractAssociatedIcon(browse.FileName)
                        Dim s = ico.ToBitmap
                        w.Image = s
                    End Using
                Catch wex As Exception
                    If browse.FileName.Length = 4 Then
                        Using ico As Icon = My.Resources.Harddrive
                            Dim s = ico.ToBitmap
                            w.Image = s
                        End Using
                    End If
                    Using ico As Icon = My.Resources.Folder
                        Dim s = ico.ToBitmap
                        w.Image = s
                    End Using
                End Try
            End Try
            If horv = "top" Then
                w.Location = New Point(rowz, 5)
                If numic > 4 Then
                    Me.Width += 40
                End If
                Me.CenterToScreen()
                Me.Top = Screen.PrimaryScreen.Bounds.X
            ElseIf horv = "left" Then
                w.Location = New Point(5, rowz)
                Me.Height += 40
                ' Me.Width -= 10
                Me.CenterToScreen()
                Me.Left = Screen.PrimaryScreen.Bounds.Y
            ElseIf horv = "right" Then
                w.Location = New Point(5, rowz)
                Me.Height += 40
                ' Me.Width -= 10
                Me.CenterToScreen()
                Me.Left = Screen.PrimaryScreen.WorkingArea.Width + -Me.Width
            ElseIf horv = "bottom" Then
                w.Location = New Point(rowz, 5)
                Me.Width += 40
                Me.CenterToScreen()
                'Me.Left = Screen.PrimaryScreen.Bounds.Width - Me.Width
                ' Me.Top = Screen.PrimaryScreen.Bounds.Height + -Me.Height
                Me.Top = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
            End If
            w.Size = New Size(30, 30)
            w.Tag = browse.FileName
            w.BackColor = Color.Transparent
            AddHandler w.Click, AddressOf Fclick
            AddHandler w.MouseEnter, AddressOf Lab_MouseEnter
            AddHandler w.MouseLeave, AddressOf Lab_MouseLeave
            Me.Controls.Add(w)
            'Me.Width += 40
            rowz += 40
            numic += 1
            Label2.Visible = False

            saveme()
        End If
Happy coding cooll;

Re: Application Bar Update - Browse Folders

Posted: Thu Nov 12, 2009 5:32 pm
by MasterCoding
i updated it so its working

your one not working its has to be a folderbrowserdialog

Code: Select all
 Dim browse As New FolderBrowserDialog
        If browse.ShowDialog = Windows.Forms.DialogResult.OK Then
            RichTextBox1.AppendText(browse.SelectedPath + vbNewLine)
            Dim w As New PictureBox
            '**********************************************
            Try
                Dim shortcut, starget As String
                Dim oshelllink
                Dim wsh As Object = CreateObject("WScript.Shell")
                wsh = CreateObject("WScript.Shell")
                shortcut = browse.SelectedPath
                oshelllink = wsh.CreateShortcut(shortcut)
                starget = oshelllink.TargetPath
                '**********************************************
                Using ico As Icon = Drawing.Icon.ExtractAssociatedIcon(starget)
                    Dim s = ico.ToBitmap
                    w.Image = s
                End Using
            Catch ex As Exception
                Try
                    Using ico As Icon = Drawing.Icon.ExtractAssociatedIcon(browse.SelectedPath)
                        Dim s = ico.ToBitmap
                        w.Image = s
                    End Using
                Catch wex As Exception
                    If browse.SelectedPath.Length = 4 Then
                        Using ico As Icon = My.Resources.Harddrive
                            Dim s = ico.ToBitmap
                            w.Image = s
                        End Using
                    End If
                    Using ico As Icon = My.Resources.Folder
                        Dim s = ico.ToBitmap
                        w.Image = s
                    End Using
                End Try
            End Try
            If horv = "top" Then
                w.Location = New Point(rowz, 5)
                If numic > 4 Then
                    Me.Width += 40
                End If
                Me.CenterToScreen()
                Me.Top = Screen.PrimaryScreen.Bounds.X
            ElseIf horv = "left" Then
                w.Location = New Point(5, rowz)
                Me.Height += 40
                ' Me.Width -= 10
                Me.CenterToScreen()
                Me.Left = Screen.PrimaryScreen.Bounds.Y
            ElseIf horv = "right" Then
                w.Location = New Point(5, rowz)
                Me.Height += 40
                ' Me.Width -= 10
                Me.CenterToScreen()
                Me.Left = Screen.PrimaryScreen.WorkingArea.Width + -Me.Width
            ElseIf horv = "bottom" Then
                w.Location = New Point(rowz, 5)
                Me.Width += 40
                Me.CenterToScreen()
                'Me.Left = Screen.PrimaryScreen.Bounds.Width - Me.Width
                ' Me.Top = Screen.PrimaryScreen.Bounds.Height + -Me.Height
                Me.Top = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
            End If
            w.Size = New Size(30, 30)
            w.Tag = browse.SelectedPath
            w.BackColor = Color.Transparent
            AddHandler w.Click, AddressOf Fclick
            AddHandler w.MouseEnter, AddressOf Lab_MouseEnter
            AddHandler w.MouseLeave, AddressOf Lab_MouseLeave
            Me.Controls.Add(w)
            'Me.Width += 40
            rowz += 40
            numic += 1
            Label2.Visible = False

            saveme()
        End If

Re: Application Bar Update - Browse Folders

Posted: Sun Nov 15, 2009 6:14 am
by Robby
CodeNStuff edit it with the latest version on the downloads and tutorial page too please becuz i m too lazy to code this again

Re: Application Bar Update - Browse Folders

Posted: Wed Apr 13, 2011 12:21 am
by Jg99
Thanks for the add items thing, i needed it

Re: Application Bar Update - Browse Folders

Posted: Wed Apr 13, 2011 1:54 am
by Bogoh67
now how would i make it work with this viewtopic.php?f=38&t=3544&p=24570#p24570
my updated version of yours