Results 1 to 6 of 6

Thread: Program In Taskbar [RESOLVED]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Location
    Scotland
    Posts
    123

    Resolved Program In Taskbar [RESOLVED]

    Hi Everyone

    What i am wanting to do is have a program which is not shown in the taskbar so all i would do for that would be make the property for this false

    I then need to have an icon in the system tray (beside the clock) when the program is minimized and then when the icon is double clicked it will open the program which has been minimized.

    Hopefully this is possible.

    Thanks
    Last edited by Aaron Smith; May 20th, 2005 at 10:23 AM.
    Regards
    Aaron Smith

    Did my post help you, rate my post

    When Quoting VB Code use [vbcode][/vbcode]

    When your problem has been resolved change to *subject* [RESOLVED]

  2. #2
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: Program In Taskbar [STILL NEEDIN HELP GUYS]

    Have a look at this example
    Hopefully it helps!
    Attached Files Attached Files
    VB.NET MVP 2008 - Present

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Location
    Scotland
    Posts
    123

    Re: Program In Taskbar [STILL NEEDIN HELP GUYS]

    thanks for your help but sadly my internet serivce cannot download as shared network

    If you could post code that would be helpful.

    Thanks
    Regards
    Aaron Smith

    Did my post help you, rate my post

    When Quoting VB Code use [vbcode][/vbcode]

    When your problem has been resolved change to *subject* [RESOLVED]

  4. #4
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: Program In Taskbar [STILL NEEDIN HELP GUYS]

    Here's the code, you just need to add some controls to the form, in order for it to work..
    VB Code:
    1. Option Explicit
    2.  
    3.       'Declare a user-defined variable to pass to the Shell_NotifyIcon
    4.       'function.
    5.       Private Type NOTIFYICONDATA
    6.          cbSize As Long
    7.          hWnd As Long
    8.          uId As Long
    9.          uFlags As Long
    10.          uCallBackMessage As Long
    11.          hIcon As Long
    12.          szTip As String * 64
    13.       End Type
    14.  
    15.       'Declare the constants for the API function. These constants can be
    16.       'found in the header file Shellapi.h.
    17.  
    18.       'The following constants are the messages sent to the
    19.       'Shell_NotifyIcon function to add, modify, or delete an icon from the
    20.       'taskbar status area.
    21.       Private Const NIM_ADD = &H0
    22.       Private Const NIM_MODIFY = &H1
    23.       Private Const NIM_DELETE = &H2
    24.  
    25.       'The following constant is the message sent when a mouse event occurs
    26.       'within the rectangular boundaries of the icon in the taskbar status
    27.       'area.
    28.       Private Const WM_MOUSEMOVE = &H200
    29.  
    30.       'The following constants are the flags that indicate the valid
    31.       'members of the NOTIFYICONDATA data type.
    32.       Private Const NIF_MESSAGE = &H1
    33.       Private Const NIF_ICON = &H2
    34.       Private Const NIF_TIP = &H4
    35.  
    36.       'The following constants are used to determine the mouse input on the
    37.       'the icon in the taskbar status area.
    38.  
    39.       'Left-click constants.
    40.       Private Const WM_LBUTTONDBLCLK = &H203   'Double-click
    41.       Private Const WM_LBUTTONDOWN = &H201     'Button down
    42.       Private Const WM_LBUTTONUP = &H202       'Button up
    43.  
    44.       'Right-click constants.
    45.       Private Const WM_RBUTTONDBLCLK = &H206   'Double-click
    46.       Private Const WM_RBUTTONDOWN = &H204     'Button down
    47.       Private Const WM_RBUTTONUP = &H205       'Button up
    48.  
    49.       'Declare the API function call.
    50.       Private Declare Function Shell_NotifyIcon Lib "shell32" _
    51.          Alias "Shell_NotifyIconA" _
    52.          (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
    53.  
    54.       'Dimension a variable as the user-defined data type.
    55.       Dim nid As NOTIFYICONDATA
    56.  
    57.       Private Sub cmdAdd_Click()
    58.          'Click this button to add an icon to the taskbar status area.
    59.  
    60.          'Set the individual values of the NOTIFYICONDATA data type.
    61.          nid.cbSize = Len(nid)
    62.          nid.hWnd = frmTaskIcon.hWnd
    63.          nid.uId = vbNull
    64.          nid.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
    65.          nid.uCallBackMessage = WM_MOUSEMOVE
    66.          nid.hIcon = frmTaskIcon.Icon
    67.          nid.szTip = "Taskbar Status Area Sample Program" & vbNullChar
    68.  
    69.          'Call the Shell_NotifyIcon function to add the icon to the taskbar
    70.          'status area.
    71.          Shell_NotifyIcon NIM_ADD, nid
    72.       End Sub
    73.  
    74.       Private Sub cmdDelete_Click()
    75.          'Click this button to delete the added icon from the taskbar
    76.          'status area by calling the Shell_NotifyIcon function.
    77.          Shell_NotifyIcon NIM_DELETE, nid
    78.       End Sub
    79.  
    80.       Private Sub Form_Load()
    81.          'Set the captions of the command button when the form loads.
    82.          cmdAdd.Caption = "Add an Icon"
    83.          cmdDelete.Caption = "Delete Icon"
    84.          
    85.          'note once icon is visible, double click it,
    86.          'to choose own icon.  Or right click to
    87.          'specify tooltips
    88.          
    89.       End Sub
    90.  
    91.       Private Sub Form_Terminate()
    92.          'Delete the added icon from the taskbar status area when the
    93.          'program ends.
    94.          Shell_NotifyIcon NIM_DELETE, nid
    95.       End Sub
    96.  
    97.       Private Sub Form_MouseMove _
    98.          (Button As Integer, _
    99.           Shift As Integer, _
    100.           X As Single, _
    101.           Y As Single)
    102.           'Event occurs when the mouse pointer is within the rectangular
    103.           'boundaries of the icon in the taskbar status area.
    104.           Dim msg As Long
    105.           Dim sFilter As String
    106.           msg = X / Screen.TwipsPerPixelX
    107.           Select Case msg
    108.              Case WM_LBUTTONDOWN
    109.              Case WM_LBUTTONUP
    110.              Case WM_LBUTTONDBLCLK
    111.              cdTask.DialogTitle = "Select an Icon"
    112.              sFilter = "Icon Files (*.ico)|*.ico"
    113.              sFilter = sFilter & "|All Files (*.*)|*.*"
    114.              cdTask.Filter = sFilter
    115.              cdTask.ShowOpen
    116.              If cdTask.FileName <> "" Then
    117.                 frmTaskIcon.Icon = LoadPicture(cdTask.FileName)
    118.                 nid.hIcon = frmTaskIcon.Icon
    119.                 Shell_NotifyIcon NIM_MODIFY, nid
    120.              End If
    121.              Case WM_RBUTTONDOWN
    122.                 Dim ToolTipString As String
    123.                 ToolTipString = InputBox("Enter the new ToolTip:", _
    124.                                   "Change ToolTip")
    125.                 If ToolTipString <> "" Then
    126.                    nid.szTip = ToolTipString & vbNullChar
    127.                    Shell_NotifyIcon NIM_MODIFY, nid
    128.                 End If
    129.              Case WM_RBUTTONUP
    130.              Case WM_RBUTTONDBLCLK
    131.           End Select
    132.       End Sub
    VB.NET MVP 2008 - Present

  5. #5
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Program In Taskbar [STILL NEEDIN HELP GUYS]

    If you click on the link in my sig, SysTray, then you can download my code.
    The code basically does what HanneSThEGreaT posted, but it's a little more structures, elegant and a few more features (like adding menus at runtime so when you right click on the icon...blah blah). It also allows you to annimate the systray icon.
    Full demo and source is included. The demo included the functionality you want, hiding the form to the systray when minimised.

    If you have any questions then give me a shout.

    Woka

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Location
    Scotland
    Posts
    123

    Re: Program In Taskbar [STILL NEEDIN HELP GUYS]

    thank you both for you help

    Quote Originally Posted by Wokawidget
    If you have any questions then give me a shout.
    I have not had a change to try this out but when i do if i have any difficulties then i will let you know
    Regards
    Aaron Smith

    Did my post help you, rate my post

    When Quoting VB Code use [vbcode][/vbcode]

    When your problem has been resolved change to *subject* [RESOLVED]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width