Results 1 to 5 of 5

Thread: Minimiing to task bar

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Slovenia
    Posts
    32

    Question

    Hi!
    I need to minimize my program to taskbar (next to the clock), but I have no idea how to do that. The programs icon should appear on the task bar and a menu should pop-up when user clicks on that icon. Please post an example if possible.

    Thanx in advance for any aswer.

    Celery

    VB6 Pro SP3 - Academic Licence

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    from Aaron or someone

    'Show form icon in system tray

    ' User defined type required by Shell_NotifyIcon API call
    Private 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

    ' Constants required by Shell_NotifyIcon API call
    Private Const NIM_ADD = &H0
    Private Const NIM_MODIFY = &H1
    Private Const NIM_DELETE = &H2
    Private Const NIF_MESSAGE = &H1
    Private Const NIF_ICON = &H2
    Private Const NIF_TIP = &H4
    Private Const WM_MOUSEMOVE = &H200
    Private Const WM_LBUTTONDOWN = &H201 'Button down
    Private Const WM_LBUTTONUP = &H202 'Button up
    Private Const WM_LBUTTONDBLCLK = &H203 'Double-click
    Private Const WM_RBUTTONDOWN = &H204 'Button down
    Private Const WM_RBUTTONUP = &H205 'Button up
    Private Const WM_RBUTTONDBLCLK = &H206 'Double-click

    'API call
    Private Declare Function SetForegroundWindow Lib "user32" _
    (ByVal hwnd As Long) As Long
    Private Declare Function Shell_NotifyIcon Lib "shell32" _
    Alias "Shell_NotifyIconA" _
    (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean

    'variable declaration
    Private nid As NOTIFYICONDATA



    Private Sub Form_Load()
    Me.Show
    Me.Refresh
    With nid
    .cbSize = Len(nid)
    .hwnd = Me.hwnd
    .uId = vbNull
    .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
    .uCallBackMessage = WM_MOUSEMOVE
    .hIcon = Me.Icon
    .szTip = App.ProductName & " " & App.Major & "." & App.Minor & ", Build " & App.Revision & vbNullChar
    End With
    Shell_NotifyIcon NIM_ADD, nid
    End Sub

    Private Sub Form_Unload(Cancel As Integer)

    ' Remove Icon from System Tray
    Shell_NotifyIcon NIM_DELETE, nid

    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Slovenia
    Posts
    32
    Thanx for your reply HeSaidJoe. But is it really necessary to write so much code? Isn't there any easier way?

    Celery

    VB6 Pro SP3 - Academic Licence

  4. #4
    New Member
    Join Date
    Jul 2000
    Posts
    4

    Exclamation

    Hi Celery

    Just a lil correction. The place where the system clock is shown is not called the TASKBAR but it is called the
    SYSTEM TRAY or SYSTRAY.

  5. #5
    Guest
    For a menu to go with your little icon:

    Code:
    Private Sub Form_MouseMove(button As Integer, Shift As Integer, X As Single, Y As Single)
      Static lngMsg As Long
      Static blnFlag As Boolean
      Dim result As Long
    lngMsg = X / Screen.TwipsPerPixelX
      If blnFlag = False Then
            blnFlag = True
            Select Case lngMsg
            'right-click
            Case WM_RBUTTONUP
              result = SetForegroundWindow(Me.hWnd)
              PopupMenu Me.mnumenu 'your menu
             Case WM_LBUTTONUP
              result = SetForegroundWindow(Me.hWnd)
              PopupMenu Me.mnumenu 'your menu
            End Select
            blnFlag = False
     End If
    End Sub

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