Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » tray icon & balloon notification
tray icon & balloon notification [message #772] Wed, 01 February 2006 16:32 Go to next message
hojtsy is currently offline  hojtsy
Messages: 241
Registered: January 2006
Location: Budapest, Hungary
Experienced Member
I would like to to put an icon into the tray (notification area) on Windows. I also would like to display notification balloons even when my application is not in focus. Is this supported by U++?
Re: tray icon & balloon notification [message #776 is a reply to message #772] Wed, 01 February 2006 18:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Define "supported" Smile

Yes, you can do it with U++ app. Anyway, there is no direct cross-platform support, you will have to use Win32 API.

Mirek
Re: tray icon & balloon notification [message #778 is a reply to message #772] Thu, 02 February 2006 08:51 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

I have modified a TaskbarButton class posted by Tom to work with my Ultimate Player (it was not compatybile with newest upp). It is not finished, but you can use it Smile

This is how I use it:

struct MyApp : TopWindow
{
TaskbarButton tray;
}

main...

MyApp app;

app.Open()
app.tray.Icon(MyIcon()).Label("MyApp");
app.tray.Init(app.GetHWND());
app.Run();

Use WhenDouble and WhenBar callbacks to add action for double click and popup menu.

Here it is the question to Mirek. As you can see I have to open appilication first to get the HWND for tray. It isn't the upp way Wink. I saw that Tom was using (overloading) CrateInit(HWND hwnd) method wich is not supported now and which was called when hwnd was known (I suppose so). This was very useful and made code much clener. Is it possible to get this method back?
Re: tray icon & balloon notification [message #788 is a reply to message #778] Thu, 02 February 2006 20:38 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
What about something like

app.tray.Open(app) ?

Mirek
Re: tray icon & balloon notification [message #790 is a reply to message #788] Thu, 02 February 2006 21:32 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Hmm, what you mean by that?
Are you suggesting adding Open mathod to the TaskbarButton class like this one...

TaskbarButton::Open(TopWindow &wnd)
{
wnd.Open()
}

.. to reduce main initialize code?

Frankly I would like to have a better solution. I had the same problem with other 3rd party libraries which required to pass to them hwnd value. What about adding WhenShow callback in TopWindow class which should be called when hwnd is accessible?
Re: tray icon & balloon notification [message #796 is a reply to message #790] Thu, 02 February 2006 23:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
How about overriding Ctrl::State and catching "OPEN"/"CLOSE" ?

Mirek
Re: tray icon & balloon notification [message #804 is a reply to message #796] Fri, 03 February 2006 08:45 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Yes, I know, but to make the condition reason == OPEN true I need call Add in main application constructor:

App()
{
Add(tray);
}

I don't want to do that, because tray control is not a layout control and the final result is a red box (in debug mode) displayed in the left-upper corner (it is ok as I did not set position and tray dosn't have a Paint method).

Could you add another value for reason - WINDOW? In this state GetHWND() should return a proper handle.
Re: tray icon & balloon notification [message #817 is a reply to message #804] Fri, 03 February 2006 11:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, I guess the confusion here is that HWND used for tray icon is quite unrelated to TopWindow. You would need to override TopWindow::WindowProc to handle it correctly.

I have tried different solution- tray icon with separate HWND and it seems to work fine - per popular demand, TrayIcon is now the part of U++.

Example:

struct App : TrayIcon {
void Info() {
PromptOK("TrayIcon launched this prompt!");
}

void Menu(Bar& bar) {
bar.Add("Info..", THISBACK(Info));
bar.Separator();
bar.Add("Exit", THISBACK(Break));
}

typedef App CLASSNAME;

App() {
WhenBar = THISBACK(Menu);
WhenLeftDouble = THISBACK(Info);
Icon(CtrlImg::File());
Tip("This is U++ tray icon");
}
};

GUI_APP_MAIN
{
App().Run();
}

Re: tray icon & balloon notification [message #820 is a reply to message #817] Fri, 03 February 2006 12:45 Go to previous messageGo to next message
hojtsy is currently offline  hojtsy
Messages: 241
Registered: January 2006
Location: Budapest, Hungary
Experienced Member
Can the icon of a TrayIcon be changed after construction?

Is there some wrapper function which can be used to hide the taskbar button of an application, so that the application can "minimize to the tray", or do I have to use Win32 for that?

I would like to monitor a web server from an u++ app and dislpay an auto-hiding balloon notification if the server fails. Also the status could be displayed in a tooltip when the mouse is hovered over the tray icon. Are there methods for the notification and tooltip in the TrayIcon?
Re: tray icon & balloon notification [message #821 is a reply to message #820] Fri, 03 February 2006 13:38 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Icon/Tip can be changed whenever you want.

To "minimize to tray", my guess is that simple minimize+close would work quite well.

"balloon" is, AFAIK, not related to tray icon (but I might be wrong).

Mirek
Re: tray icon & balloon notification [message #824 is a reply to message #821] Fri, 03 February 2006 15:54 Go to previous messageGo to next message
hojtsy is currently offline  hojtsy
Messages: 241
Registered: January 2006
Location: Budapest, Hungary
Experienced Member
luzr wrote on Fri, 03 February 2006 07:38

To "minimize to tray", my guess is that simple minimize+close would work quite well.
I think I will rather hide it with WndShow(false). I would like to keep the internal state of the window unchanged when "minimized" to the tray.

Other question: Could you add a TopWindow method to set the window topmost, which calls SetWindowPos(hWnd, HWND_TOPMOST, ...) ?
Re: tray icon & balloon notification [message #827 is a reply to message #824] Fri, 03 February 2006 17:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, there is no WndShow in U++, but Hide calls it for TopWindow... And you are right, hiding is good as well.

OTOH, U++ is designed that it mostly does not matter. Only "internal state" that really exists is focus - and that one is stored as "active focus" in TopWindow anyway.

Other anwser:

Well, I can adding TopMost modifier, but for now please use:

TopWindow& ExStyle(dword _exstyle);
dword GetExStyle() const;

(like ExStyle(GetExStyle() | WS_EX_TOPMOST)Wink

(note that it works the U++ way - does not matter whether TopWindow is open or not).

Mirek
Re: tray icon & balloon notification [message #828 is a reply to message #827] Fri, 03 February 2006 17:19 Go to previous messageGo to next message
hojtsy is currently offline  hojtsy
Messages: 241
Registered: January 2006
Location: Budapest, Hungary
Experienced Member
luzr wrote on Fri, 03 February 2006 11:04

Well, there is no WndShow in U++
It is a method of Ctrl. But I noticed now that it is private.
ExStyle(GetExStyle() | WS_EX_TOPMOST) is OK, no need for another method.
Re: tray icon & balloon notification [message #869 is a reply to message #828] Mon, 06 February 2006 13:38 Go to previous messageGo to next message
hojtsy is currently offline  hojtsy
Messages: 241
Registered: January 2006
Location: Budapest, Hungary
Experienced Member
Hi I am having a problem with making a window topmost (floating above windows of other applications). With this function I can make a window topmost:
::SetWindowPos(GetHWND(), HWND_TOPMOST, 0,0,0,0, (UINT)(SWP_NOMOVE | SWP_NOSIZE));

But this other one you suggested does not work:
ExStyle(GetExStyle() | WS_EX_TOPMOST);

Additionally on linux the GetExStyle is undefined. It would be better to have a dummy function returning default values.
Re: tray icon & balloon notification [message #872 is a reply to message #869] Mon, 06 February 2006 14:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
OK, I hope ExStyle is fixed now.

As for empty implementations in Linux, I do not agree - I do not like the idea of silently ignored problems.

Use #ifdef PLATFORM_WIN32 conditional compilation instead.

Mirek
Re: tray icon & balloon notification [message #890 is a reply to message #872] Tue, 07 February 2006 13:09 Go to previous messageGo to next message
hojtsy is currently offline  hojtsy
Messages: 241
Registered: January 2006
Location: Budapest, Hungary
Experienced Member
ExStyle(GetExStyle() | WS_EX_TOPMOST);
Still not OK in 602 beta. It results in some kind of freezing of the window. It can no longer be resized, only moved, controls in the window no longer react to mouse clicks, and right click on the title bar opens up an incorrectly aligned menu, which contains the only way to close the application (not counting killing from Task Manager).

[Updated on: Tue, 07 February 2006 13:10]

Report message to a moderator

Re: tray icon & balloon notification [message #908 is a reply to message #890] Tue, 07 February 2006 22:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, I hope I have fixed it, however, later I have found that it cannot work for WS_EX_TOPMOST:

http://msdn.microsoft.com/archive/default.asp?url=/archive/e n-us/win9x/verdiff_2awj.asp

so SetWindowPos is now the best option...

Mirek
Re: tray icon & balloon notification [message #962 is a reply to message #772] Fri, 10 February 2006 10:26 Go to previous messageGo to next message
hojtsy is currently offline  hojtsy
Messages: 241
Registered: January 2006
Location: Budapest, Hungary
Experienced Member
It is typical for popup menus created by tray icons to have a menu entry with bold font. Can this be accomplised with U++?
Re: tray icon & balloon notification [message #964 is a reply to message #962] Fri, 10 February 2006 10:45 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Yes, but just accidentally and not very nice way:

Typecast result of bar.Add... to MenuItemBase and use SetFont.

Putting to todo.... (but I do not see any nice way now..)

Mirek
Previous Topic: How to stick focus on a control
Next Topic: Qtf and drawing
Goto Forum:
  


Current Time: Thu Mar 28 18:05:19 CET 2024

Total time taken to generate the page: 0.01442 seconds