OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
trayicon.h
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1998 bBidus Yura, All Rights Reserved
4//
5//------------------------------------------------------------------------------
6
7#if !defined(OWL_TRAYICON_H)
8#define OWL_TRAYICON_H
9
10#include <owl/private/defs.h>
11#if defined(BI_HAS_PRAGMA_ONCE)
12# pragma once
13#endif
14
15#include <owl/defs.h>
16#include <owl/wsyscls.h>
17#include <owl/gdiobjec.h>
18#include <owl/eventhan.h>
19
20#include <shellapi.h>
21
22namespace owl {
23
24class _OWLCLASS TModule;
25
26#include <owl/preclass.h>
27
28//
29/// \class TTrayIcon
30// ~~~~~ ~~~~~~~~~
31//
32class _OWLCLASS TTrayIcon: protected NOTIFYICONDATA {
33 public:
34 TTrayIcon(TModule* module = &GetGlobalModule());
35 TTrayIcon(TWindow* parent, TMsgId, const tstring& tip, TIcon& icon, uint id, TModule* module = &GetGlobalModule());
36 TTrayIcon(TWindow* parent, TMsgId, const tstring& tip, TResId icon, uint id, TModule* module = &GetGlobalModule());
37 virtual void Init(TWindow* parent, TMsgId, const tstring& tip, TIcon* icon=0, uint id=0);
38 virtual ~TTrayIcon();
39
40 // Operations
41 public:
42 bool Enabled() const;
43 bool Visible() const;
44
45 /// Create the tray icon => must have valid hWnd => call in SetupWindow();
46 bool Create();
47
48 //Change or retrieve the Tooltip text
49 bool SetText(const tstring& text);
50 bool SetText(TResId resId);
51 tstring GetText() const;
52
53 //Change or retrieve the window to send notification messages to
54 bool SetParent(TWindow* wnd);
55 TWindow* GetParent() const;
56
57 //Change or retrieve the icon displayed
58 bool SetIcon(TIcon& icon, TAutoDelete = NoAutoDelete);
59 bool SetIcon(TResId resId);
60 TIcon* GetIcon() const;
61
62
63 void HideIcon();
64 void ShowIcon();
65 void RemoveIcon();
66 void MoveToRight();
67
68 /// Default handler for tray notification message
69 TResult EvTrayNotification(TParam1, TParam2);
70
71 // Implementation
72 protected:
73 bool bEnabled; ///< does O/S support tray icon?
74 bool bHidden; ///< Has the icon been hidden?
79
80 //DECLARE_DYNAMIC(TTrayIcon)
81};
82
83#include <owl/posclass.h>
84
85inline bool TTrayIcon::Enabled() const {
86 return bEnabled;
87}
88inline bool TTrayIcon::Visible() const {
89 return !bHidden;
90}
92 return Parent;
93}
95 return SetText(Module->LoadString(resId.GetInt()));
96}
97
99 return SetIcon(*new TIcon(Module? (HINSTANCE)*Module : HINSTANCE(nullptr), resId), AutoDelete);
100}
101
102} // OWL namespace
103
104
105#endif // #define OWL_TRAYICON_H
106
TIcon, derived from TGdiObject, represents the GDI object icon class.
Definition gdiobjec.h:670
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
bool SetText(const tstring &text)
Definition trayicon.cpp:244
TWindow * Parent
Definition trayicon.h:75
bool bEnabled
does O/S support tray icon?
Definition trayicon.h:73
bool bHidden
Has the icon been hidden?
Definition trayicon.h:74
bool ShouldDelete
Definition trayicon.h:78
bool SetIcon(TIcon &icon, TAutoDelete=NoAutoDelete)
Definition trayicon.cpp:225
bool Enabled() const
Definition trayicon.h:85
TIcon * GetIcon() const
TIcon * Icon
Definition trayicon.h:77
bool Visible() const
Definition trayicon.h:88
TWindow * GetParent() const
Definition trayicon.h:91
TModule * Module
Definition trayicon.h:76
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
Definition of TEventHandler and related classes & macros.
Definition of abstract GDI object class and derived classes.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition gdibase.h:70
@ AutoDelete
Definition gdibase.h:70
@ NoAutoDelete
Definition gdibase.h:70
int LoadString(uint id, TCHAR *buf, int maxChars) const
Loads a string resource identified by id into the buffer pointed to by buff.
Definition module.cpp:586
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
UINT TMsgId
Message ID type.
Definition dispatch.h:53
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
TModule & GetGlobalModule()
Definition global.cpp:48
General definitions used by all ObjectWindows programs.
#define _OWLCLASS
Definition defs.h:338
Classes for window system structure and type encapsulation.