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 » TopWindow&PopUp, TrayIcon » runtime tray icon? Draw a number?
runtime tray icon? Draw a number? [message #8213] Tue, 20 February 2007 04:20 Go to next message
DrGary is currently offline  DrGary
Messages: 7
Registered: February 2007
Promising Member
How can you create a tray icon at runtime? I would like to write/draw a number in the tray icon location. There was an example in the forum, but it is a year old and no longer works with the current version.

Would someone post a simple example program?

Thanks,
Gary
Re: runtime tray icon? Draw a number? [message #8224 is a reply to message #8213] Wed, 21 February 2007 00:37 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Icon in the tray is normal Image. You can use ImageDraw to paint it.

See

http://www.ultimatepp.org/srcdoc$Draw$DrawTutorial$en-us.htm l

section 5.
Re: runtime tray icon? Draw a number? [message #8230 is a reply to message #8224] Thu, 22 February 2007 07:01 Go to previous messageGo to next message
DrGary is currently offline  DrGary
Messages: 7
Registered: February 2007
Promising Member
Hey, that was pretty easy. It looks like a mask is necessary. Without the line that includes 'img.Alpha().DrawText()', only a black square appears. Is this correct?

--Gary

The code below is a modification of the TrayIcon sample.


#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct App : TrayIcon {
	Image icon1;
	
	void drawImage(String str) {
		ImageDraw img(16, 16);
        	img.Alpha().DrawText(0, 0, str, Arial(14), GrayColor(255)); 
		img.DrawText(0, 0, str, Arial(14), Blue()); 
		Icon(img);
	}
	
	void Info() {
		drawImage("11");
		PromptOK("TrayIcon launched this prompt!");
		drawImage("ab");
	}
	
	virtual 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);
		Tip("This is U++ tray icon");
		drawImage("56");
	}
};

GUI_APP_MAIN
{
	App().Run();
}
Re: runtime tray icon? Draw a number? [message #8233 is a reply to message #8230] Thu, 22 February 2007 14:42 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
DrGary wrote on Thu, 22 February 2007 01:01

Hey, that was pretty easy.



Thanks. That is what we want U++ to be Wink

Quote:


It looks like a mask is necessary. Without the line that includes 'img.Alpha().DrawText()', only a black square appears. Is this correct?



Yes, because initial pixels are all set to Color(0, 0, 0).

You can clear them to white (using DrawRect).

Note that until you use Alpha(), Image is Opaque. First call to Alpha makes it 100% transparent.

Mirek
Previous Topic: Borderless TopWindow
Next Topic: How to add Topwindow icon?
Goto Forum:
  


Current Time: Fri Mar 29 07:02:37 CET 2024

Total time taken to generate the page: 0.01947 seconds