Results 1 to 5 of 5

Thread: Help........!!!! About Application...

  1. #1

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Post

    Dear All...

    I want to ask something about VB...
    If I minimized my application program (in exe file), I want it to appear in the right side of tasbar....
    I mean like icq, mcAffee VShield, task scheduler, etc....

    Could anyone help me ??? Just tell me how to do it....

    Thx a lot...

    Wille
    Junior VB Programmer

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Here an example of how to place an Icon in the System Tray..
    Code:
    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
    
    Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
    
    Private Const NIF_ICON = &H2
    Private Const NIF_MESSAGE = &H1
    Private Const NIF_TIP = &H4
    Private Const NIM_ADD = &H0
    Private Const NIM_DELETE = &H2
    Private Const NIM_MODIFY = &H1
    Private Const WM_MOUSEMOVE = &H200
    Private Const WM_LBUTTONDBLCLK = &H203
    Private Const WM_LBUTTONDOWN = &H201
    Private Const WM_RBUTTONDOWN = &H204
    
    Private tTrayIcon As NOTIFYICONDATA
    
    Private Sub Form_Load()
        'Create a Tray Icon
        Picture1.Visible = False
        With tTrayIcon
            .hIcon = Icon
            .hwnd = Picture1.hwnd
            .szTip = "My Tray Icon" & Chr(0)
            .uCallbackMessage = WM_MOUSEMOVE
            .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
            .uID = 1
            .cbSize = Len(tTrayIcon)
        End With
        Shell_NotifyIcon NIM_ADD, tTrayIcon
    End Sub
    
    Private Sub Form_Resize()
        DoEvents
        If WindowState = vbMinimized Then
            Hide
        End If
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        'Remove the Tray Icon
        Shell_NotifyIcon NIM_DELETE, tTrayIcon
    End Sub
    
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Select Case ScaleX(X, vbTwips, vbPixels)
        Case WM_RBUTTONDOWN
            'Show Popup Menu
        Case WM_LBUTTONDBLCLK
            'Show the Form
            WindowState = vbNormal
            Show
        End Select
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  3. #3

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Post

    Dear Mr. Aaron...

    I've tried your code...
    and it works.. thx...
    but.. I still have one question...

    When I move my mouse pointer to the icon,
    there's a tooltiptext --> "My Tray Icon"

    My question is... How can I change it ???
    I mean... How can I change the tooltiptext into the text I want...

    Thx Mr. Aaron..

    Wille
    Junior VB Programmer

  4. #4
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Post

    Hi,

    You see the form load events codes....
    The 5th line

    .szTip = "Minimized Form" & Chr(0)

    Change the text what ever u want here

    Venkat. Good Luck

  5. #5
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Check the code on Form_Load event. Aaron is assigning values to NOTIFYICONDATA structure (variable name tTrayIcon). Find the szTip and assign any other string value (don't forget to assign the vbNullChar (Chr(0) at the end of that string)

    Code:
    With tTrayIcon
            .hIcon = Icon
            .hwnd = Picture1.hwnd
            .szTip = "My Tray Icon" & Chr(0)  'Here put your own ToolTip Message
            .uCallbackMessage = WM_MOUSEMOVE
            .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
            .uID = 1
            .cbSize = Len(tTrayIcon)
        End With
    Regards,

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819



    [This message has been edited by Serge (edited 11-15-1999).]

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