borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Cdate function)Next Topic (Communication Ports detection both in Windows 95/95 and Windows NT/2000.) New Topic New Poll Post Reply
AndreaVB Forum : VB General : How to add icon at the startup bar - bottom right corner
Poster Message
shahidmojid
Level: Professor

Registered: 09-05-2002
Posts: 85

icon How to add icon at the startup bar - bottom right corner  Archived to Disk

I am using VB6 / win98. I want to add an icon at the startup by vb6 command, i mean to say when i click hide from my vb6 project it supposed to show an small icon at the right bottom corner and program should hide also. How can i do that. Please help!!!!

09-05-2002 at 11:04 AM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1616
icon Re: How to add icon at the startup bar - bottom right corner  Archived to Disk

To hide the program:
      MainFormName.Visible=False
    
To add an icon (I believe all the stuff's here, I had to copy it from a program). Of course it requires a picture box.

' For Systray Icon
    Public Type NOTIFYICONDATA
        cbSize As Long
        hwnd As Long
        uId As Long
        uFlags As Long
        ucallbackMessage As Long
        hIcon As Long
        szTip As String * 64
    End Type

    Public Const NIM_ADD = &H0
    Public Const NIM_MODIFY = &H1
    Public Const NIM_DELETE = &H2
    Public Const WM_MOUSEMOVE = &H200
    Public Const NIF_MESSAGE = &H1
    Public Const NIF_ICON = &H2
    Public Const NIF_TIP = &H4

    Public NID As NOTIFYICONDATA

    Public Declare Function Shell_NotifyIcon Lib "shell32" _
        Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid _
        As NOTIFYICONDATA) As Boolean

Public Function SysTrayIcon(Optional ByVal fLoad As Boolean = True) As Boolean
    On Error Resume Next
    Err.Clear
' Define System tray icon
    With NID
    ' Common To loading and unloading
        .cbSize = Len(NID)
        .hwnd = pctSysTray.hwnd
        .uId = 1&
        If fLoad Then
        ' Only Loading info
            .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
            .ucallbackMessage = WM_MOUSEMOVE
            .hIcon = pctSysTray.hwnd
            .szTip = "Tip" & Chr$(0)
        End If
    End With
    If fLoad Then
    ' Load Sys Tray icon
        Shell_NotifyIcon NIM_ADD, NID
    Else
    ' Remove Sys Tray icon
        Shell_NotifyIcon NIM_DELETE, NID
    End If
    SysTrayIcon = IIf(LenB(Err.Description) = 0, True, False)
End Function


' To handle the mouse events
Private Sub pctSysTray_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Show the menu, show options that are available
    If Button = vbRightButton Then
        PopupMenu menuTray, , , , menuFileRestore
    End If
End Sub

09-05-2002 at 05:19 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
shahidmojid
Level: Professor

Registered: 09-05-2002
Posts: 85
icon Re: How to add icon at the startup bar - bottom right corner  Archived to Disk

Guru Thanks a lot for your prompt help. But why still i am not getting the icon at the tray? Please help!!!!

pctSysTray_MouseMove and function (SysTrayIcon) i kept under Form. All const, declared function and Type kept under module. Picturebox added (name pctSysTray). I called the api systrayicon from a command button but still not getting the icon at the tray.

sub command1_click
systrayicon
end sub

What shall i do? please help!!!

09-05-2002 at 07:57 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1616
icon Re: How to add icon at the startup bar - bottom right corner  Archived to Disk

Oops...

In the code that I posted change the following:

        If fLoad Then
        ' Only Loading info
            .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
            .ucallbackMessage = WM_MOUSEMOVE
' ******* CHANGE THE FOLLOWING LINE ********
            .hIcon = pctSysTray.Picture
            .szTip = "Tip" & Chr$(0)
        End If

I put the hWnd not the picture for the icon, so that's why it didn't work.

09-05-2002 at 08:53 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
shahidmojid
Level: Professor

Registered: 09-05-2002
Posts: 85
icon Re: How to add icon at the startup bar - bottom right corner  Archived to Disk

Guru, thank you very much.... It's working very nice....

Thanks

10-05-2002 at 02:38 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : How to add icon at the startup bar - bottom right corner
Previous Topic (Cdate function)Next Topic (Communication Ports detection both in Windows 95/95 and Windows NT/2000.) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder