Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members File Members Related Pages

# wkgl::TrayIcon Class Reference

Creates, Modifies, Removes icons from the system tray. More...

`#include <TrayIcon.h>`

Inheritance diagram for wkgl::TrayIcon:

List of all members.

## Public Methods
| TrayIcon (Component *parent, HICON icon, const char *tooltip=NULL)
| Creates a new tray icon, initially not shown.
| TrayIcon (Component *parent, const char *iconfile, const char *tooltip=NULL)
| Creates a new tray icon, initially not shown.
| ~TrayIcon ()
| Destroys a tray icon, and removes it from the system tray.
BOOL | show ()
| Displays a tray icon.
BOOL | hide ()
| Removes a tray icon from the system tray.
BOOL | isShowing ()
| Returns true if the icon is showing.
BOOL | setIcon (HICON icon)
| Sets the icon that is displayed to the given icon.
BOOL | setIcon (const char *iconfile)
| Loads the given icon and sets it if the icons is visible.
BOOL | setTooltip (const char *tooltip)
| Sets the tooltip text.
virtual void | registerComponent (HWND *hwnd, Component *com)
| Allows this component to recieve top level events.
virtual void | registerChild (HWND *hwnd, Component *com)
| Allows this component to propagate an event to the given child.
virtual LRESULT | fireChildEvents (UINT message, WPARAM wParam, LPARAM lParam)
| Propagates the events to the appropriate child/children.
virtual Component * | getParent ()
| Returns a pointer to the parent component.
virtual void | setParent (Component *p)
| Sets the components parent.
virtual HINSTANCE | getInstance ()
| Returns the instance of the application.
virtual HWND | getHwnd ()
| Returns the window handle.
virtual void | setHwnd (HWND h)
| Sets the window handle.
virtual void | addCallBack (COMCALLBACK callback)
| Adds a callback function.
virtual void | addCallBack (CallBack *callback)
| Adds a callback method.
virtual LRESULT | fireEvents (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
| Propagates events to all the callback functions.
## Static Public Methods
UINT | getWndProc ()
| Returns the the address of GlobalProc().
## Protected Methods
void | destroyLoadedIcon ()
| This method destroys an icon that was made by SetIcon(String iconfile).
BOOL | commitChanges ()
| This method updates the tray icons appearence if it is showing.
void | setFlags ()
| This method updates the tray icons appearence if it is showing.
## Protected Attributes
NOTIFYICONDATA | ndata
| The data needed to send messages to an icon.
HICON | curicon
| The curent icon if it was loaded, else NULL.
bool | showing
| Flag specifying that an icon is showing.
Component * | parent
| The parent of the component.
HINSTANCE | hInstance
| The instance of this application.
HWND | hwnd
| The handle to the component.
std::vector< CHILDCOMPONENT > | clisteners
| A list of the child components that events are to be passed to.
std::vector< COMCALLBACK > | comlisteners
| Stores the callbacks for this component that use functions. Stores the functions given to AddCallBack(). It is used by FireEvents() to notify the callbacks.
std::vector< CallBack * > | classlisteners
| Stores the callbacks for this component that come from classes. Stores the functions given to AddCallBack(). It is used by FireEvents() to notify the callbacks.
## Static Protected Attributes
UINT | uid_inc = 1
| Incriments ndata.uId.
## Friends
LRESULT CALLBACK | globalProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
| Is used to process all the callback functions.

## Detailed Description

Creates, Modifies, Removes icons from the system tray.

Author:
  Micheal Nooner.

Events are passed to the parent. Usually they are mouse messages and so you will need to handle them. Most commonly you want to have a menu pop up when the user right clickes (WM_RBUTTONUP) messge. The wParam will contain the identifier of the icon that generated the event. The lParam will contain the mouse or keyboard event identifier.

## Constructor & Destructor Documentation

TrayIcon::TrayIcon | ( | Component * | parent,
|  | HICON | icon,
|  | const char * | tooltip = NULL
| ) |

  | Creates a new tray icon, initially not shown. Parameters:
  parent | The parent of this icon (usally a Window).
  icon | The handle to the icon to load (see LoadIcon in win docs).
  tooltip | The tooltip to display when the mouse hovers over the icon.

TrayIcon::TrayIcon | ( | Component * | parent,
|  | const char * | iconfile,
|  | const char * | tooltip = NULL
| ) |

  | Creates a new tray icon, initially not shown. Parameters:
  parent | The parent of this icon (usally a Window).
  iconfile | The handle to the icon to load (see LoadIcon in win docs).
  tooltip | The tooltip to display when the mouse hovers over the icon.

TrayIcon::~TrayIcon | ( |  | ) |

| Destroys a tray icon, and removes it from the system tray.

## Member Function Documentation

void Component::addCallBack | ( | CallBack * | callback | ) | `[virtual, inherited]`

  | Adds a callback method. The callback must be a method from a class that inheirits from CallBack. Parameters:
  callback | the function to call when an event occurs
See also: FireEvents(), classlisteners

void Component::addCallBack | ( | COMCALLBACK | callback | ) | `[virtual, inherited]`

  | Adds a callback function. Parameters:
  callback | the function to call when an event occurs
See also: FireEvents(), comlisteners

BOOL TrayIcon::commitChanges | ( |  | ) | `[protected]`

| This method updates the tray icons appearence if it is showing. Returns: Returns the value of Shell_NotifyIcon() if the icon is showing TRUE otherwise

void TrayIcon::destroyLoadedIcon | ( |  | ) | `[protected]`

| This method destroys an icon that was made by SetIcon(String iconfile).

LRESULT Component::fireChildEvents | ( | UINT | message,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) | `[virtual, inherited]`

  | Propagates the events to the appropriate child/children. Parameters:
  message | the windows message to pass to the callback
  wParam | the submessage (see windows docs).
  lParam | the subparameter (see windows docs).
Returns: 0 if the event was handled otherwise what DefWindowProc returns. See also: RegisterChild(), clisteners Reimplemented in wkgl::Dialog.

LRESULT Component::fireEvents | ( | HWND | hwnd,
|  | UINT | message,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) | `[virtual, inherited]`

  | Propagates events to all the callback functions. Parameters:
  hwnd | the window handle to the window the events go to.
  message | the windows message to pass to the callback.
  wParam | the submessage (see windows docs).
  lParam | the subparameter (see windows docs).
Returns: 0 if the event was handled otherwise what DefWindowProc returns. See also: AddCallBack(), comlisteners Reimplemented in wkgl::Dialog.

HWND Component::getHwnd | ( |  | ) | `[virtual, inherited]`

| Returns the window handle. Returns: the window handle.

HINSTANCE Component::getInstance | ( |  | ) | `[virtual, inherited]`

| Returns the instance of the application. Returns: the instance of the application.

Component * Component::getParent | ( |  | ) | `[virtual, inherited]`

| Returns a pointer to the parent component. Returns: A pointer to the parent component.

UINT Component::getWndProc | ( |  | ) | `[static, inherited]`

| Returns the the address of GlobalProc(). Returns: the the address of GlobalProc().

BOOL TrayIcon::hide | ( |  | ) |

| Removes a tray icon from the system tray. Returns: TRUE if the icon is removed, FALSE otherwise.

BOOL TrayIcon::isShowing | ( |  | ) |

| Returns true if the icon is showing.

void Component::registerChild | ( | HWND * | hwnd,
|  | Component * | com
| ) | `[virtual, inherited]`

  | Allows this component to propagate an event to the given child. Parameters:
  hwnd | the window handle of the control to register.
  com | the control to register.
See also: CHILDCOMPONENT, clisteners

void Component::registerComponent | ( | HWND * | hwnd,
|  | Component * | com
| ) | `[virtual, inherited]`

  | Allows this component to recieve top level events. Parameters:
  hwnd | the window handle of the control to register.
  com | the control to register.
See also: AddCallBack(), FireEvents(), GlobalProc()

void TrayIcon::setFlags | ( |  | ) | `[protected]`

| This method updates the tray icons appearence if it is showing.

void Component::setHwnd | ( | HWND | h | ) | `[virtual, inherited]`

  | Sets the window handle. Parameters:
  h | The new window handle.

BOOL TrayIcon::setIcon | ( | const char * | iconfile | ) |

  | Loads the given icon and sets it if the icons is visible. Parameters:
  iconfile | The file name of the icon to load and place in the display.
Returns: TRUE if the icon is set successfully, FALSE otherwise.

BOOL TrayIcon::setIcon | ( | HICON | icon | ) |

  | Sets the icon that is displayed to the given icon. Parameters:
  icon | The handle to the icon to place in the display.
Returns: TRUE if the icon is set successfully, FALSE otherwise.

void Component::setParent | ( | Component * | p | ) | `[virtual, inherited]`

  | Sets the components parent. Parameters:
  p | The new parent of this component.

BOOL TrayIcon::setTooltip | ( | const char * | tooltip | ) |

  | Sets the tooltip text. Parameters:
  tooltip | the text to set the tip to.
Returns: TRUE if the tooltip is set successfully, FALSE otherwise.

BOOL TrayIcon::show | ( |  | ) |

| Displays a tray icon. Returns: TRUE if the icon is shown, FALSE otherwise.

## Friends And Related Function Documentation

LRESULT CALLBACK globalProc | ( | HWND | hwnd,
|  | UINT | message,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) | `[friend, inherited]`

  | Is used to process all the callback functions. Parameters:
  hwnd | the window handle to the window the events go to
  message | the windows message to pass to the callback
  wParam | the submessage (see windows docs).
  lParam | the subparameter (see windows docs).
Returns: what the appropriate component's FireEvent() method returns otherwise if returns what DefWindowProc() returns. See also: Component::FireEvents

## Member Data Documentation

std::vector< CallBack* > wkgl::Component::classlisteners`[protected, inherited]`

| Stores the callbacks for this component that come from classes. Stores the functions given to AddCallBack(). It is used by FireEvents() to notify the callbacks. See also: AddCallBack(), FireEvents()

std::vector< CHILDCOMPONENT > wkgl::Component::clisteners`[protected, inherited]`

| A list of the child components that events are to be passed to. Stores the children who wish to recieve events. See also: FireChildEvents(), CHILDCOMPONENT

std::vector< COMCALLBACK > wkgl::Component::comlisteners`[protected, inherited]`

| Stores the callbacks for this component that use functions. Stores the functions given to AddCallBack(). It is used by FireEvents() to notify the callbacks. See also: AddCallBack(), FireEvents()

HICON wkgl::TrayIcon::curicon`[protected]`

| The curent icon if it was loaded, else NULL.

HINSTANCE wkgl::Component::hInstance`[protected, inherited]`

| The instance of this application.

HWND wkgl::Component::hwnd`[protected, inherited]`

| The handle to the component.

NOTIFYICONDATA wkgl::TrayIcon::ndata`[protected]`

| The data needed to send messages to an icon.

Component* wkgl::Component::parent`[protected, inherited]`

| The parent of the component. Reimplemented in wkgl::Control.

bool wkgl::TrayIcon::showing`[protected]`

| Flag specifying that an icon is showing.

UINT TrayIcon::uid_inc = 1`[static, protected]`

| Incriments ndata.uId.

The documentation for this class was generated from the following files:

- TrayIcon.h
- TrayIcon.cpp