Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Minimize To SysTray!


I am minimizing a web browser application to the systray (near the clock). Clicking the systray icon (be it right-click or left-click) opens a menu with the Restore, Maximize & Exit items.

Assume that I am working with 4 applications - one of them being the browser & the rest being any application. I minimize the browser; an icon gets added to the systray. I click this icon (which opens the menu) to restore it or maximize it or to close it but then decide to leave it as it is in the minimized state. So without taking any action, I move to the rest of the open applications. Note that the icon menu also remains as it is.

Under such circumstances, what I find that leaving the icon menu open & moving to another application doesn't close the icon menu. Moreover when I click the other applications on the TaskBar to work with any of them, I find that they don't "come" forward; rather their icons on the TaskBar go on blinking till I either invoke the menu of the browser icon from the systray & do something with it or move from one application to another using Alt+Tab.

Now why is this happeniing & how do I prevent this from happening?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Minimize To SysTray
I notice there are(and have been) quite a few queries on this topic.

I think this would be a candidate for the CodeBank ?

I think something as simple(to use) as -
Icon loads into systray on Form_Load.
When user clicks the Icon it shows the Form, if not showing.
It hides the Form if it is showing.
It has no right click popup menu.
It does not require double click
The Form never shows in the Taskbar.

Just click to show Form, and click to hide Form.

No menus (although a hidden popup menu in design mode, may be required to get it working ?)

Is anyone aware of an example like that ?

How To Minimize App. To Systray....
This is sort of a noob question, but how do you make a form go to the systray, with its icon, when you click the X button?

Systray Minimize
Although I know there are many examples here how to do this I have a little twist on the problem... I need to minimize an external program ( i.e: Outlook) to the system tray.

Any examples or advice would be great!

Minimize To Systray
Hi.
I use IDontKnow's systray code and it works perfect. But i havent got this to work.

I have a form, and when the user press the minimize button on the form i want the form to disappear from the taskbar. And when he doubleclick the systray icon it shows again.

So what i need to know is how i can trigger the form1.hide from the minimize button and how i can enable the minimize button even if the form is set to fixed size.

Thanks in advance, Anders

Minimize To SysTray
Hi All,

I've setup my program so that I can use a systray icon, and removed the taskbar icon. However, when I minimize my program, it minimizes to the corner of the screen (on top of the taskbar) instead of disappearing to the tray. Any idea what I can do to fix this?

Thanks

Minimize MDI Form To Systray
right, this is driving me up the wall! i found some code to minimize my MDI form to the systray, and then allows the user to either double-click the icon to restore the window, or right-click it to get a menu that allows them to restore or exit.

this all works fine in the IDE, but when it's compiled, it doesn't react to any mouse clicks on the icon, so i can't restore the window.

the thing that's making me drive further up the wall is the fact that the sample program that i got the code from works fine in the IDE and when compiled (it's also an MDI project, and i just copy/pasted the code).

this is the code that it seems to have trouble with:


VB Code:
Private Sub MDIForm_MouseMove(Button As Integer, Shift As Integer, _x As Single, Y As Single)    If (Me.ScaleWidth = vbPixels) Then        lngMsg = x    Else        lngMsg = x / Screen.TwipsPerPixelX    End If        Select Case lngMsg        Case WM_LBUTTONDBLCLK    '515: Restore form window            Me.WindowState = vbMaximized            lngResult = SetForegroundWindow(Me.hwnd)            Shell_NotifyIcon NIM_DELETE, nid            Me.Show        Case WM_RBUTTONUP        '517: Display popup menu            lngResult = SetForegroundWindow(Me.hwnd)            Me.PopupMenu mnuSystray    End SelectEnd Sub


any ideas why this isn't working? thanks.

Minimize To Systray Still Shows Title Bar
I followed the tutorial on min to systray and this now works fine. However, i have set showintaskbar to false and when i min to systray it still appears as a moveable title bar on my desktop (sorry i dont know what the correct title for this thing is - basically the head of my form). Any ideas how to remove this so when i min to systray i'm left with no trace of the program until I double click (on systray icon) to return it?

Thanks

Minimize To Systray Without Menu Editor
hi, I am trying to find a way to minimize an app to the systray without using the menueditor.
I am using vbshape form creator to make an odd shape form, when ever I use the menu editor it puts the title bart bacck on and wrecks my form shape?

Systray Menu Appears At Random When Program Is Not In Systray
I have a menu that is only supposed to appear when the icon in the system tray is clicked. It works fine from the system tray. But when I have the program opened the menu will appear at random times and locations. Why?

I put the debug commands in to notifiy me when the event(s) fire. This problem also occurs in all of my other programs that have this code BUT ONLY if there is a right click menu associated with that icon. I have already run Windows Update and installed VB6 SP6.

The code I am using I got from msdn.microsoft.com.


Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'intDebugCnt is located in the General Declarations section of the form
intDebugCnt = intDebugCnt + 1
Debug.Print MODULE_NAME & "Form_MouseMove" & intDebugCnt

Dim Result As Long
Dim msg As Long

If Me.ScaleMode = vbPixels Then
msg = X
Else
msg = X / Screen.TwipsPerPixelX
End If

Debug.Print "X = " & X

Select Case msg
Case WM_RBUTTONUP
Debug.Print "WM_RBUTTONUP"
'517 - Display popup menu
Result = SetForegroundWindow(Me.hwnd)
Me.PopupMenu Me.mnuSysTray
Case WM_LBUTTONDBLCLK
Debug.Print "WM_LBUTTONDBLCLK"
'515 - Restore frmMain
Me.WindowState = vbNormal
cmdReturnToTray.visible = True
Result = SetForegroundWindow(Me.hwnd)
Me.Show
End Select
End Sub

How Can I Add A Systray Icon And A Systray Menu.
SupZ.... I got as pic that i want to be the systray icon. I dono how to addit. I also need to add clicking options to the icon. ex: If I right click it , a menu pups up and sais about , exit and so on. when left clicked, It restores the program.

Help?

Th,x L8ter

How Do I Minimize A Form Without Clicking The Minimize Button???
Hi,

I would like to mimimize a form with a button called cmdMinimize???

Thanks

How Can Minimize Button Act As Minimize To Tray ?
how can minimize button act as Minimize to tray ?

i have separate button for............ Minimize To Tray........ but i want that..... my minimize button of form must work as minimize to tray !! how can i do that !!

Type "minimize" To Minimize Form1 ***SOLVED***
hi
I have this code:

VB Code:
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then    If Text1.Text = "minimize" Then        Form1.WindowState = 1        Text1.Text = ""    Else         Text2.Text = Text1.Text        Text1.Text = ""    End IfEnd IfEnd Sub

when i press Enter, it cleans Text1 but also create a new line...
then if I type something; press Enter; then try to minimize, it doesn't work
What can I do

Thanks

Add A Button In Front Of The Minimize-button Kind Of 'minimize-to-system-tray-button'
At the moment I'm trying to add an icon in the system tray for my app - maybe i'll make it.
When I have made it I'd like to add a button in front of the min-button on the title bar of the apps form (like the one on All-API's API-Guide ), in order to empower the user to minimize the app even further, i.e. to the system tray - how can this be achieved?

thx,

Helger

Systray?
how to send program to systray, and, then when i click on his icon, it restores?

Systray
I need a really good systray source code if you know which one is good please tell me. I dont want one that minimize into tray i want one that closes into tray. When click minimize it still minimizes into the taskbar.


-Hao Li-

Systray
How do make my software appear in the system tray with an icon when minimized and how do i make a menu when right-clicked on the icon in system tray.

Please help thanx

-Hao Li-

Systray
I am trying to make my program only show up in the systray. I know this is a common thing, however I did a search and did not find too much.
http://www.google.com/search?hs=tDe&...um&btnG=Search

One thing I found was fairly complicated. Anyways, I was wondering what you would recommend to do the job? Thanks.
http://www.xtremevbtalk.com/showthread.php?t=19087

Systray
What is the simplest code to make a program that run in systray ??

PLZ help me

Systray
how to make a vb application to be included inside the systray such as MSN or ICQ?

Systray Help
Hi, I got the following code example from here. How can I change it so that when a user clicks on the "X" button the program goes to the system tray instead of when the user clicks on the "-"minibuton.
Thanks

Code Code:
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
'declaration for putting the application to system tray
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

    'declare constants
Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const WM_MOUSEMOVE = &H200
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4

'The following constants are used to determine the mouse input on the

    'Left-click
Private Const WM_LBUTTONDBLCLK = &H203   'Double click
Private Const WM_LBUTTONDOWN = &H201     'down
Private Const WM_LBUTTONUP = &H202       'up

    'Right-click
Private Const WM_RBUTTONDBLCLK = &H206   'Double click
Private Const WM_RBUTTONDOWN = &H204     'down
Private Const WM_RBUTTONUP = &H205       'up

'Dimension a variable as the user-defined data type.
Dim nid As NOTIFYICONDATA


Private Sub Ex_Click()
Unload Me
Shell_NotifyIcon NIM_DELETE, nid 'Delete the form's icon from the sys tray
End Sub
'   one main menu by Caption"Menu" name "TrayMenu"
'   one sub menu by name caption "Exit" name "Ex"
'   one sub menu by name caption "Show" name "Show"

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim msg As Long
Dim sFilter As String
msg = X / Screen.TwipsPerPixelX
    Select Case msg
        Case WM_LBUTTONDOWN
            MsgBox "you clicked me!"
        '      Me.PopupMenu TrayMenu   'if u want u can call the popup menu
        Case WM_LBUTTONUP
        Case WM_LBUTTONDBLCLK
        Case WM_RBUTTONDOWN
        Case WM_RBUTTONUP
            Me.PopupMenu TrayMenu  'call the popup menu
        Case WM_RBUTTONDBLCLK
    End Select
End Sub


Private Sub Form_Resize()
If Me.WindowState = 1 Then

    Me.Hide
    nid.cbSize = Len(nid)
        nid.hwnd = Me.hwnd
        nid.uId = vbNull
        nid.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
        nid.uCallBackMessage = WM_MOUSEMOVE
        nid.hIcon = Me.Icon
        'u can give a tool tip text here
        nid.szTip = "My System Tray Message" & vbNullChar
       'Call the Shell_NotifyIcon function to add the icon to the System Tray, defulte form's icon

        Shell_NotifyIcon NIM_ADD, nid
        Else
End If
End Sub

Private Sub Show_Click()
Me.WindowState = 0
Me.Show
Shell_NotifyIcon NIM_DELETE, nid 'Delete the form's icon from the sys tray
End Sub

Systray
i cant seem to find this code on the internet, so there might not be one.

I am trying to hide the system tray so just the clock and the taskbar is showing.

Please let me know if it is possible, and if you know the code please post it.

Systray
Hi
I have a VB6 program that alert the user about his schedule,I want to include a shortcut of this program into the systray toolbar.
Also,upon starting up the PC,i want to load this program

How can I do it?
thanks

Systray Help
Hey, I cant seem to get ANY of the examples of minimizing to the System tray and then restoring the form when clicking the icon to work. With every example it minimizes fine, but then the Icon just sits in the systray.

Please help me out with this. Sorry for the inconvience..

- BorT

Need Help With Systray App
I've tried to get my systray app to work, but i haven't managed in 4 hours, so i'm kinda tired at it. If anyone could take a look at it, I would be grateful.

if you want any more info, just tell me

Systray IP
*first post first thread*

Alright im making a very very simple program that hides in the notification area by the clock down at the task bar, that when you hover over the icon it shows your IP address.

I already made the code for getting the local IP, i know its one line of code its easy, and right now all my program does is change the form caption to the IP address. I was guessing that you needed to do this in order for the tooltip to display the IP.

Systray
How to make an application go to the systray when it's minimized?
I mean only to the systray so it's not shown in the taskbar.
thx

My Own Systray????
Hi again.
I would like to make my own systray, but I don't know how to handle programs, which want to show an icon in it. Know this somebody?



------------------
Thanks,
John, 14 years old

App In Systray
Is there a way to determine if my current app is also running in the systray?

Systray
How can I add my program link in systray.

Who Try This ? (VB6 From Systray)
Hello,

I don't know if somebody have experience this !

If you call a VB program from the systray (SE: Windows ME and Office 2000), it launch systematically the Microsoft Office 2000 SETUP !...

I have try to put only the call of VB6.EXE in the systray and I get the same problem (see bitmap)

Please HELP !.....

Thanks,
Thierry Demoy

Systray
Can somebody plese tell me how i can put the program sortoff into the systray so that i can control it?

can it be done?

SysTray
Is there any way (VB or not) that i can get rid of the systray icon without closing the program down, in particular the program Mirc, I wanna it that way so the program is hidden when on

Thanks

SysTray????
Is there any way (VB or not) that i can get rid of a tray icon, in particular the mirc tray icon when its minimized....?


Thanks

SysTray
Hi, I have the following code which tells when the user has clicked on my minimized-to-systray icon.


Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim msgCallBackMessage As Long
msgCallBackMessage = X / Screen.TwipsPerPixelX
Select Case msgCallBackMessage
Case WM_MOUSEMOVE: MySysTray.TipText = MySysTray.PopUpMessage
Case WM_LBUTTONDOWN: Me.Show
Case WM_RBUTTONDOWN: MsgBox "BSS Action Centre - Unisys Ltd"
End Select
End Sub


I want it to behave like a normal icon, which you have to double click (like outlooks email envelope). How can I go about doing this?

SysTray Help Please!
I've created a program that shrinks into the systray the only problem is that I can't seem to be able to show a menu of some sort on the right mouse click?

Help!

Systray
i am working on ticker application ..where data scroll in a form ..how can i place this ticker the systray..in the lines of yahoo ticker

SysTray.ocx
Can anyone explain to me how I use this damn thing - it was working fine under VB5, now all the properties seem to have changed....

Own Systray
how can i make my own systray..ie. icons added when programs like icq start, etc. i need this for a shell replacement btw, cos not having systray icons is really annoying

SysTray
How do I change the icon Of my Appl in the systray?

Thanks

SysTray!!!
Does someone know how to put a clock in the SysTray? Yes, I know it´s already a clock there but i want to do one on my own. So can someone solve this little problem fo me?¿

SysTray
Add an Invisible Picturebox to your Form, then Paste this Code:

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

If you want it even simpler I believe there's an OCX available on this site somewhere, which bascially does all this in the background.

Only downside is you have to ship the OCX with your Project.

------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

SYSTRAY
Hi I am trying to make my application hide and show a icon in the system tray. I found some code to do this and it seems to work in the example but when I run my code it dosen't work.


Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim Msg As Long

Msg = X
' The message is passed to the X value

' You must set your form's ScaleMode property to pixels in order to get the correct message

If Msg = WM_LBUTTONDBLCLK Then
' The user has double-clicked your icon

Call mnuShow_Click
' Show the window

ElseIf Msg = WM_RBUTTONDOWN Then
' Right-click

PopupMenu mnuPopup
' Popup the menu

End If

End Sub



It seems that the X variable never changes so the condition never gets meet. Even though this works on the sample program. Thank you for you help in advance.

Systray
there's loads of code around that allows a program to minimize to the systray and have a pop-up menu. but none of it (that ive found at least) lets u change the icon used without first removing it and then adding it again. id also like to be able to use icons with more than 16 colours

anyone help??

Systray
How can I write a program which is not shown in the Task Bar but has an Icon in the SysTray.

Please help

mfG Pueromane

Icon In Systray Bug
I follow the tutorial gave by MS in the linkhttp://support.microsoft.com/default...;en-us;Q162613 , with the following code

<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

'Declare the constants for the API function. These constants can be
'found in the header file Shellapi.h.

'The following constants are the messages sent to the
'Shell_NotifyIcon function to add, modify, or delete an icon from the
'taskbar status area.
Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2

'The following constant is the message sent when a mouse event occurs
'within the rectangular boundaries of the icon in the taskbar status
'area.
Private Const WM_MOUSEMOVE = &H200

'The following constants are the flags that indicate the valid
'members of the NOTIFYICONDATA data type.
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4

'The following constants are used to determine the mouse input on the
'the icon in the taskbar status area.

'Left-click constants.
Private Const WM_LBUTTONDBLCLK = &H203 'Double-click
Private Const WM_LBUTTONDOWN = &H201 'Button down
Private Const WM_LBUTTONUP = &H202 'Button up

'Right-click constants.
Private Const WM_RBUTTONDBLCLK = &H206 'Double-click
Private Const WM_RBUTTONDOWN = &H204 'Button down
Private Const WM_RBUTTONUP = &H205 'Button up

'Declare the API function call.
Private Declare Function Shell_NotifyIcon Lib "shell32" _
Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean

'Dimension a variable as the user-defined data type.
Dim nid As NOTIFYICONDATA

Private Sub Command1_Click()
'Click this button to add an icon to the taskbar status area.

'Set the individual values of the NOTIFYICONDATA data type.
nid.cbSize = Len(nid)
nid.hWnd = Form1.hWnd
nid.uId = vbNull
nid.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
nid.uCallBackMessage = WM_MOUSEMOVE
nid.hIcon = Form1.Icon
nid.szTip = "Taskbar Status Area Sample Program" & vbNullChar

'Call the Shell_NotifyIcon function to add the icon to the taskbar
'status area.
Shell_NotifyIcon NIM_ADD, nid
End Sub

Private Sub Command2_Click()
'Click this button to delete the added icon from the taskbar
'status area by calling the Shell_NotifyIcon function.
Shell_NotifyIcon NIM_DELETE, nid
End Sub

Private Sub Form_Load()
'Set the captions of the command button when the form loads.
Command1.Caption = "Add an Icon"
Command2.Caption = "Delete Icon"
End Sub

Private Sub Form_Terminate()
'Delete the added icon from the taskbar status area when the
'program ends.
Shell_NotifyIcon NIM_DELETE, nid
End Sub

Private Sub Form_MouseMove _
(Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)
'Event occurs when the mouse pointer is within the rectangular
'boundaries of the icon in the taskbar status area.
Dim msg As Long
Dim sFilter As String
msg = X / Screen.TwipsPerPixelX
Select Case msg
Case WM_LBUTTONDOWN
Case WM_LBUTTONUP
Case WM_LBUTTONDBLCLK
CommonDialog1.DialogTitle = "Select an Icon"
sFilter = "Icon Files (*.ico)|*.ico"
sFilter = sFilter & "|All Files (*.*)|*.*"
CommonDialog1.Filter = sFilter
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Form1.Icon = LoadPicture(CommonDialog1.FileName)
nid.hIcon = Form1.Icon
Shell_NotifyIcon NIM_MODIFY, nid
End If
Case WM_RBUTTONDOWN
Dim ToolTipString As String
ToolTipString = InputBox("Enter the new ToolTip:", _
"Change ToolTip")
If ToolTipString <> "" Then
nid.szTip = ToolTipString & vbNullChar
Shell_NotifyIcon NIM_MODIFY, nid
End If
Case WM_RBUTTONUP
Case WM_RBUTTONDBLCLK
End Select
End Sub

</code>

It works fine, but always you move the mouse in the right, top-right portion of the form (if it is maximized) it sends the WM_LBUTTONDBLCLK message. Somebody knows how to fix it ? It's incredible that MS has published this code with this bug...

Systray ? (yes I Searched)
All the code I have found for minimizing to systemtray uses the minimize button(which i think is this: Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single), well what if i want to use an image? ... Private Sub imgPoop_Click(Button As Integer, Shift As Integer, X As Single, Y As Single) doesnt work...didnt think it would...but you might see what im saying, anyone know?

SysTray.OCX Problems
i have an app that I am trying to minimize to the systray and that all works fine but I need to change the icon to some thing else that the standard thing. only problem is that it wont let me change it at all.

i have tried to set the icon in the properties but it doesn't change it

I have tried this code to change it also

Code:
Private Sub Command2_Click()
Form1.Hide
cSysTray1.InTray = True
cSysTray1.TrayIcon = App.Path & " emp.bmp" 'but I get an error saying invalid use of property here
End Sub

Any ideas on why it wont let me change the icon?

Thanks for any help

GeeK

Application In Systray...
I want to put my application in the systray instead of the taskbar. I know who to remove it from the taskbar but how can I place an icon in the systray?

I want to minimize and maximize the application using the systray icon.

Any help would be appreciated

Copyright © 2005-08 www.BigResource.com, All rights reserved