ReactOS 0.4.15-dev-8096-ga0eec98
NotifyArea Struct Reference

tray notification area aka "tray" More...

#include <traynotify.h>

Inheritance diagram for NotifyArea:
Collaboration diagram for NotifyArea:

Public Types

typedef Window super
 
- Public Types inherited from Window
typedef map< HWND, Window * > WindowMap
 
typedef Window *(* CREATORFUNC) (HWND)
 
typedef Window *(* CREATORFUNC_INFO) (HWND, const void *)
 

Public Member Functions

 NotifyArea (HWND hwnd)
 
 ~NotifyArea ()
 
LRESULT ProcessTrayNotification (int notify_code, NOTIFYICONDATA *pnid)
 
- Public Member Functions inherited from Window
 Window (HWND hwnd)
 
virtual ~Window ()
 
LRESULT SendParent (UINT nmsg, WPARAM wparam=0, LPARAM lparam=0)
 
LRESULT PostParent (UINT nmsg, WPARAM wparam=0, LPARAM lparam=0)
 
 Window (INT cx, INT cy, BOOL fAutoHide=FALSE)
 
virtual ~Window ()
 
virtual LRESULT CALLBACK WindowProcDx (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void DoAction ()
 

Static Public Member Functions

static HWND Create (HWND hwndParent)
 
- Static Public Member Functions inherited from Window
static HWND Create (CREATORFUNC creator, DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent=0, HMENU hMenu=0)
 
static HWND Create (CREATORFUNC_INFO creator, const void *info, DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent=0, HMENU hMenu=0)
 
static Windowcreate_mdi_child (const ChildWndInfo &info, const MDICREATESTRUCT &mcs, CREATORFUNC_INFO creator)
 
static LRESULT CALLBACK WindowWndProc (HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
 
static INT_PTR CALLBACK DialogProc (HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
 
static Windowget_window (HWND hwnd)
 get window controller from window handle
 
template<typename CLASS >
static CLASS * get_window (HWND hwnd)
 
static void register_pretranslate (HWND hwnd)
 
static void unregister_pretranslate (HWND hwnd)
 
static BOOL pretranslate_msg (LPMSG pmsg)
 
static void register_dialog (HWND hwnd)
 
static void unregister_dialog (HWND hwnd)
 
static BOOL dispatch_dialog_msg (LPMSG pmsg)
 
static int MessageLoop ()
 
static void CancelModes ()
 
static BOOL DoRegisterClass (HINSTANCE hInstance)
 
static HWND DoCreateMainWnd (HINSTANCE hInstance, LPCTSTR pszText, INT cx, INT cy, DWORD style=WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN, DWORD exstyle=WS_EX_WINDOWEDGE|WS_EX_TOOLWINDOW|WS_EX_TOPMOST, BOOL fAutoHide=FALSE)
 
static INT DoMainLoop ()
 
static WindowGetAppbarData (HWND hwnd)
 
static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static DWORD WINAPI ActionThreadFunc (LPVOID args)
 

Protected Member Functions

LRESULT Init (LPCREATESTRUCT pcs)
 
LRESULT WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam)
 
int Command (int id, int code)
 
int Notify (int id, NMHDR *pnmh)
 
void UpdateIcons ()
 
void Paint ()
 
void Refresh (bool do_refresh=false)
 
void CancelModes ()
 
NotifyIconSet::iterator IconHitTest (const POINT &pos)
 search for a icon at a given client coordinate position
 
bool DetermineHideState (NotifyInfo &entry)
 
void read_config ()
 
void write_config ()
 
void show_clock (bool flag)
 
- Protected Member Functions inherited from Window
virtual LRESULT Init (LPCREATESTRUCT pcs)
 
virtual LRESULT WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam)
 
virtual int Command (int id, int code)
 
virtual int Notify (int id, NMHDR *pnmh)
 
void OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
 
void OnPaint (HWND hwnd)
 
void OnRButtonDown (HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
 
void OnKey (HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
 
void OnAppBarCallback (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL AppBar_Register (HWND hwnd)
 
BOOL AppBar_UnRegister (HWND hwnd)
 
BOOL AppBar_SetAutoHide (HWND hwnd, BOOL fHide)
 
BOOL AppBar_AutoHide (HWND hwnd)
 
BOOL AppBar_NoAutoHide (HWND hwnd)
 
BOOL AppBar_SetSide (HWND hwnd, UINT uSide)
 
void AppBar_SetAlwaysOnTop (HWND hwnd, BOOL fOnTop)
 
void AppBar_Hide (HWND hwnd)
 
void AppBar_UnHide (HWND hwnd)
 
void AppBar_SetAutoHideTimer (HWND hwnd)
 
void AppBar_SetAutoUnhideTimer (HWND hwnd)
 
void AppBar_Size (HWND hwnd)
 
void AppBar_QueryPos (HWND hwnd, LPRECT lprc)
 
void AppBar_QuerySetPos (UINT uEdge, LPRECT lprc, PAPPBARDATA pabd, BOOL fMove)
 
void AppBar_PosChanged (PAPPBARDATA pabd)
 
BOOL OnCreate (HWND hwnd, LPCREATESTRUCT lpCreateStruct)
 
void OnActivate (HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized)
 
void OnWindowPosChanged (HWND hwnd, const LPWINDOWPOS lpwpos)
 
void OnSize (HWND hwnd, UINT state, int cx, int cy)
 
void OnMove (HWND hwnd, int x, int y)
 
void OnNCDestroy (HWND hwnd)
 
void OnTimer (HWND hwnd, UINT id)
 
UINT OnNCHitTest (HWND hwnd, int x, int y)
 
void OnLButtonDown (HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
 
void OnMouseMove (HWND hwnd, int x, int y, UINT keyFlags)
 
void OnLButtonUp (HWND hwnd, int x, int y, UINT keyFlags)
 
void GetWorkArea (LPRECT prc) const
 

Protected Attributes

WindowHandle _hwndClock
 
int _clock_width
 
ToolTip _tooltip
 
NotifyHook _hook
 
bool _show_hidden
 
bool _hide_inactive
 
bool _show_button
 
NotifyIconCfgList _cfg
 
map< HWND, String_window_modules
 
NotifyIconMap _icon_map
 
NotifyIconSet _sorted_icons
 
int _next_idx
 
size_t _last_icon_count
 
- Protected Attributes inherited from Window
HWND m_hwnd
 
BOOL m_fAutoHide
 
BOOL m_fOnTop
 
BOOL m_fHiding
 
UINT m_uSide
 
LONG m_cxWidth
 
LONG m_cyHeight
 
LONG m_cxSave
 
LONG m_cySave
 
BOOL m_fAppBarRegd
 
BOOL m_fMoving
 
BOOL m_bDragged
 
POINT m_ptDragOn
 
RECT m_rcAppBar
 
RECT m_rcDrag
 

Friends

struct TrayNotifyDlg
 

Additional Inherited Members

- Public Attributes inherited from Window
IAccessible IAccessible_iface
 
IOleWindow IOleWindow_iface
 
IEnumVARIANT IEnumVARIANT_iface
 
LONG ref
 
- Static Protected Member Functions inherited from Window
static Windowcreate_controller (HWND hwnd)
 create controller for a new window
 
static StaticWindowDataGetStaticWindowData ()
 
static LRESULT CALLBACK MDICBTHookProc (int code, WPARAM wparam, LPARAM lparam)
 
static LRESULT CALLBACK PropSheetCBTHookProc (int code, WPARAM wparam, LPARAM lparam)
 
- Static Protected Attributes inherited from Window
static WindowMap s_wnd_map
 
static const voids_new_info = NULL
 
static CREATORFUNC s_window_creator = NULL
 
static HHOOK s_hcbtHook = 0
 
static WindowSet s_pretranslate_windows
 
static WindowSet s_dialogs
 

Detailed Description

tray notification area aka "tray"

Definition at line 130 of file traynotify.h.

Member Typedef Documentation

◆ super

Definition at line 132 of file traynotify.h.

Constructor & Destructor Documentation

◆ NotifyArea()

NotifyArea::NotifyArea ( HWND  hwnd)

Definition at line 204 of file traynotify.cpp.

205 : super(hwnd),
207{
208 _next_idx = 0;
209 _clock_width = 0;
211 _show_hidden = false;
212 _hide_inactive = true;
213 _show_button = true;
214}
int _next_idx
Definition: traynotify.h:176
bool _show_button
Definition: traynotify.h:150
size_t _last_icon_count
Definition: traynotify.h:177
Window super
Definition: traynotify.h:132
ToolTip _tooltip
Definition: traynotify.h:145
bool _hide_inactive
Definition: traynotify.h:149
bool _show_hidden
Definition: traynotify.h:148
int _clock_width
Definition: traynotify.h:143
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ ~NotifyArea()

NotifyArea::~NotifyArea ( )

Definition at line 216 of file traynotify.cpp.

217{
218 KillTimer(_hwnd, 0);
219
220 write_config();
221}
void write_config()
Definition: traynotify.cpp:294
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Member Function Documentation

◆ CancelModes()

void NotifyArea::CancelModes ( )
protected

Definition at line 572 of file traynotify.cpp.

573{
575
577 PostMessage(it->_hWnd, WM_CANCELMODE, 0, 0);
578}
iterator end()
Definition: _set.h:152
iterator begin()
Definition: _set.h:151
_Rep_type::const_iterator const_iterator
Definition: _set.h:74
NotifyIconSet _sorted_icons
Definition: traynotify.h:175
#define HWND_BROADCAST
Definition: winuser.h:1204
#define WM_CANCELMODE
Definition: winuser.h:1635
#define PostMessage
Definition: winuser.h:5832

Referenced by WndProc().

◆ Command()

int NotifyArea::Command ( int  id,
int  code 
)
protectedvirtual

Reimplemented from Window.

Definition at line 511 of file traynotify.cpp.

512{
513 switch(id) {
516 UpdateIcons();
517 break;
518
521 UpdateIcons();
522 break;
523
526 break;
527
528 case ID_CONFIG_TIME:
529 launch_cpanel(_hwnd, TEXT("timedate.cpl"));
530 break;
531
532 default:
534 }
535
536 return 0;
537}
#define TEXT(s)
Definition: k32.h:26
#define ID_SHOW_ICON_BUTTON
Definition: resource.h:223
#define ID_CONFIG_NOTIFYAREA
Definition: resource.h:218
#define ID_CONFIG_TIME
Definition: resource.h:219
#define IDD_NOTIFYAREA
Definition: resource.h:103
#define ID_SHOW_HIDDEN_ICONS
Definition: resource.h:217
BOOL launch_cpanel(HWND hwnd, LPCTSTR applet)
Definition: utility.cpp:383
#define WINDOW_CREATOR(WND_CLASS)
Definition: window.h:202
static int DoModal(UINT nid, CREATORFUNC creator, HWND hwndParent=0)
Definition: window.cpp:701
void UpdateIcons()
Definition: traynotify.cpp:646
configuration dialog for notification icons
Definition: traynotify.h:199
LRESULT SendParent(UINT nmsg, WPARAM wparam=0, LPARAM lparam=0)
Definition: window.cpp:657
Definition: inflate.c:139
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define WM_COMMAND
Definition: winuser.h:1740
HWND WINAPI GetParent(_In_ HWND)

◆ Create()

HWND NotifyArea::Create ( HWND  hwndParent)
static

Definition at line 367 of file traynotify.cpp.

368{
369 static BtnWindowClass wcTrayNotify(CLASSNAME_TRAYNOTIFY, CS_DBLCLKS);
370
371 ClientRect clnt(hwndParent);
372
375 clnt.right-(NOTIFYAREA_WIDTH_DEF+1), 1, NOTIFYAREA_WIDTH_DEF, clnt.bottom-2, hwndParent);
376}
static HWND hwndParent
Definition: cryptui.c:300
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_CLIPCHILDREN
Definition: pedump.c:619
window class with gray background color
Definition: window.h:249
tray notification area aka "tray"
Definition: traynotify.h:131
static HWND Create(CREATORFUNC creator, DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent=0, HMENU hMenu=0)
Definition: window.cpp:87
#define NOTIFYAREA_WIDTH_DEF
Definition: traynotify.h:34
#define TITLE_TRAYNOTIFY
Definition: traynotify.h:30
#define CLASSNAME_TRAYNOTIFY
Definition: traynotify.h:29
#define WS_EX_STATICEDGE
Definition: winuser.h:403
#define CS_DBLCLKS
Definition: winuser.h:651

Referenced by DesktopBar::Init().

◆ DetermineHideState()

bool NotifyArea::DetermineHideState ( NotifyInfo entry)
protected

Definition at line 837 of file traynotify.cpp.

838{
839 if (entry._modulePath.empty()) {
840 const String& modulePath = _window_modules[entry._hWnd];
841
842 // request module path for new windows (We will get an asynchronous answer by a WM_COPYDATA message.)
843 if (!modulePath.empty())
844 entry._modulePath = modulePath;
845 else
846 _hook.GetModulePath(entry._hWnd, _hwnd);
847 }
848
849 for(NotifyIconCfgList::const_iterator it=_cfg.begin(); it!=_cfg.end(); ++it) {
850 const NotifyIconConfig& cfg = *it;
851
852 if (cfg.match(entry)) {
853 entry._mode = cfg._mode;
854 return true;
855 }
856 }
857
858 return false;
859}
_STLP_PRIV _List_iterator< NotifyIconConfig, _Const_traits< NotifyIconConfig > > const_iterator
Definition: _list.h:276
iterator begin()
Definition: _list.h:367
iterator end()
Definition: _list.h:370
uint32_t entry
Definition: isohybrid.c:63
NotifyHook _hook
Definition: traynotify.h:146
NotifyIconCfgList _cfg
Definition: traynotify.h:170
map< HWND, String > _window_modules
Definition: traynotify.h:172
void GetModulePath(HWND hwnd, HWND hwndCallback)
Definition: traynotify.cpp:45
configuration for the display mode of a notification icon
Definition: traynotify.h:72
bool match(const NotifyIconConfig &props) const
Definition: traynotify.cpp:820
NOTIFYICONMODE _mode
Definition: traynotify.h:83
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by ProcessTrayNotification(), and Refresh().

◆ IconHitTest()

NotifyIconSet::iterator NotifyArea::IconHitTest ( const POINT pos)
protected

search for a icon at a given client coordinate position

Definition at line 789 of file traynotify.cpp.

790{
792 return _sorted_icons.end();
793
795
796 int x = NOTIFYICON_X;
797
798 if (_show_button)
800
801 for(; it!=_sorted_icons.end(); ++it) {
802 //NotifyInfo& entry = const_cast<NotifyInfo&>(*it); // Why does GCC 3.3 need this additional const_cast ?!
803
804 if (pos.x>=x && pos.x<x+NOTIFYICON_SIZE)
805 break;
806
808 }
809
810 return it;
811}
_Rep_type::iterator iterator
Definition: _set.h:73
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define NOTIFYICON_Y
Definition: traynotify.h:39
#define NOTIFYICON_X
Definition: traynotify.h:38
#define NOTIFYICON_SIZE
Definition: traynotify.h:37
#define NOTIFYICON_DIST
Definition: traynotify.h:35

Referenced by Notify(), and WndProc().

◆ Init()

LRESULT NotifyArea::Init ( LPCREATESTRUCT  pcs)
protectedvirtual

Reimplemented from Window.

Definition at line 355 of file traynotify.cpp.

356{
357 if (super::Init(pcs))
358 return 1;
359
360 read_config();
361
362 SetTimer(_hwnd, 0, 1000, NULL);
363
364 return 0;
365}
#define NULL
Definition: types.h:112
void read_config()
Definition: traynotify.cpp:243
virtual LRESULT Init(LPCREATESTRUCT pcs)
Definition: window.cpp:241
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)

◆ Notify()

int NotifyArea::Notify ( int  id,
NMHDR pnmh 
)
protectedvirtual

Reimplemented from Window.

Definition at line 539 of file traynotify.cpp.

540{
541 if (pnmh->code == TTN_GETDISPINFO) {
543
545 ScreenToClient(_hwnd, &pt);
546
547 if (_show_button &&
550 {
551 static ResString sShowIcons(IDS_SHOW_HIDDEN_ICONS);
552 static ResString sHideIcons(IDS_HIDE_ICONS);
553
554 pdi->lpszText = (_show_hidden? sHideIcons: sShowIcons).str();
555 } else {
557
558 if (found != _sorted_icons.end()) {
559 NotifyInfo& entry = const_cast<NotifyInfo&>(*found); // Why does GCC 3.3 need this additional const_cast ?!
560
561 // enable multiline tooltips (break at CR/LF and for very long one-line strings)
563
564 pdi->lpszText = entry._tipText.str();
565 }
566 }
567 }
568
569 return 0;
570}
#define pt(x, y)
Definition: drawing.c:79
#define IDS_HIDE_ICONS
Definition: resource.h:48
#define IDS_SHOW_HIDDEN_ICONS
Definition: resource.h:47
#define LPNMTTDISPINFO
Definition: commctrl.h:1915
#define TTN_GETDISPINFO
Definition: commctrl.h:1878
#define TTM_SETMAXTIPWIDTH
Definition: commctrl.h:1819
const WCHAR * str
NotifyIconSet::iterator IconHitTest(const POINT &pos)
search for a icon at a given client coordinate position
Definition: traynotify.cpp:789
structure for maintaining informations about one notification icon
Definition: traynotify.h:94
convenient loading of string resources
Definition: globals.h:304
UINT code
Definition: winuser.h:3159
HWND hwndFrom
Definition: winuser.h:3157
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO * pdi
Definition: winddi.h:3554
DWORD WINAPI GetMessagePos(void)
Definition: message.c:1351
#define SendMessage
Definition: winuser.h:5843
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)

◆ Paint()

void NotifyArea::Paint ( )
protected

Definition at line 697 of file traynotify.cpp.

698{
699 BufferedPaintCanvas canvas(_hwnd);
700
701 // first fill with the background color
702 FillRect(canvas, &canvas.rcPaint, GetSysColorBrush(COLOR_BTNFACE));
703
704 // draw icons
705 int x = NOTIFYICON_X;
706 int y = NOTIFYICON_Y;
707
708 if (_show_button) {
709 static SmallIcon leftArrowIcon(IDI_NOTIFY_L);
710 static SmallIcon rightArrowIcon(IDI_NOTIFY_R);
711
712 DrawIconEx(canvas, x, y, _show_hidden?rightArrowIcon:leftArrowIcon, NOTIFYICON_SIZE, NOTIFYICON_SIZE, 0, 0, DI_NORMAL);
714 }
715
716#ifndef _NO_ALPHABLEND
717 MemCanvas mem_dc;
718 SelectedBitmap bmp(mem_dc, CreateCompatibleBitmap(canvas, NOTIFYICON_SIZE, NOTIFYICON_SIZE));
720 BLENDFUNCTION blend = {AC_SRC_OVER, 0, 128, 0}; // 50 % visible
721#endif
722
724#ifndef _NO_ALPHABLEND
725 if (it->_dwState & NIS_HIDDEN) {
727 DrawIconEx(mem_dc, 0, 0, it->_hIcon, NOTIFYICON_SIZE, NOTIFYICON_SIZE, 0, 0, DI_NORMAL);
729 } else
730#endif
731 DrawIconEx(canvas, x, y, it->_hIcon, NOTIFYICON_SIZE, NOTIFYICON_SIZE, 0, 0, DI_NORMAL);
732
734 }
735}
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define IDI_NOTIFY_L
Definition: resource.h:120
#define IDI_NOTIFY_R
Definition: resource.h:121
BITMAP bmp
Definition: alphablend.c:62
& rect
Definition: startmenu.cpp:1413
convenient loading of small (16x16) icon resources
Definition: globals.h:321
#define AlphaBlend
Definition: misc.c:293
#define AC_SRC_OVER
Definition: wingdi.h:1369
#define DI_NORMAL
Definition: wingdi.h:72
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:2059
#define COLOR_BTNFACE
Definition: winuser.h:928

Referenced by WndProc().

◆ ProcessTrayNotification()

LRESULT NotifyArea::ProcessTrayNotification ( int  notify_code,
NOTIFYICONDATA pnid 
)
Todo:
This is a fix for Windows Task Manager.
Todo:
call only if really changes occurred

Definition at line 580 of file traynotify.cpp.

581{
582 switch(notify_code) {
583 case NIM_ADD:
584 case NIM_MODIFY:
585 if ((int)pnid->uID >= 0) {
586 NotifyInfo& entry = _icon_map[pnid];
587
588 // a new entry?
589 if (entry._idx == -1)
590 entry._idx = ++_next_idx;
591 /* equivalent code using iterator::find();
592 NotifyIconMap::iterator found = _icon_map.find(pnid);
593 NotifyInfo* pentry;
594 // a new entry?
595 if (found == _icon_map.end()) {
596 pentry = &_icon_map[pnid];
597 pentry->_idx = ++_next_idx;
598 } else {
599 pentry = &found->second;
600 }
601 NotifyInfo& entry = *pentry;
602 */
603 bool changes = entry.modify(pnid);
604
605 if (DetermineHideState(entry) && entry._mode==NIM_HIDE) {
606 entry._dwState |= NIS_HIDDEN;
607 changes = true;
608 }
609
610 if (changes)
611 UpdateIcons();
612
613 return TRUE;
614 }
615 break;
616
617 case NIM_DELETE: {
619
620 if (found != _icon_map.end()) {
621 if (found->second._hIcon)
622 DestroyIcon(found->second._hIcon);
623 _icon_map.erase(found);
624 UpdateIcons();
625 return TRUE;
626 }
627 break;}
628
629 case NIM_SETFOCUS:
630 SetForegroundWindow(_hwnd);
631 return TRUE;
632
633 case NIM_SETVERSION:
635
636 if (found != _icon_map.end()) {
637 found->second._version = pnid->UNION_MEMBER(uVersion);
638 return TRUE;
639 } else
640 return FALSE;
641 }
642
643 return FALSE;
644}
_STLP_TEMPLATE_FOR_CONT_EXT iterator find(const _KT &__x)
Definition: _map.h:210
iterator end()
Definition: _map.h:165
_Rep_type::iterator iterator
Definition: _map.h:85
void erase(iterator __pos)
Definition: _map.h:203
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static CHANGE * changes
Definition: io.c:49
#define NIM_DELETE
Definition: shellapi.h:96
#define NIM_MODIFY
Definition: shellapi.h:95
#define NIM_ADD
Definition: shellapi.h:94
bool DetermineHideState(NotifyInfo &entry)
Definition: traynotify.cpp:837
NotifyIconMap _icon_map
Definition: traynotify.h:174
@ NIM_HIDE
Definition: traynotify.h:65
BOOL WINAPI SetForegroundWindow(_In_ HWND)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2084

◆ read_config()

void NotifyArea::read_config ( )
protected
Todo:
read default setting from registry
Todo:
read default setting from registry

Definition at line 243 of file traynotify.cpp.

244{
245 bool clock_visible = true;
246
247 // read notification icon settings from XML configuration
248 XMLPos cfg_pos = g_Globals.get_cfg();
249
250 if (!g_Globals._SHRestricted || !SHRestricted(REST_HIDECLOCK))
251 {
252 if (cfg_pos.go_down("desktopbar")) {
253 clock_visible = XMLBoolRef(XMLPos(cfg_pos,"options"), "show-clock", !get_hide_clock_from_registry());
254 cfg_pos.back();
255 }
256 }
257
258 if (cfg_pos.go_down("notify-icons")) {
259 XMLPos options(cfg_pos, "options");
260
261 _hide_inactive = XMLBool(options, "hide-inactive", true);
262 _show_hidden = XMLBool(options, "show-hidden", false);
263 _show_button = XMLBool(options, "show-button", true);
264
265 XMLChildrenFilter icons(cfg_pos, "icon");
266
267 for(XMLChildrenFilter::iterator it=icons.begin(); it!=icons.end(); ++it) {
268 const XMLNode& node = **it;
269
271
272 cfg._name = node.get("name").c_str();
273 cfg._tipText = node.get("text").c_str();
274 cfg._windowTitle = node.get("window").c_str();
275 cfg._modulePath = node.get("module").c_str();
276 const string& mode = node.get("show");
277
278 if (mode == "show")
279 cfg._mode = NIM_SHOW;
280 else if (mode == "hide")
281 cfg._mode = NIM_HIDE;
282 else //if (mode == "auto")
283 cfg._mode = NIM_HIDE;
284
285 _cfg.push_back(cfg);
286 }
287
288 cfg_pos.back();
289 }
290
291 show_clock(clock_visible);
292}
void push_back(const_reference __x)
Definition: _list.h:509
GLenum mode
Definition: glext.h:6217
ExplorerGlobals g_Globals
Definition: explorer.cpp:52
@ REST_HIDECLOCK
Definition: shlobj.h:1788
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:146
XMLPos get_cfg()
Definition: explorer.cpp:119
void show_clock(bool flag)
Definition: traynotify.cpp:332
String _windowTitle
Definition: traynotify.h:80
String _modulePath
Definition: traynotify.h:81
static bool get_hide_clock_from_registry()
Definition: traynotify.cpp:223
@ NIM_SHOW
Definition: traynotify.h:65
Definition: dlist.c:348

Referenced by Init(), and WndProc().

◆ Refresh()

void NotifyArea::Refresh ( bool  do_refresh = false)
protected

Definition at line 737 of file traynotify.cpp.

738{
739 // Look for task icons without valid owner window.
740 // This is an extended feature missing in MS Windows.
742 const NotifyInfo& entry = *it;
743
744 if (!IsWindow(entry._hWnd))
745 if (_icon_map.erase(entry)) // delete icons without valid owner window
746 ++update;
747 }
748
750
751 // handle icon hiding
752 for(NotifyIconMap::iterator it=_icon_map.begin(); it!=_icon_map.end(); ++it) {
753 NotifyInfo& entry = it->second;
754
756
757 switch(entry._mode) {
758 case NIM_HIDE:
759 if (!(entry._dwState & NIS_HIDDEN)) {
760 entry._dwState |= NIS_HIDDEN;
761 ++update;
762 }
763 break;
764
765 case NIM_SHOW:
766 if (entry._dwState&NIS_HIDDEN) {
767 entry._dwState &= ~NIS_HIDDEN;
768 ++update;
769 }
770 break;
771
772 case NIM_AUTO:
773 // automatically hide icons after long periods of inactivity
774 if (_hide_inactive)
775 if (!(entry._dwState & NIS_HIDDEN))
776 if (now-entry._lastChange > ICON_AUTOHIDE_SECONDS*1000) {
777 entry._dwState |= NIS_HIDDEN;
778 ++update;
779 }
780 break;
781 }
782 }
783
784 if (update)
785 UpdateIcons();
786}
iterator begin()
Definition: _map.h:163
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
unsigned long DWORD
Definition: ntddk_ex.h:95
time_t now
Definition: finger.c:65
@ NIM_AUTO
Definition: traynotify.h:65
#define ICON_AUTOHIDE_SECONDS
Definition: traynotify.h:41
BOOL WINAPI IsWindow(_In_opt_ HWND)

◆ show_clock()

void NotifyArea::show_clock ( bool  flag)
protected

Definition at line 332 of file traynotify.cpp.

333{
334 bool vis = _hwndClock!=0;
335
336 if (vis != flag) {
337 if (flag) {
338 // create clock window
340
341 if (_hwndClock) {
342 ClientRect clock_size(_hwndClock);
343 _clock_width = clock_size.right;
344 }
345 } else {
347 _hwndClock = 0;
348 _clock_width = 0;
349 }
350
352 }
353}
#define PM_RESIZE_CHILDREN
Definition: explorer.h:66
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52
static HWND Create(HWND hwndParent)
WindowHandle _hwndClock
Definition: traynotify.h:142
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by read_config().

◆ UpdateIcons()

void NotifyArea::UpdateIcons ( )
protected

Definition at line 646 of file traynotify.cpp.

647{
649
650 // sort icon infos by display index
652 const NotifyInfo& entry = it->second;
653
654 if (_show_hidden || !(entry._dwState & NIS_HIDDEN))
656 }
657
658 // sync tooltip areas to current icon number
661
662 size_t tt_idx = 0;
663
664 if (_show_button) {
665 _tooltip.add(_hwnd, tt_idx++, rect);
666
667 rect.left += NOTIFYICON_DIST;
668 rect.right += NOTIFYICON_DIST;
669 }
670
671 size_t icon_cnt = _sorted_icons.size();
672 while(tt_idx < icon_cnt) {
673 _tooltip.add(_hwnd, tt_idx++, rect);
674
675 rect.left += NOTIFYICON_DIST;
676 rect.right += NOTIFYICON_DIST;
677 }
678
679 while(tt_idx < _last_icon_count)
680 _tooltip.remove(_hwnd, tt_idx++);
681
683 }
684
686
687 InvalidateRect(_hwnd, NULL, FALSE); // refresh icon display
688 UpdateWindow(_hwnd);
689}
_Rep_type::const_iterator const_iterator
Definition: _map.h:86
pair< iterator, bool > insert(const value_type &__x)
Definition: _set.h:168
void clear()
Definition: _set.h:185
size_type size() const
Definition: _set.h:160
void add(HWND hparent, HWND htool, LPCTSTR txt=LPSTR_TEXTCALLBACK, LPARAM lparam=0)
Definition: window.h:861
void remove(HWND hparent, HWND htool)
Definition: window.h:893
BOOL WINAPI UpdateWindow(_In_ HWND)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by Command(), ProcessTrayNotification(), Refresh(), and WndProc().

◆ WndProc()

LRESULT NotifyArea::WndProc ( UINT  nmsg,
WPARAM  wparam,
LPARAM  lparam 
)
protectedvirtual

Reimplemented from Window.

Definition at line 378 of file traynotify.cpp.

379{
380 switch(nmsg) {
381 case WM_PAINT:
382 Paint();
383 break;
384
385 case WM_TIMER: {
386 Refresh();
387
389
390 if (clock_window)
391 clock_window->TimerTick();
392 break;}
393
394 case PM_REFRESH:
395 Refresh(true);
396 break;
397
398 case WM_SIZE: {
399 int cx = LOWORD(lparam);
401 break;}
402
403 case PM_GET_WIDTH: {
405 if (_show_button)
407 return w;}
408
410 read_config();
411 break;
412
413 case WM_CONTEXTMENU: {
414 Point pt(lparam);
415 POINTS p;
416 p.x = (SHORT) pt.x;
417 p.y = (SHORT) pt.y;
418 ScreenToClient(_hwnd, &pt);
419
420 if (IconHitTest(pt) == _sorted_icons.end()) { // display menu only when no icon clicked
421 PopupMenu menu(IDM_NOTIFYAREA);
425 menu.TrackPopupMenu(_hwnd, p);
426 }
427 break;}
428
429 case WM_COPYDATA: { // receive NotifyHook answers
430 String path;
431 HWND hwnd;
432
435 break;}
436
437 default:
438 if (nmsg>=WM_MOUSEFIRST && nmsg<=WM_MOUSELAST) {
439 // close startup menu and other popup menus
440 // This functionality is missing in MS Windows.
441 if (nmsg==WM_LBUTTONDOWN || nmsg==WM_MBUTTONDOWN || nmsg==WM_RBUTTONDOWN
442#ifdef WM_XBUTTONDOWN
443 || nmsg==WM_XBUTTONDOWN
444#endif
445 )
446
447 CancelModes();
448
449 Point pt(lparam);
451
452 if (found != _sorted_icons.end()) {
453 const NotifyInfo& entry = const_cast<NotifyInfo&>(*found); // Why does GCC 3.3 need this additional const_cast ?!
454
455 // set activation time stamp
456 if (nmsg == WM_LBUTTONDOWN || // Some programs need PostMessage() instead of SendMessage().
457 nmsg == WM_MBUTTONDOWN || // So call SendMessage() only for BUTTONUP and BLCLK messages
458#ifdef WM_XBUTTONDOWN
459 nmsg == WM_XBUTTONDOWN ||
460#endif
461 nmsg == WM_RBUTTONDOWN) {
462 _icon_map[entry]._lastChange = GetTickCount();
463 }
464
465 // Notify the message if the owner is still alive
466 if (IsWindow(entry._hWnd)) {
467 if (nmsg == WM_MOUSEMOVE || // avoid to call blocking SendMessage() for merely moving the mouse over icons
468 nmsg == WM_LBUTTONDOWN || // Some programs need PostMessage() instead of SendMessage().
469 nmsg == WM_MBUTTONDOWN || // So call SendMessage() only for BUTTONUP and BLCLK messages
470#ifdef WM_XBUTTONDOWN
471 nmsg == WM_XBUTTONDOWN ||
472#endif
473 nmsg == WM_RBUTTONDOWN)
474 PostMessage(entry._hWnd, entry._uCallbackMessage, entry._uID, nmsg);
475 else {
476 // allow SetForegroundWindow() in client process
477 DWORD pid;
478
479 if (GetWindowThreadProcessId(entry._hWnd, &pid)) {
480 // bind dynamically to AllowSetForegroundWindow() to be compatible to WIN98
481 static DynamicFct<BOOL(WINAPI*)(DWORD)> AllowSetForegroundWindow(TEXT("USER32"), "AllowSetForegroundWindow");
482
484 (*AllowSetForegroundWindow)(pid);
485 }
486
487 // use PostMessage() for notifcation icons of Shell Service Objects in the own process
488 if (pid == GetCurrentProcessId())
489 PostMessage(entry._hWnd, entry._uCallbackMessage, entry._uID, nmsg);
490 else
491 SendMessage(entry._hWnd, entry._uCallbackMessage, entry._uID, nmsg);
492 }
493 }
494 else if (_icon_map.erase(entry)) // delete icons without valid owner window
495 UpdateIcons();
496 } else
497 // handle clicks on notification area button "show hidden icons"
498 if (_show_button)
499 if (nmsg == WM_LBUTTONDOWN)
503 }
504
505 return super::WndProc(nmsg, wparam, lparam);
506 }
507
508 return 0;
509}
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
#define PM_REFRESH_CONFIG
Definition: explorer.h:70
#define PM_REFRESH
Definition: explorer.h:69
#define PM_GET_WIDTH
Definition: explorer.h:67
GLfloat GLfloat p
Definition: glext.h:8902
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
void Refresh(void)
Definition: magnifier.c:317
#define IDM_NOTIFYAREA
Definition: resource.h:97
#define GET_WINDOW(CLASS, hwnd)
Definition: window.h:88
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
#define LOWORD(l)
Definition: pedump.c:82
short SHORT
Definition: pedump.c:59
_Out_opt_ int * cx
Definition: commctrl.h:585
#define WM_CONTEXTMENU
Definition: richedit.h:64
window for displaying the time in the tray notification area
Definition: traynotify.h:239
void TimerTick()
void CancelModes()
Definition: traynotify.cpp:572
void Paint()
Definition: traynotify.cpp:697
bool ModulePathCopyData(LPARAM lparam, HWND *phwnd, String &path)
Definition: traynotify.cpp:50
virtual LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
Definition: window.cpp:280
#define NOTIFYAREA_SPACE
Definition: traynotify.h:36
BOOL WINAPI AllowSetForegroundWindow(DWORD dwProcessId)
Definition: window.c:49
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837
#define WINAPI
Definition: msvc.h:6
#define WM_PAINT
Definition: winuser.h:1620
#define MAKEWPARAM(l, h)
Definition: winuser.h:4009
#define SWP_NOACTIVATE
Definition: winuser.h:1242
#define MF_BYCOMMAND
Definition: winuser.h:202
#define WM_MOUSEFIRST
Definition: winuser.h:1774
#define WM_MOUSELAST
Definition: winuser.h:1801
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_SIZE
Definition: winuser.h:1611
#define MF_CHECKED
Definition: winuser.h:132
#define SWP_NOSIZE
Definition: winuser.h:1245
#define WM_MOUSEMOVE
Definition: winuser.h:1775
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
#define MF_UNCHECKED
Definition: winuser.h:204
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define WM_RBUTTONDOWN
Definition: winuser.h:1779
#define WM_TIMER
Definition: winuser.h:1742
#define MF_BYPOSITION
Definition: winuser.h:203
#define WM_COPYDATA
Definition: winuser.h:1664
#define SWP_NOZORDER
Definition: winuser.h:1247
#define WM_MBUTTONDOWN
Definition: winuser.h:1782

◆ write_config()

void NotifyArea::write_config ( )
protected

Definition at line 294 of file traynotify.cpp.

295{
296 // write notification icon settings to XML configuration file
297 XMLPos cfg_pos = g_Globals.get_cfg();
298
299 cfg_pos.smart_create("desktopbar");
300 XMLBoolRef boolRef(XMLPos(cfg_pos,"options"), "show-clock");
301 boolRef = _hwndClock!=0;
302 cfg_pos.back();
303
304 cfg_pos.smart_create("notify-icons");
305
306 XMLPos options(cfg_pos, "options");
307 XMLBoolRef(options, "hide-inactive") = _hide_inactive;
308 XMLBoolRef(options, "show-hidden") = _show_hidden;
309 XMLBoolRef(options, "show-button") = _show_button;
310
311 for(NotifyIconCfgList::iterator it=_cfg.begin(); it!=_cfg.end(); ++it) {
312 NotifyIconConfig& cfg = *it;
313
314 // search for the corresponding node using the original name
315 cfg_pos.smart_create("icon", "name", cfg._name);
316
317 // refresh unique name
318 cfg.create_name();
319
320 cfg_pos["name"] = cfg._name.c_str();
321 cfg_pos["text"] = cfg._tipText.c_str();
322 cfg_pos["window"] = cfg._windowTitle.c_str();
323 cfg_pos["module"] = cfg._modulePath.c_str();
324 cfg_pos["show"] = string_from_mode(cfg._mode).c_str();
325
326 cfg_pos.back();
327 }
328
329 cfg_pos.back(); // smart_create
330}
_STLP_PRIV _List_iterator< NotifyIconConfig, _Nonconst_traits< NotifyIconConfig > > iterator
Definition: _list.h:275
String string_from_mode(NOTIFYICONMODE mode)
Definition: traynotify.cpp:863

Referenced by ~NotifyArea().

Friends And Related Function Documentation

◆ TrayNotifyDlg

friend struct TrayNotifyDlg
friend

Definition at line 168 of file traynotify.h.

Member Data Documentation

◆ _cfg

◆ _clock_width

int NotifyArea::_clock_width
protected

Definition at line 143 of file traynotify.h.

Referenced by NotifyArea(), show_clock(), and WndProc().

◆ _hide_inactive

bool NotifyArea::_hide_inactive
protected

Definition at line 149 of file traynotify.h.

Referenced by NotifyArea(), read_config(), Refresh(), and write_config().

◆ _hook

NotifyHook NotifyArea::_hook
protected

Definition at line 146 of file traynotify.h.

Referenced by DetermineHideState(), and WndProc().

◆ _hwndClock

WindowHandle NotifyArea::_hwndClock
protected

Definition at line 142 of file traynotify.h.

Referenced by show_clock(), WndProc(), and write_config().

◆ _icon_map

◆ _last_icon_count

size_t NotifyArea::_last_icon_count
protected

Definition at line 177 of file traynotify.h.

Referenced by NotifyArea(), and UpdateIcons().

◆ _next_idx

int NotifyArea::_next_idx
protected

Definition at line 176 of file traynotify.h.

Referenced by NotifyArea(), and ProcessTrayNotification().

◆ _show_button

bool NotifyArea::_show_button
protected

◆ _show_hidden

◆ _sorted_icons

NotifyIconSet NotifyArea::_sorted_icons
protected

Definition at line 175 of file traynotify.h.

Referenced by CancelModes(), IconHitTest(), Notify(), Paint(), Refresh(), UpdateIcons(), and WndProc().

◆ _tooltip

ToolTip NotifyArea::_tooltip
protected

Definition at line 145 of file traynotify.h.

Referenced by UpdateIcons().

◆ _window_modules

map<HWND, String> NotifyArea::_window_modules
protected

Definition at line 172 of file traynotify.h.

Referenced by DetermineHideState(), and WndProc().


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