473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Minimize to Syste Tray

pablojoshua
How would you minimize your project to the system tray. All of the ones I find on the web will not mazimize the program when it is clicked on wile in the tray.

Thanks & Cheers
Jun 27 '07 #1
2 2082
sashi
1,754 Expert 1GB
Hi there,

Kindly refer to below code segment, hope it helps. Good luck & Take care.

Module code
Expand|Select|Wrap|Line Numbers
  1. 'user defined type required by Shell_NotifyIcon API call
  2.       Public Type NOTIFYICONDATA
  3.        cbSize As Long
  4.        hwnd As Long
  5.        uId As Long
  6.        uFlags As Long
  7.        uCallBackMessage As Long
  8.        hIcon As Long
  9.        szTip As String * 64
  10.       End Type
  11.  
  12.       'constants required by Shell_NotifyIcon API call:
  13.       Public Const NIM_ADD = &H0
  14.       Public Const NIM_MODIFY = &H1
  15.       Public Const NIM_DELETE = &H2
  16.       Public Const NIF_MESSAGE = &H1
  17.       Public Const NIF_ICON = &H2
  18.       Public Const NIF_TIP = &H4
  19.       Public Const WM_MOUSEMOVE = &H200
  20.       Public Const WM_LBUTTONDOWN = &H201     'Button down
  21.       Public Const WM_LBUTTONUP = &H202       'Button up
  22.       Public Const WM_LBUTTONDBLCLK = &H203   'Double-click
  23.       Public Const WM_RBUTTONDOWN = &H204     'Button down
  24.       Public Const WM_RBUTTONUP = &H205       'Button up
  25.       Public Const WM_RBUTTONDBLCLK = &H206   'Double-click
  26.  
  27.       Public Declare Function SetForegroundWindow Lib "user32" _
  28.       (ByVal hwnd As Long) As Long
  29.       Public Declare Function Shell_NotifyIcon Lib "shell32" _
  30.       Alias "Shell_NotifyIconA" _
  31.       (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
  32.  
  33.       Public nid As NOTIFYICONDATA
  34.  
  35.  

Form code
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.        'the form must be fully visible before calling Shell_NotifyIcon
  3.        Me.Show
  4.        Me.Refresh
  5.        With nid
  6.         .cbSize = Len(nid)
  7.         .hwnd = Me.hwnd
  8.         .uId = vbNull
  9.         .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
  10.         .uCallBackMessage = WM_MOUSEMOVE
  11.         .hIcon = Me.Icon
  12.         .szTip = "Your ToolTip" & vbNullChar
  13.        End With
  14.        Shell_NotifyIcon NIM_ADD, nid
  15.       End Sub
  16.  
  17.       Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  18.       'this procedure receives the callbacks from the System Tray icon.
  19.       Dim Result As Long
  20.       Dim msg As Long
  21.        'the value of X will vary depending upon the scalemode setting
  22.        If Me.ScaleMode = vbPixels Then
  23.         msg = X
  24.        Else
  25.         msg = X / Screen.TwipsPerPixelX
  26.        End If
  27.        Select Case msg
  28.         Case WM_LBUTTONUP        '514 restore form window
  29.          Me.WindowState = vbNormal
  30.          Result = SetForegroundWindow(Me.hwnd)
  31.          Me.Show
  32.         Case WM_LBUTTONDBLCLK    '515 restore form window
  33.          Me.WindowState = vbNormal
  34.          Result = SetForegroundWindow(Me.hwnd)
  35.          Me.Show
  36.         Case WM_RBUTTONUP        '517 display popup menu
  37.          Result = SetForegroundWindow(Me.hwnd)
  38.          Me.PopupMenu Me.mPopupSys
  39.        End Select
  40.       End Sub
  41.  
  42.       Private Sub Form_Resize()
  43.        'this is necessary to assure that the minimized window is hidden
  44.        If Me.WindowState = vbMinimized Then Me.Hide
  45.       End Sub
  46.  
  47.       Private Sub Form_Unload(Cancel As Integer)
  48.        'this removes the icon from the system tray
  49.        Shell_NotifyIcon NIM_DELETE, nid
  50.       End Sub
  51.  
  52.       Private Sub mPopExit_Click()
  53.        'called when user clicks the popup menu Exit command
  54.        Unload Me
  55.       End Sub
  56.  
  57.       Private Sub mPopRestore_Click()
  58.        'called when the user clicks the popup menu Restore command
  59.        Dim Result As Long
  60.        Me.WindowState = vbNormal
  61.        Result = SetForegroundWindow(Me.hwnd)
  62.        Me.Show
  63.       End Sub
  64.  
How would you minimize your project to the system tray. All of the ones I find on the web will not mazimize the program when it is clicked on wile in the tray.

Thanks & Cheers
Jun 27 '07 #2
pureenhanoi
175 100+
How would you minimize your project to the system tray. All of the ones I find on the web will not mazimize the program when it is clicked on wile in the tray.

Thanks & Cheers
i'm doing a project and need minimize to system tray too. I searched in Microsoft Support Center and found this articlehttp://support.microsoft.com/kb/176085/en-us
If u can open this link, go to http://support.microsoft.com and search with keyword "System Tray". The title of this article is "How to use the System Tray directly from Visual Basic".
Jun 27 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Austin | last post by:
I wrote a GUI program with wxPython. In the window, there are 3 attributes on left top. "_" could let the program to minimize to tool bar. I want to let the program minimized to the system tray....
2
by: varadha | last post by:
Hi, i want to create a VC++ application that minimizes to system tray when i minimize it. This application should be running in the background and doing it process(Just like Yahoo messanger...
4
by: mphanke | last post by:
Hi, how can I minimize an application to the tray? Snippets welcome. Martin
1
by: Xarky | last post by:
Hi, I followed the follwoing post to minimize application to system tray....
3
by: Maka Sili | last post by:
Hi, My VC++ application does not have a titlebar (and therefore no System menu, no minimize, no maximize and no close button). We have a custom button for minimize and close. When the app...
4
by: steve | last post by:
hi all, i was wondering how is it possible to add an extra box ( i think they are called boxes: upper right corner ...) in a form that will minimize it in the system tray? You know some...
8
by: Avi G | last post by:
Hi, i've created an application and i want it to be minimized to the sys tray, how i do it? if you can direct me step by step even with create a small application and put it in the sys tray ...
1
by: zakhirn | last post by:
Anyone have code that creates a button that will Minimize Excel to the system tray. I do not need anything complicated like changing the minimize button or the close button to a minimize to...
3
by: Jimmy | last post by:
I'm kinda newbie to python and wxPython. Now I'm confronting a thorny problem: how can I make my program minimize to the taskbar represented as an ico, and when there is some message from network...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.