ReactOS  0.4.15-dev-1070-ge1a01de
ClockWindow Struct Reference

window for displaying the time in the tray notification area More...

#include <traynotify.h>

Inheritance diagram for ClockWindow:
Collaboration diagram for ClockWindow:

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

 ClockWindow (HWND hwnd)
 
void TimerTick ()
 
- 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 More...
 
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 WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam)
 
int Notify (int id, NMHDR *pnmh)
 
bool FormatTime ()
 
void Paint ()
 
- Protected Member Functions inherited from Window
virtual LRESULT Init (LPCREATESTRUCT pcs)
 
virtual int Command (int id, int code)
 
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

TCHAR _time [16]
 
ToolTip _tooltip
 
- 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
 

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 More...
 
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

window for displaying the time in the tray notification area

Definition at line 238 of file traynotify.h.

Member Typedef Documentation

◆ super

Definition at line 240 of file traynotify.h.

Constructor & Destructor Documentation

◆ ClockWindow()

ClockWindow::ClockWindow ( HWND  hwnd)

Definition at line 1252 of file traynotify.cpp.

1253  : super(hwnd),
1254  _tooltip(hwnd)
1255 {
1256  *_time = TEXT('\0');
1257  FormatTime();
1258 
1259  _tooltip.add(_hwnd, _hwnd);
1260 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
TCHAR _time[16]
Definition: traynotify.h:255
ToolTip _tooltip
Definition: traynotify.h:256
bool FormatTime()
void add(HWND hparent, HWND htool, LPCTSTR txt=LPSTR_TEXTCALLBACK, LPARAM lparam=0)
Definition: window.h:861
#define TEXT(s)
Definition: k32.h:26
Window super
Definition: traynotify.h:240

Member Function Documentation

◆ Create()

HWND ClockWindow::Create ( HWND  hwndParent)
static

Definition at line 1262 of file traynotify.cpp.

1263 {
1265 
1266  ClientRect clnt(hwndParent);
1267 
1268  WindowCanvas canvas(hwndParent);
1269  FontSelection font(canvas, GetStockFont(ANSI_VAR_FONT));
1270 
1271  RECT rect = {0, 0, 0, 0};
1272  TCHAR buffer[16];
1273  // Arbitrary high time so that the created clock window is big enough
1274  SYSTEMTIME st = { 1601, 1, 0, 1, 23, 59, 59, 999 };
1275 
1276  if (!GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buffer, sizeof(buffer)/sizeof(TCHAR)))
1277  _tcscpy(buffer, TEXT("00:00"));
1278 
1279  // Calculate the rectangle needed to draw the time (without actually drawing it)
1281  int clockwindowWidth = rect.right-rect.left + 4;
1282 
1284  wcClock, NULL, WS_CHILD|WS_VISIBLE,
1285  clnt.right-(clockwindowWidth), 1, clockwindowWidth, clnt.bottom-2, hwndParent);
1286 }
#define WINDOW_CREATOR(WND_CLASS)
Definition: window.h:202
#define GetStockFont(i)
Definition: windowsx.h:283
Definition: mk_font.cpp:20
#define LOCALE_USER_DEFAULT
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
GLuint buffer
Definition: glext.h:5915
#define WS_CHILD
Definition: pedump.c:617
#define DT_NOPREFIX
Definition: winuser.h:537
& rect
Definition: startmenu.cpp:1413
#define DrawText
Definition: winuser.h:5746
#define DT_CALCRECT
Definition: winuser.h:526
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
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
window for displaying the time in the tray notification area
Definition: traynotify.h:238
char TCHAR
Definition: xmlstorage.h:189
window class with gray background color
Definition: window.h:248
#define CLASSNAME_CLOCKWINDOW
Definition: traynotify.h:32
#define CS_DBLCLKS
Definition: winuser.h:646
#define GetTimeFormat
Definition: winnls.h:1186
#define DT_SINGLELINE
Definition: winuser.h:540
#define TEXT(s)
Definition: k32.h:26
#define ANSI_VAR_FONT
Definition: wingdi.h:906
#define TIME_NOSECONDS
Definition: winnls.h:275
#define WS_VISIBLE
Definition: pedump.c:620

Referenced by NotifyArea::show_clock().

◆ FormatTime()

bool ClockWindow::FormatTime ( )
protected

Definition at line 1331 of file traynotify.cpp.

1332 {
1333  TCHAR buffer[16];
1334 
1336  if (_tcscmp(buffer, _time)) {
1337  _tcscpy(_time, buffer);
1338  return true; // The text to display has changed.
1339  }
1340 
1341  return false; // no change
1342 }
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define LOCALE_USER_DEFAULT
TCHAR _time[16]
Definition: traynotify.h:255
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
GLuint buffer
Definition: glext.h:5915
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
#define GetTimeFormat
Definition: winnls.h:1186
#define TIME_NOSECONDS
Definition: winnls.h:275

Referenced by ClockWindow(), and TimerTick().

◆ Notify()

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

Reimplemented from Window.

Definition at line 1306 of file traynotify.cpp.

1307 {
1308  if (pnmh->code == TTN_GETDISPINFO) {
1310 
1311  SYSTEMTIME systime;
1312  TCHAR buffer[64];
1313 
1314  GetLocalTime(&systime);
1315 
1317  _tcscpy(pdi->szText, buffer);
1318  else
1319  pdi->szText[0] = '\0';
1320  }
1321 
1322  return 0;
1323 }
#define LOCALE_USER_DEFAULT
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
GLuint buffer
Definition: glext.h:5915
UINT code
Definition: winuser.h:3134
#define TTN_GETDISPINFO
Definition: commctrl.h:1874
smooth NULL
Definition: ftsmooth.c:416
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
char TCHAR
Definition: xmlstorage.h:189
#define GetDateFormat
Definition: winnls.h:1181
#define DATE_LONGDATE
Definition: winnls.h:194
#define LPNMTTDISPINFO
Definition: commctrl.h:1911
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO * pdi
Definition: winddi.h:3553

◆ Paint()

void ClockWindow::Paint ( )
protected

Definition at line 1344 of file traynotify.cpp.

1345 {
1346  PaintCanvas canvas(_hwnd);
1347 
1348  FillRect(canvas, &canvas.rcPaint, GetSysColorBrush(COLOR_BTNFACE));
1349 
1350  BkMode bkmode(canvas, TRANSPARENT);
1351  FontSelection font(canvas, GetStockFont(ANSI_VAR_FONT));
1352 
1353  DrawText(canvas, _time, -1, ClientRect(_hwnd), DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX);
1354 }
#define GetStockFont(i)
Definition: windowsx.h:283
Definition: mk_font.cpp:20
TCHAR _time[16]
Definition: traynotify.h:255
#define DT_NOPREFIX
Definition: winuser.h:537
#define DrawText
Definition: winuser.h:5746
#define TRANSPARENT
Definition: wingdi.h:949
#define DT_VCENTER
Definition: winuser.h:543
#define COLOR_BTNFACE
Definition: winuser.h:918
#define DT_SINGLELINE
Definition: winuser.h:540
#define ANSI_VAR_FONT
Definition: wingdi.h:906
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)

Referenced by WndProc().

◆ TimerTick()

void ClockWindow::TimerTick ( )

Definition at line 1325 of file traynotify.cpp.

1326 {
1327  if (FormatTime())
1328  InvalidateRect(_hwnd, NULL, TRUE); // refresh displayed time
1329 }
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
bool FormatTime()

Referenced by NotifyArea::WndProc().

◆ WndProc()

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

Reimplemented from Window.

Definition at line 1288 of file traynotify.cpp.

1289 {
1290  switch(nmsg) {
1291  case WM_PAINT:
1292  Paint();
1293  break;
1294 
1295  case WM_LBUTTONDBLCLK:
1296  launch_cpanel(_hwnd, TEXT("timedate.cpl"));
1297  break;
1298 
1299  default:
1300  return super::WndProc(nmsg, wparam, lparam);
1301  }
1302 
1303  return 0;
1304 }
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
BOOL launch_cpanel(HWND hwnd, LPCTSTR applet)
Definition: utility.cpp:383
#define WM_PAINT
Definition: winuser.h:1602
virtual LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
Definition: window.cpp:280
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1760
#define TEXT(s)
Definition: k32.h:26
static UINT WPARAM wparam
Definition: combo.c:716

Member Data Documentation

◆ _time

TCHAR ClockWindow::_time[16]
protected

Definition at line 255 of file traynotify.h.

Referenced by ClockWindow(), FormatTime(), and Paint().

◆ _tooltip

ToolTip ClockWindow::_tooltip
protected

Definition at line 256 of file traynotify.h.

Referenced by ClockWindow().


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