window for displaying the time in the tray notification area More...
#include <traynotify.h>
Public Types | |
typedef Window | super |
Public Member Functions | |
ClockWindow (HWND hwnd) | |
void | TimerTick () |
Static Public Member Functions | |
static HWND | Create (HWND hwndParent) |
Protected Member Functions | |
LRESULT | WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam) |
int | Notify (int id, NMHDR *pnmh) |
bool | FormatTime () |
void | Paint () |
Protected Attributes | |
TCHAR | _time [16] |
ToolTip | _tooltip |
window for displaying the time in the tray notification area
Definition at line 238 of file traynotify.h.
typedef Window ClockWindow::super |
Definition at line 240 of file traynotify.h.
ClockWindow::ClockWindow | ( | HWND | hwnd ) |
Definition at line 1268 of file traynotify.cpp.
References WindowHandle::_hwnd, _time, _tooltip, ToolTip::add(), FormatTime(), and TEXT.
Definition at line 1278 of file traynotify.cpp.
References CLASSNAME_CLOCKWINDOW, TEXT, and WINDOW_CREATOR.
{ static BtnWindowClass wcClock(CLASSNAME_CLOCKWINDOW, CS_DBLCLKS); ClientRect clnt(hwndParent); WindowCanvas canvas(hwndParent); FontSelection font(canvas, GetStockFont(DEFAULT_GUI_FONT)); RECT rect = {0, 0, 0, 0}; TCHAR buffer[8]; if (!GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, buffer, sizeof(buffer)/sizeof(TCHAR))) _tcscpy(buffer, TEXT("00:00")); DrawText(canvas, buffer, -1, &rect, DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT); int clockwindowWidth = rect.right-rect.left + 4; return Window::Create(WINDOW_CREATOR(ClockWindow), 0, wcClock, NULL, WS_CHILD|WS_VISIBLE, clnt.right-(clockwindowWidth), 1, clockwindowWidth, clnt.bottom-2, hwndParent); }
bool ClockWindow::FormatTime | ( | ) | [protected] |
Definition at line 1344 of file traynotify.cpp.
References _time.
Referenced by ClockWindow(), and TimerTick().
{ TCHAR buffer[16]; if (GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, buffer, sizeof(buffer)/sizeof(TCHAR))) if (_tcscmp(buffer, _time)) { _tcscpy(_time, buffer); return true; // The text to display has changed. } return false; // no change }
int ClockWindow::Notify | ( | int | id, |
NMHDR * | pnmh | ||
) | [protected, virtual] |
Reimplemented from Window.
Definition at line 1319 of file traynotify.cpp.
{ if (pnmh->code == TTN_GETDISPINFO) { LPNMTTDISPINFO pdi = (LPNMTTDISPINFO)pnmh; SYSTEMTIME systime; TCHAR buffer[64]; GetLocalTime(&systime); if (GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &systime, NULL, buffer, 64)) _tcscpy(pdi->szText, buffer); else pdi->szText[0] = '\0'; } return 0; }
void ClockWindow::Paint | ( | ) | [protected] |
Definition at line 1357 of file traynotify.cpp.
References WindowHandle::_hwnd, and _time.
Referenced by WndProc().
{ PaintCanvas canvas(_hwnd); FillRect(canvas, &canvas.rcPaint, GetSysColorBrush(COLOR_BTNFACE)); BkMode bkmode(canvas, TRANSPARENT); FontSelection font(canvas, GetStockFont(ANSI_VAR_FONT)); DrawText(canvas, _time, -1, ClientRect(_hwnd), DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX); }
void ClockWindow::TimerTick | ( | ) |
Definition at line 1338 of file traynotify.cpp.
References WindowHandle::_hwnd, and FormatTime().
Referenced by NotifyArea::WndProc().
{ if (FormatTime()) InvalidateRect(_hwnd, NULL, TRUE); // refresh displayed time }
LRESULT ClockWindow::WndProc | ( | UINT | nmsg, |
WPARAM | wparam, | ||
LPARAM | lparam | ||
) | [protected, virtual] |
Reimplemented from Window.
Definition at line 1301 of file traynotify.cpp.
References WindowHandle::_hwnd, launch_cpanel(), Paint(), TEXT, and Window::WndProc().
{ switch(nmsg) { case WM_PAINT: Paint(); break; case WM_LBUTTONDBLCLK: launch_cpanel(_hwnd, TEXT("timedate.cpl")); break; default: return super::WndProc(nmsg, wparam, lparam); } return 0; }
TCHAR ClockWindow::_time[16] [protected] |
Definition at line 255 of file traynotify.h.
Referenced by ClockWindow(), FormatTime(), and Paint().
ToolTip ClockWindow::_tooltip [protected] |
Definition at line 256 of file traynotify.h.
Referenced by ClockWindow().
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |