Old 30th July 2003, 15:27   #1
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Tray icon

It would be great if anyone can show me how to get the installer to display in the System Tray area on the Windows task bar.
I doubt this is possible, but it would sure be nice for my program - it downloads updates for my game, which can take hours (if many updates)

Thanks

-Stu
Afrow UK is offline   Reply With Quote
Old 30th July 2003, 23:29   #2
Vytautas
Major Dude
 
Vytautas's Avatar
 
Join Date: May 2003
Location: Victoria, Australia
Posts: 643
Send a message via ICQ to Vytautas
You should be able to do it using the APIs and system plugin. Not sure of the actual call but will check it out.

Vytautas
Vytautas is offline   Reply With Quote
Old 30th July 2003, 23:41   #3
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Shell_NotifyIcon is the API call...


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 30th July 2003, 23:46   #4
Vytautas
Major Dude
 
Vytautas's Avatar
 
Join Date: May 2003
Location: Victoria, Australia
Posts: 643
Send a message via ICQ to Vytautas
I found some info about Shell_NotifyIcon at this site. I know it's for VB but someone should be able to convert it to system plugin code.

Vytautas
Vytautas is offline   Reply With Quote
Old 31st July 2003, 09:21   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I know hardly anything about using System plugin let alone VB.

Help would be much appreciated!

-Stu
Afrow UK is offline   Reply With Quote
Old 31st July 2003, 22:33   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Can anyone help me on this one please

-Stu
Afrow UK is offline   Reply With Quote
Old 1st August 2003, 00:09   #7
RDaneel
Member
 
Join Date: Nov 2001
Location: Seattle, Washington
Posts: 78
Well, probably the best thing I can do for you (besides writing your installer for you ) is to give you a conceptual model for "tray stuff".

First off, things are fairly simple, and do indeed revolve around the Shell_NotifyIcon API call... the one problem I can see has, I think, been discussed here before - how to receive [Windows] messages sent to your NSIS installer process.

Anyway, at its simplest, when you want to go into the tray, you set your app (NSIS installer in this case) to be invisible by doing a Win32 API call of ShowWindow(SW_HIDE), and immediately tell Windows to display your icon in the tray, using the Shell_NotifyIcon call.

Flipping back to non-tray operation is just the reverse - set your main window back to the visible state, and tell Windows to delete your icon from the tray.

Now, the tricks - when you first go into the tray, along with an icon handle, you tell Windows to use some user-defined Windows message of your choice to inform you of things the user does to your tray icon, like left- or right- clicking it etc. Clearly, if you are unable to get your hands on this message when Windows sends it to your NSIS installer, you will have a problem communicating with your user. Hopefully someone else (Joost?) can assist you with this...

Finally, you will need to feel comfortable using the System plugin, both for simple calls, and for creating/interpreting the data structures used with the Shell_NotifyIcon API call... not to mention checking out the documentation on the handful of Windows API calls involved:

* Shell_NotifyIcon
* ShowWindow
* LoadImage (for getting your icon handle, although you might have some other access to your icon already buried in your NSIS installer).

Good luck!
RDaneel is offline   Reply With Quote
Old 1st August 2003, 12:25   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Thanks for your help!
The reason I cannot start to properly understand the System plugin, is due to the fact that I know nothing about C++, C or hardly any VB!

I know that Brainsucker would have the ultimate solution to this straight off, but he seems to be away atm

-Stu
Afrow UK is offline   Reply With Quote
Old 1st August 2003, 15:17   #9
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
The thing is in this part:
code:

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


is important for the API call:
Declare Function Shell_NotifyIcon Lib "shell32.dll" \ Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
I don't think that's possible with NSIS...
A less, as you wrote, Mr. Brain popup a good example code solution.


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 1st August 2003, 16:18   #10
Vytautas
Major Dude
 
Vytautas's Avatar
 
Join Date: May 2003
Location: Victoria, Australia
Posts: 643
Send a message via ICQ to Vytautas
I am 99% sure that this will be posible with nsis. The declaration can be done using the system dll as it only allocates memory. It's too late tonight for me to this this through, almost 03:30 in the morning. I'll have another look tomorrow.

Vytautas
Vytautas is offline   Reply With Quote
Old 1st August 2003, 16:20   #11
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Thank you

#me awaits patiently

-Stu
Afrow UK is offline   Reply With Quote
Old 2nd August 2003, 11:52   #12
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I notice brainsucker is online atm ...

-Stu
Afrow UK is offline   Reply With Quote
Old 2nd August 2003, 12:05   #13
brainsucker
Senior Member
 
brainsucker's Avatar
 
Join Date: Sep 2002
Location: Minsk, Belarus
Posts: 190
Send a message via ICQ to brainsucker
You could create taskbar icon, modify or delete it, but it is hard to react to it. However:


; ---------- Some declarations -----------
;typedef struct _NOTIFYICONDATA {
; DWORD cbSize;
; HWND hWnd;
; UINT uID;
; UINT uFlags;
; UINT uCallbackMessage;
; HICON hIcon;
; TCHAR szTip[64];
;}
!define stNOTIFYICONDATA '(&l4, i, i, i, i, i, &t64) i'

!define NIF_MESSAGE 0x00000001
!define NIF_ICON 0x00000002
!define NIF_TIP 0x00000004
!define NIM_ADD 0x00000000
!define NIM_MODIFY 0x00000001
!define NIM_DELETE 0x00000002

; ----------- To Add icon ---------------
; use [t "iconfilename"] instead of [i 32514] to specify your icon,
; or if you already have your icon handle you can use it instead of r2
; at structure creation time
System::Call 'User32::LoadIconA(i 0, i 32514) i .r2'
System::Call '*${stNOTIFYICONDATA}(, $HWNDPARENT, 0, ${NIF_TIP}|${NIF_ICON}, 0, r2, "How do you like this?") .r0'
System::Call 'Shell32::Shell_NotifyIcon(i ${NIM_ADD}, i r0) i.r1'

; ----------- To Modify icon ---------------
System::Call '*$0${stNOTIFYICONDATA}(,,,,,, "Another icon tip...")'
System::Call 'Shell32::Shell_NotifyIcon(i ${NIM_MODIFY}, i r0) i.r1'

; ----------- To Delete icon ---------------
System::Call 'Shell32::Shell_NotifyIcon(i ${NIM_DELETE}, i r0) i.r1'
System::Free $0
brainsucker is offline   Reply With Quote
Old 2nd August 2003, 13:34   #14
brainsucker
Senior Member
 
brainsucker's Avatar
 
Join Date: Sep 2002
Location: Minsk, Belarus
Posts: 190
Send a message via ICQ to brainsucker
Quote:
I notice brainsucker is online atm ...
brainsucker is offline   Reply With Quote
Old 2nd August 2003, 14:06   #15
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
wow! it's easy...easier than Visual Basic
Cool dude


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 2nd August 2003, 16:59   #16
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Hmm, theres a problem with the code to unload the tray icon.
Sometimes it works, sometimes it doesn't, but it always brings up a crash.

Can anyone see whats wrong with it?

Thanks, this is excellent!

-Stu
Afrow UK is offline   Reply With Quote
Old 2nd August 2003, 17:01   #17
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Ok, also it seems that if I hover my mouse over the tray icon, it dissapears too.

-Stu
Afrow UK is offline   Reply With Quote
Old 2nd August 2003, 17:11   #18
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Where do you put:
code:

System::Call 'Shell32::Shell_NotifyIcon(i ${NIM_DELETE}, i r0) i.r1'
System::Free $0



* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 2nd August 2003, 17:47   #19
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I have placed it in my abort/instsuccess functions.

-Stu
Afrow UK is offline   Reply With Quote
Old 2nd August 2003, 19:12   #20
RDaneel
Member
 
Join Date: Nov 2001
Location: Seattle, Washington
Posts: 78
Well, brainsucker *is* Mr System plug-in, as I understand it, but the rest of us aren't, so there may be some less-obvious things to look at here

1) so we are all clear on what is happening, the Shell_NotifyIcon API call needs a NOTIFYICONDATA data structure passed in to it EVERY time... since $0 is being used to hang on to a pointer to this structure, you must make sure that $0 is not overwritten by any other code during the time between the NIM_ADD and NIM_DELETE calls

2) while the example shown is apparently using some magic in the System plug-in to allocate (and fill in) this data structure the first time (just prior to the NIM_ADD call), note that if you use the example code for the NIM_DELETE call, this data structure is released with the System::Free, and the whole initial sequence (the setup code for the NIM_ADD) must be executed again

3) when initializing the structure, the first element *must* be filled in with the size in BYTES of the entire structure... this should be happening with the "&l4" in the structure def, but has the actual value been verified? Actually, there are some semi-trick cases to consider here, since the size specified is used by Windows to decide which version of the Shell_NotifyIcon API to offer/use... the example code will *probably* make the system think that you are only using the "ancient" Win95/WinNT features of this API, which would mean that the example structure will work

4) the NIM_MODIFY sequence will (as shown) modify the TOOLTIP, not the ICON (either or both are possible)... just a comment on the comment

5) finally, *don't* blow off brainsucker's first line of the example post - the "but it is hard to react to it" is echoing my earlier remarks about receiving the Windows messages sent back to your NSIS installer to tell you when the user "does something" to your tray icon... if it is your intention to use the tray completely non-interactively, fine - otherwise, this issue will have to be addressed
RDaneel is offline   Reply With Quote
Old 2nd August 2003, 19:18   #21
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
The idea was so that the installer would not be listed on the task bar, but be instead an icon on the task bar instead.
The user would be able to right/left click to open the installer again.

I have changed it to use $4 instead (haven't used that in my script)
It now does not crash, but it still dissapears on mouseover.

Thanks

-Stu
Afrow UK is offline   Reply With Quote
Old 2nd August 2003, 23:42   #22
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Ops,

The idea was so that the installer would not be listed on the task bar, but be instead an icon on the sys tray instead.
Afrow UK is offline   Reply With Quote
Old 3rd August 2003, 21:28   #23
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Well, the code seems to work on Win98SE, but on WinXP the icon just dissappears on mouse-over.

-Stu
Afrow UK is offline   Reply With Quote
Old 4th August 2003, 02:06   #24
RDaneel
Member
 
Join Date: Nov 2001
Location: Seattle, Washington
Posts: 78
You haven't mentioned whether you think the system is just disappearing your tray icon on you, or your code to make it go away is being invoked... when the icon goes away (on XP), does your app go away too (i.e., it's no longer on the system tasklist)?

Why don't you put debug output to the NSIS log page when *any* of the Shell_NotifyIcon calls are made - this is a way to get more data on what may be happening. Also, if you are worried about being able to *see* the log because your NSIS installer is invisible, just don't turn off visibility to start with when you first make the icon show in the tray.
RDaneel is offline   Reply With Quote
Old 4th August 2003, 12:12   #25
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
The tray icon dissappears on mouseover (like I said) while the program is running, not when it has been shut down.
This happens on WinXP only.
The icon shows it's label correctly (displays the text) on mouseover on Win98/NT.
Afrow UK is offline   Reply With Quote
Old 4th August 2003, 14:54   #26
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Ok...
according to my recent research about system plugin...
Shell_NotifyIcon it's a call like Visual Basic handles..
Shell_NotifyIconA is the called for the plugin.


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 4th August 2003, 17:45   #27
RDaneel
Member
 
Join Date: Nov 2001
Location: Seattle, Washington
Posts: 78
Ummm, "Major Dude", get the trace/debug info as suggested above. It is more likely that your NSIS code is [inadvertently] removing the tray icon than that XP is spontaneously doing it.

"Forum King", the real deal is that most of the Win32 API calls that handle text actually have *2* entry points: one with "A" appended, and one with "W".

In this particular case, then, the Shell32 DLL has both Shell_NotifyIconA and Shell_NotifyIconW. There *is* no "Shell_NotifyIcon" version of the call in reality - in programming land, your development environment maps this generic version of the name to one of the real ones... either the "A" version for ASCII text, or the "W" version for Unicode.

So, if things work at all as shown in brainsucker's example, I would expect it is because the System plug-in, when it fails on a GetProcAddress call, automatically retries with "A" appended to the supplied API entry point.
RDaneel is offline   Reply With Quote
Old 4th August 2003, 19:07   #28
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
After placing brainsuckers' code into an empty script, that does not use any variables (except for the System code itself) my problem persists where the icon just dissappears on mouse-over.

-Stu
Afrow UK is offline   Reply With Quote
Old 5th August 2003, 14:21   #29
brainsucker
Senior Member
 
brainsucker's Avatar
 
Join Date: Sep 2002
Location: Minsk, Belarus
Posts: 190
Send a message via ICQ to brainsucker
Afrow UK: It's the most likely you've forgotten to add

SetPluginUnload alwaysoff

option at the script start (or /nounload to every system call).
Don't forget to add

SetPluginUnload manual

before the last system call (or fake System::Free 0 call).

RDaneel:
0. thanx for you comments
1. I've spent to many time debuggin &l option, so there is no one chance it'll fail!!!
2. System does nothing with the letter A at the proc name end, I've just forgotten to add it... The way it works?... Hmm.. Shell32.dll contains proc version without any letters, may be because it could determine which structure (unicode or ascii) passed to it by cbSize member (there are no other string params, as you see).

P.S. I'll post notifyicon plugin ASAP, which will solve all the problems (the icons at TNA and removing the window from taskbar).
brainsucker is offline   Reply With Quote
Old 5th August 2003, 15:20   #30
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
OMG BRAINSUCKER!!!!
/me saw the last P.S.

You are the most amazing guy on the net - seriously, you writing a plugin just like that wow!!

So, will this plugin have support for simple sys tray icon click - opens program, or even more!?

-Stu
Afrow UK is offline   Reply With Quote
Old 5th August 2003, 15:30   #31
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Quote:
Originally posted by brainsucker

2. System does nothing with the letter A at the proc name end
Just to be clear: I used the term "A" for the conversion from
Visual Basic 4/5/6 API declare function to system plugin syntax


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 5th August 2003, 17:46   #32
RDaneel
Member
 
Join Date: Nov 2001
Location: Seattle, Washington
Posts: 78
brainsucker,

You certainly are an energetic person!

Really, be careful with the A/W thing - in general, the A/W naming convention *is* the rule in Win32 system API calls that have any dealings with text, whether as parameters, or in this case, in a structure that is a parameter.

As it happens, for *some* of the API calls, an additional entry point (without A/W) is defined to be the same as the entry point for the "A" version of the call... but not all of them!

So, while Shell_NotifyIcon does have the "extra" entry point, others do not (e.g., ShellAbout and ShellExecute).

Hmmm... might you want to include the strategy on failed GetProcAdress calls that I mentioned earlier (you would only need to make this change in one place)? If you/we can convince yourself/ourselves that the "A" version is probably what the NSIS scripter actually meant to use, this *could* save some confusion - at the cost of further obscuring how things actually work, of course.
RDaneel is offline   Reply With Quote
Old 5th August 2003, 22:16   #33
brainsucker
Senior Member
 
brainsucker's Avatar
 
Join Date: Sep 2002
Location: Minsk, Belarus
Posts: 190
Send a message via ICQ to brainsucker
Afrow UK: I'm thinking about right click menu, but it'll have a little sense anyway (there are 2 ways I see, and both are ugly: 1. assign some variable some value on menu selection, and then check it thru the script 2. Pool some plugin function which will return menu status). Any ideas about additional functionality?

RDaneel:
"Really, be careful with the A/W thing"
I've just forgotten that damn letter!!!!

System+A: ok... good idea.
brainsucker is offline   Reply With Quote
Old 5th August 2003, 22:36   #34
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I think it wouldn't be possible for nsis programs to recieve the values from the menu.
Because NSIS only runs the codes in different places (in oninit, after a page etc) not constantly...

We can forget the return values I suppose.
It's just up to the dll now to bring the program on-top when the user clicks on the sys tray icon.
You could allow additional defines when calling the plugin (no idea what plugin is called but,)

TrayIcon::Load "Icon" "Hover title"
TrayIcon::Menu "TI_MINIMIZE, TI_OPEN" "Menu header text"
TrayIcon::Close

Going over the top would be, I dunno...

TrayIcon::Menu "SubMenu('Readme'), Menu('Open Readme', exec $INSTDIR\readme.txt)"

This would create a submenu, which on moueover brings up a second menu which inturn has a button to open the installer readme.

lol

-Stu
Afrow UK is offline   Reply With Quote
Old 8th August 2003, 22:15   #35
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Afrow, where did you put the creation code? It must not be in .onInit because in there $HWNDPARENT is not valid.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 9th August 2003, 13:02   #36
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Thanks, but after moving it to GUIInit or one of my custom pages, the installer would just crash onInit, and wouldn't even reach any dialogs.

-Stu
Afrow UK is offline   Reply With Quote
Old 9th August 2003, 13:04   #37
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
May I ask how the plugin is going?
I have till next weekend to prepare for the release of my 12 map D-Day campaign, along with the release of my NSIS installer.

It would be nice to get the tray icon working by then, but I can always release the installer (program) again later (It has built in updater).

-Stu
Afrow UK is offline   Reply With Quote
Old 10th August 2003, 10:55   #38
brainsucker
Senior Member
 
brainsucker's Avatar
 
Join Date: Sep 2002
Location: Minsk, Belarus
Posts: 190
Send a message via ICQ to brainsucker
Sorry... I've got some immediate work (programming USB device).... so ASAP. ;(

BTW, would you like to remove program from taskbar on minimize only, or at any time?
brainsucker is offline   Reply With Quote
Old 10th August 2003, 11:06   #39
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Well, it at the moment I've used System code to remove the taskbar item perminantly for the settings tab (which is executed with ExecWait)
But, indeed yes, it would be nice if the taskbar item dissapeared on minimize.

-Stu
Afrow UK is offline   Reply With Quote
Old 10th August 2003, 22:13   #40
brainsucker
Senior Member
 
brainsucker's Avatar
 
Join Date: Sep 2002
Location: Minsk, Belarus
Posts: 190
Send a message via ICQ to brainsucker
Hide on minimize is 10000000 times easier I've f*cked all the Sunday of the last week with hiding at normal state (WS_EX_TOOLBOX sux - make new styles and so on, and other techiques work hard with nsis window).
I'll release tomorrow (i think) minimal version with hide on minimize and no right click menues (but with balloon tooltips for example .
brainsucker is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump