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




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




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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

Systray Popup Menu Navigation Program
When I right click the icon of my program on the system tray, a popup menu appears but I can't navigate the menu items with a keyboard as I can in other programs. Is this a VB bug? Is there any fix for this?

Shell_NotifyIcon is used to add program to systray.

Random Focusing, And Min. To Systray
Hi,

I need help on getting my program to randomly (or in order, in order according to the alt+tab menu) set focus on programs open that are shown in the taskbar. I'm trying to get it to randomly set focus on a different application every 5 minutes or so. Could that be possible, if so, could one help me out with it?

Also, another thing would be minimizing to the system tray. YES - I've read just about every topic that I thought were useful for this, but it didnt seem to be what I needed/wanted. I'm trying to get my program to minimize to the system tray ONLY when you click on the minimize button [_], not when the [X] is clicked. All that you can do to the program when it's in the system tray it restore it, no options would be avalibe, just a double-click on the icon and it's restored. Or even possibly just a click of a CommandButton will do the same as clicking on [_] as described above.

Any help would be greatly appriciated.

Thanks.

Pop-up Menu In Systray
Hi
I'm using an ActiveX object (csystray) to place an icon on the systray.
I add a menu and try to pop it up over the icon, when someone clicks there.

I do this :
(form is set in pixels -- tried point and the same outcome -- only I can't get + 50 and -200 to work at all)

Private Sub cSysTray1_MouseDown(Button As Integer, Id As Long)
Dim P As POINTAPI
Dim D As Long
SetForegroundWindow (Form1.hwnd)
GetCursorPos P
PopupMenu Form1.mnu_to_pop_up , , P.x + 50, P.y - 200
End Sub

I do the + 50 and -200 to get a decent pop-up positioning, but I quite envy other programs in systray that pop-up the menu right above where I click the mouse.
Am I doing something wrong here?
Thanks!

SysTray.ocx Right Click Menu?
i use the SysTray.ocx that i found some where on this forum to put my app to the systray but i have a small problem.. my program is GUI less so its systray only(its an HTTP Server) i need it to when right clicked to display a menu with few buttons Restart, Stop, Exit.. kinda like apache is it possible to so the right click menu when using the ocx? thanks for any input

EDIT: i herd theres an api to do this but i like the OCX.. dont like apis

Dismiss The Systray Menu
Sorry guys, a real silly question. The context menu I've created for my program icon on the right click of the mouse at the system tray region does not disappear when I hit the escape key or click somewhere on the screen out of the menu. How do I make the menu disappear if I did not want to select anything out of the choices it offers?

Systray Popup Menu
hi,

My Application is minimised to systray ,the momemt it is started. When i right Click on the Systray Icon..the popup menu for the Application is displayed....Now when I pressthe ESC Key or Click on any other area . the popup menu is not disappearing ...it is still visible.....How can I make the popupmenu disappear by pressing ESC key or...by clicking on some other area...
Thanks..

SysTray Pop-up Menu Control
I have an option in my System tray icon's pop-up menu that has a key combo that you can use (ctrl+w) but when the program is running, I can't hit ctrl+w to execute the menu item. It works just fine if you click on it manually.

Any help here is appreciated. thanks.

Creating Pop-up Menu In Systray?
How do you create a pop-up menu when you right click on an Icon in the Systray?

Thanks,
Jeff

Dismiss The Systray Menu
Sorry guys, a real silly question. The context menu I've created for my program icon on the right click of the mouse at the system tray region does not disappear when I hit the escape key or click somewhere on the screen out of the menu. How do I make the menu disappear if I did not want to select anything out of the choices it offers?

The Little Menu On A Systray Icon
That's Ok... but before anyone asks:
VB Code:
Private Declare Function SetForegroundWindow Lib "user32" _  Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long

Menu Wont Pop-up In Systray
Sups all,
In my last app i used a popup menu in the systray and all worked perfect.
In my correct app, I wanna use a popup menu in the systray too, but it just wont popup. (i can minimized to systray but cant popup the menu. Clicks on the icon wont do nuthin.)
i'm using the same code, but i found that if i'm putting the code for the systray and menu on a different form in the app, it works.
That means that something with the other form is wrong. I dont know what...u know something about it?
how can i fix it?
and 1 more question: what is 'hwnd' and what he do?
tnx

Popup-menu In Systray
I have made a program running in the system tray. Now I want to create a menu that pops up by right-mouse-clicking on the icon from the program in the system tray. How can I do this? I already know how to let appear a form when right-mouse-clicking on the icon, but I don't want to use a form.

SysTray Menu Popup
Code:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If WindowState = vbMinimized And Button = vbRightButton Then
Me.PopupMenu mnuSysTray
End If
End Sub

This code works fine in Windows XP for when I have my program minimized to the tray so to speak, but in Windows 98/ME the Button seems to not be passed, basically when I right click, nothing happens. If I remove the second half, and just have it a mouseover, it works fine... Is there a way to get around this?

Dismiss The Systray Menu
Sorry guys, a real silly question. The context menu I've created for my program icon on the right click of the mouse at the system tray region does not disappear when I hit the escape key or click somewhere on the screen out of the menu. How do I make the menu disappear if I did not want to select anything out of the choices it offers?

Systray Menu Popup Question
Hi,

My program has a systray icon and when you right click, I have a menu popup. So far so good.

But if I right click the icon, but do not select a menu option, the menu still stays there and I have to click a menu option to mae it go away.

What can I implement a way of detecting if the user clicks away from the menu and the menu hides again.?

Thank you

SysTray Menu Popup Problem
Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If WindowState = vbMinimized And Button = vbRightButton Then
Me.PopupMenu mnuSysTray
End If
End Sub
This code works fine in Windows XP for when I have my program minimized to the tray so to speak, but in Windows 98/ME the Button seems to not be passed, basically when I right click, nothing happens. If I remove the second half, and just have it a mouseover, it works fine... Is there a way to get around this?

SysTray Popup Menu Problem?
I've created a menu within my VB app, however, I want to be able to pop it up when I click on my app icon in the systray. Does anyone have any working code that shows how to do this?

Thanks

-Blake

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 Code That Allows Menu Checksunchecks.
Hey,

Just making my program run in the system tray but the code i have doesn't seem to have the ability to allow me to make a menu item checked or unchecked. Is this easy??

I also find it hard to get my app to add and remove items from the menu easily during runtime, is there something I am doing wrong.

Thx
KT

SysTray Popup Menu Problem
Code:Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If WindowState = vbMinimized And Button = vbRightButton Then
        Me.PopupMenu mnuSysTray
    End If
End Sub
This code works fine in Windows XP for when I have my program minimized to the tray so to speak, but in Windows 98/ME the Button seems to not be passed, basically when I right click, nothing happens. If I remove the second half, and just have it a mouseover, it works fine... Is there a way to get around this?

If it helps, I am using the following to display the SysTray icon, the following code is contained in its own module:
Code:Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean

Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_RBUTTONDBLCLK = &H206
Public Const HWND_TOPMOST = -1

Public nid As NOTIFYICONDATA

Public 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
And then the following is to place it in the tray when I minimize, or take it out when I restore:
Code:If WindowState = vbMinimized Then 'Add SysTray Icon
    Me.Hide
    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 = Me.Caption & vbNullChar
    End With
    Shell_NotifyIcon NIM_ADD, nid
    Exit Sub
Else 'Remove SysTray Icon
    Shell_NotifyIcon NIM_DELETE, nid
End If



Edited by - Beefyman on 8/12/2003 7:53:23 PM

Creating A Popup Menu For Systray Icon?
Hi all

Please would someone tell me how i would go about creating a popup menu for my system-tray icon, so that when the user right-clicks a little menu comes up

thanks for any help

sorry if these are really newb questions, but it's a good way for me to learn so next time i wont have to ask the question and ill know what to do

Popup Menu Won't Disappear (Systray Issue)
My program runs in the systray and I finally got the popup menu to appear when the user right-clicks on it, but alas, a new problem arises... After the menu comes up, it won't disappear when I click away from it...(I click on the desktop, other applications, but the menu still remains ) If anyone knows how to fix this, it would be a great help. Thanks...

Add Different Program To Systray
How would I go about adding a different exe to the systray?

Got HWnd, How To Restore Window? Also, Systray Menu Problem
Hi guys, couple of things:

I have a program that tells Dreamweaver to save its files. To do this it gets the hWnd of dreamweaver, then "clicks" on the save-all menu item. It also has a function "pop DW to front", though at the moment, if DW is minimised, all it does it press the taskbar button down. How to i tell the DW window to restore, or maximise itself too?

The icon in the system tray has a right click menu, and the menu appears to have a bug. If i right click the icon the menu appears. But if i click somewhere else in windows (e.g., the desktop), the menu does not go away. If i click a dead space (like separator) on the menu, then click the desktop, it DOES go away. What bit of code have i not added to the message handling?

To demonstrate the menu problem, i have attached the exe in a zip file. The zip and associated exe are certified by http://www.kaspersky.com/remoteviruschk.html to be virus free.

Starting Program In Systray
I want to make it so a program im writing starts up automaticly with nothing showing in the taskbar, but an icon in the systray. Is that possible with VB6? If so, how do i do it?

Thanks!

Putting My Program In Systray
I have searched planetsourcecode.com and all the code that put an Application in the systray is very long, full of API and I dont understand one bit of it.

I have a program with about 9 forms, and what I want to do is to put the main form in in the systray - This is because my program has to run along another program.

Is there any easy way of doing this at all?? - I really need my program somewhere other than minimised all day.

Thanks !!

Help! How Can You Stop A Program From Using Too Much Ram When In Systray?
When i minimize my program in systray, it still uses as much ran as it does not in systray..

how can i stop all this unnecessary ram usage?

Adding Program To Systray??
How do you add your program to the systray, so that it will keep running, even if the form is minimized.

I want to make a voice recognition program, that accepts voice commands, but even if it doesn't have focus.

Thanks all,

10kman

Program Running On Systray
Hi friends
anybody can tell me about how to create a program that runs on taskbar
(systra) or in the background
thanks in advance

aravind

How To Prevent A Program From Beeing Showed In Systray
There is a small program which appears in the systray. But the program keeps repainting itself so a nice animation is shown in the systray. I found out that this costs a pretty amount of CPU so I want to 1: prevent this program from having an icon there (which seems impossible because it keeps drawing it, if it was just drawn once then it would be possible I think, so my program has to prevent the other program from calling the specific API which updates the systrayicon) or 2: remove the whole systray or 3 shutdown explorer.exe. I don't want to do number 3 because I still want to work with my computer. I would like to do 2 but I can't find any documentation on how to do this.

Anyone knows or has other ideas how to fix this?

(Actually, it is explorer.exe which takes all the CPU for drawing the picture, so I'm not even sure if disabling the systray would help. Perhaps explorer isn't that smart :S)

tnx!

Problems With "systray Popup Menu"...
Hallo everyone,
I have written a little programm which places itself in the systray,
if I click on the symbol in the systray with right mouse button a
menu opens and - here is my problem - doesn't close itself after
a certain time(if I don't choose one menu item !). How do I tell
the menu to close itself, if a certain period of time has been gone
and the user didn't choose an menu item ?
The menu stays visible even if the user changes to another task,
here's my code for the systray thing :

module :

Public Const MAX_TOOLTIP As Integer = 64
Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * MAX_TOOLTIP
End Type
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long


Form :

Private Sub Form_Load()
With nfIconData
.hWnd = Me.hWnd
.uID = Me.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon.Handle
.szTip = "Shortcuts" & Chr$(0)
.cbSize = Len(nfIconData)
End With
...
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Select Case (x Screen.TwipsPerPixelX)
Case &H204 'Rechte Maustast down
PopupMenu mnuPopup, 0, , , mnuClose
End Select
End Sub

Thanks in advance,

Greetings from Bavaria,

André

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

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