ReactOS  0.4.15-dev-1070-ge1a01de
CTrayClockWnd Class Reference
Inheritance diagram for CTrayClockWnd:
Collaboration diagram for CTrayClockWnd:

Public Member Functions

 CTrayClockWnd ()
 
virtual ~CTrayClockWnd ()
 
HRESULT WINAPI GetWindow (HWND *phwnd)
 
HRESULT WINAPI ContextSensitiveHelp (BOOL fEnterMode)
 
HRESULT Initialize (IN HWND hWndParent)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from ATL::CWindowImpl< CTrayClockWnd, CWindow, CControlWinTraits >
HWND Create (HWND hWndParent, _U_RECT rect=NULL, LPCTSTR szWindowName=NULL, DWORD dwStyle=0, DWORD dwExStyle=0, _U_MENUorID MenuOrID=0U, LPVOID lpCreateParam=NULL)
 
- Public Member Functions inherited from ATL::CWindowImplBaseT< CWindow, CControlWinTraits >
 CWindowImplBaseT ()
 
virtual void OnFinalMessage (HWND)
 
BOOL SubclassWindow (HWND hWnd)
 
virtual WNDPROC GetWindowProc ()
 
LRESULT DefWindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam)
 
HWND Create (HWND hWndParent, _U_RECT rect, LPCTSTR szWindowName, DWORD dwStyle, DWORD dwExStyle, _U_MENUorID MenuOrID, ATOM atom, LPVOID lpCreateParam)
 
- Public Member Functions inherited from ATL::CWindowImplRoot< CWindow >
 CWindowImplRoot ()
 
virtual ~CWindowImplRoot ()
 
- Public Member Functions inherited from ATL::CWindow
 CWindow (HWND hWnd=NULL)
 
 operator HWND () const
 
UINT ArrangeIconicWindows ()
 
void Attach (HWND hWndNew)
 
HDC BeginPaint (LPPAINTSTRUCT lpPaint)
 
BOOL BringWindowToTop ()
 
BOOL CenterWindow (HWND hWndCenter=NULL)
 
BOOL ChangeClipboardChain (HWND hWndNewNext)
 
BOOL CheckDlgButton (int nIDButton, UINT nCheck)
 
BOOL CheckRadioButton (int nIDFirstButton, int nIDLastButton, int nIDCheckButton)
 
HWND ChildWindowFromPoint (POINT point) const
 
HWND ChildWindowFromPointEx (POINT point, UINT uFlags) const
 
BOOL ClientToScreen (LPPOINT lpPoint) const
 
BOOL ClientToScreen (LPRECT lpRect) const
 
HWND Create (LPCTSTR lpstrWndClass, HWND hWndParent, _U_RECT rect=NULL, LPCTSTR szWindowName=NULL, DWORD dwStyle=0, DWORD dwExStyle=0, _U_MENUorID MenuOrID=0U, LPVOID lpCreateParam=NULL)
 
BOOL CreateCaret (HBITMAP pBitmap)
 
BOOL CreateGrayCaret (int nWidth, int nHeight)
 
BOOL CreateSolidCaret (int nWidth, int nHeight)
 
HDWP DeferWindowPos (HDWP hWinPosInfo, HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT uFlags)
 
BOOL DestroyWindow ()
 
HWND Detach ()
 
int DlgDirList (LPTSTR lpPathSpec, int nIDListBox, int nIDStaticPath, UINT nFileType)
 
int DlgDirListComboBox (LPTSTR lpPathSpec, int nIDComboBox, int nIDStaticPath, UINT nFileType)
 
BOOL DlgDirSelect (LPTSTR lpString, int nCount, int nIDListBox)
 
BOOL DlgDirSelectComboBox (LPTSTR lpString, int nCount, int nIDComboBox)
 
void DragAcceptFiles (BOOL bAccept=TRUE)
 
BOOL DrawMenuBar ()
 
BOOL EnableScrollBar (UINT uSBFlags, UINT uArrowFlags=ESB_ENABLE_BOTH)
 
BOOL EnableWindow (BOOL bEnable=TRUE)
 
void EndPaint (LPPAINTSTRUCT lpPaint)
 
BOOL FlashWindow (BOOL bInvert)
 
BOOL GetClientRect (LPRECT lpRect) const
 
HDC GetDC ()
 
HDC GetDCEx (HRGN hRgnClip, DWORD flags)
 
HWND GetDescendantWindow (int nID) const
 
HRESULT GetDlgControl (int nID, REFIID iid, void **ppCtrl)
 
int GetDlgCtrlID () const
 
HRESULT GetDlgHost (int nID, REFIID iid, void **ppHost)
 
HWND GetDlgItem (int nID)
 
UINT GetDlgItemInt (int nID, BOOL *lpTrans=NULL, BOOL bSigned=TRUE) const
 
UINT GetDlgItemText (int nID, LPTSTR lpStr, int nMaxCount) const
 
BOOL GetDlgItemText (int nID, BSTR &bstrText) const
 
DWORD GetExStyle () const
 
HFONT GetFont () const
 
DWORD GetHotKey () const
 
HICON GetIcon (BOOL bBigIcon=TRUE) const
 
HWND GetLastActivePopup () const
 
HMENU GetMenu () const
 
HWND GetNextDlgGroupItem (HWND hWndCtl, BOOL bPrevious=FALSE) const
 
HWND GetNextDlgTabItem (HWND hWndCtl, BOOL bPrevious=FALSE) const
 
CWindow GetParent () const
 
BOOL GetScrollInfo (int nBar, LPSCROLLINFO lpScrollInfo)
 
BOOL GetScrollPos (int nBar)
 
BOOL GetScrollRange (int nBar, LPINT lpMinPos, LPINT lpMaxPos) const
 
DWORD GetStyle () const
 
HMENU GetSystemMenu (BOOL bRevert)
 
HWND GetTopLevelParent () const
 
HWND GetTopLevelWindow () const
 
HWND GetTopWindow () const
 
BOOL GetUpdateRect (LPRECT lpRect, BOOL bErase=FALSE)
 
int GetUpdateRgn (HRGN hRgn, BOOL bErase=FALSE)
 
HWND GetWindow (UINT nCmd) const
 
DWORD GetWindowContextHelpId () const
 
HDC GetWindowDC ()
 
LONG GetWindowLong (int nIndex) const
 
LONG_PTR GetWindowLongPtr (int nIndex) const
 
BOOL GetWindowPlacement (WINDOWPLACEMENT *lpwndpl) const
 
DWORD GetWindowProcessID ()
 
BOOL GetWindowRect (LPRECT lpRect) const
 
int GetWindowRgn (HRGN hRgn)
 
int GetWindowText (LPTSTR lpszStringBuf, int nMaxCount) const
 
BOOL GetWindowText (BSTR &bstrText)
 
int GetWindowTextLength () const
 
DWORD GetWindowThreadID ()
 
WORD GetWindowWord (int nIndex) const
 
void GotoDlgCtrl (HWND hWndCtrl) const
 
BOOL HideCaret ()
 
BOOL HiliteMenuItem (HMENU hMenu, UINT uHiliteItem, UINT uHilite)
 
BOOL Invalidate (BOOL bErase=TRUE)
 
BOOL InvalidateRect (LPCRECT lpRect, BOOL bErase=TRUE)
 
void InvalidateRgn (HRGN hRgn, BOOL bErase=TRUE)
 
BOOL IsChild (const HWND hWnd) const
 
BOOL IsDialogMessage (LPMSG lpMsg)
 
UINT IsDlgButtonChecked (int nIDButton) const
 
BOOL IsIconic () const
 
BOOL IsParentDialog ()
 
BOOL IsWindow () const
 
BOOL IsWindowEnabled () const
 
BOOL IsWindowVisible () const
 
BOOL IsWindowUnicode ()
 
BOOL IsZoomed () const
 
BOOL KillTimer (UINT_PTR nIDEvent)
 
BOOL LockWindowUpdate (BOOL bLock=TRUE)
 
int MapWindowPoints (HWND hWndTo, LPPOINT lpPoint, UINT nCount) const
 
int MapWindowPoints (HWND hWndTo, LPRECT lpRect) const
 
int MessageBox (LPCTSTR lpszText, LPCTSTR lpszCaption=NULL, UINT nType=MB_OK)
 
BOOL ModifyStyle (DWORD dwRemove, DWORD dwAdd, UINT nFlags=0)
 
BOOL ModifyStyleEx (DWORD dwRemove, DWORD dwAdd, UINT nFlags=0)
 
BOOL MoveWindow (int x, int y, int nWidth, int nHeight, BOOL bRepaint=TRUE)
 
void NextDlgCtrl () const
 
BOOL OpenClipboard ()
 
BOOL PostMessage (UINT message, WPARAM wParam=0, LPARAM lParam=0)
 
void PrevDlgCtrl () const
 
void Print (HDC hDC, DWORD dwFlags) const
 
void PrintClient (HDC hDC, DWORD dwFlags) const
 
BOOL RedrawWindow (LPCRECT lpRectUpdate=NULL, HRGN hRgnUpdate=NULL, UINT flags=RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE)
 
int ReleaseDC (HDC hDC)
 
BOOL ResizeClient (int nWidth, int nHeight, BOOL bRedraw=FALSE)
 
BOOL ScreenToClient (LPPOINT lpPoint) const
 
BOOL ScrollWindow (int xAmount, int yAmount, LPCRECT lpRect=NULL, LPCRECT lpClipRect=NULL)
 
int ScrollWindowEx (int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, HRGN hRgnUpdate, LPRECT lpRectUpdate, UINT flags)
 
LRESULT SendDlgItemMessage (int nID, UINT message, WPARAM wParam=0, LPARAM lParam=0)
 
LRESULT SendMessage (UINT message, WPARAM wParam=0, LPARAM lParam=0)
 
void SendMessageToDescendants (UINT message, WPARAM wParam=0, LPARAM lParam=0, BOOL bDeep=TRUE)
 
BOOL SendNotifyMessage (UINT message, WPARAM wParam=0, LPARAM lParam=0)
 
HWND SetActiveWindow ()
 
HWND SetCapture ()
 
HWND SetClipboardViewer ()
 
int SetDlgCtrlID (int nID)
 
BOOL SetDlgItemInt (int nID, UINT nValue, BOOL bSigned=TRUE)
 
BOOL SetDlgItemText (int nID, LPCTSTR lpszString)
 
HWND SetFocus ()
 
void SetFont (HFONT hFont, BOOL bRedraw=TRUE)
 
int SetHotKey (WORD wVirtualKeyCode, WORD wModifiers)
 
HICON SetIcon (HICON hIcon, BOOL bBigIcon=TRUE)
 
BOOL SetMenu (HMENU hMenu)
 
HWND SetParent (HWND hWndNewParent)
 
void SetRedraw (BOOL bRedraw=TRUE)
 
int SetScrollInfo (int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedraw=TRUE)
 
int SetScrollPos (int nBar, int nPos, BOOL bRedraw=TRUE)
 
BOOL SetScrollRange (int nBar, int nMinPos, int nMaxPos, BOOL bRedraw=TRUE)
 
UINT_PTR SetTimer (UINT_PTR nIDEvent, UINT nElapse, void(CALLBACK *lpfnTimer)(HWND, UINT, UINT_PTR, DWORD)=NULL)
 
BOOL SetWindowContextHelpId (DWORD dwContextHelpId)
 
LONG SetWindowLong (int nIndex, LONG dwNewLong)
 
LONG_PTR SetWindowLongPtr (int nIndex, LONG_PTR dwNewLong)
 
BOOL SetWindowPlacement (const WINDOWPLACEMENT *lpwndpl)
 
BOOL SetWindowPos (HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags)
 
int SetWindowRgn (HRGN hRgn, BOOL bRedraw=FALSE)
 
BOOL SetWindowText (LPCTSTR lpszString)
 
WORD SetWindowWord (int nIndex, WORD wNewWord)
 
BOOL ShowCaret ()
 
BOOL ShowOwnedPopups (BOOL bShow=TRUE)
 
BOOL ShowScrollBar (UINT nBar, BOOL bShow=TRUE)
 
BOOL ShowWindow (int nCmdShow)
 
BOOL ShowWindowAsync (int nCmdShow)
 
BOOL UpdateWindow ()
 
BOOL ValidateRect (LPCRECT lpRect)
 
BOOL ValidateRgn (HRGN hRgn)
 
BOOL WinHelp (LPCTSTR lpszHelp, UINT nCmd=HELP_CONTEXT, DWORD dwData=0)
 
- Public Member Functions inherited from ATL::CMessageMap
virtual BOOL ProcessWindowMessage (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult, DWORD dwMsgMapID)=0
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Private Member Functions

LRESULT OnThemeChanged ()
 
LRESULT OnThemeChanged (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
BOOL MeasureLines ()
 
WORD GetMinimumSize (IN BOOL Horizontal, IN OUT PSIZE pSize)
 
VOID UpdateWnd ()
 
VOID Update ()
 
UINT CalculateDueTime ()
 
BOOL ResetTime ()
 
VOID CalibrateTimer ()
 
LRESULT OnDestroy (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnPaint (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
VOID SetFont (IN HFONT hNewFont, IN BOOL bRedraw)
 
LRESULT DrawBackground (HDC hdc)
 
LRESULT OnEraseBackground (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnTimer (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnGetMinimumSize (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnContextMenu (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSetFont (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnCreate (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSize (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnTaskbarSettingsChanged (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnLButtonDblClick (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 

Private Attributes

HFONT hFont
 
COLORREF textColor
 
RECT rcText
 
SYSTEMTIME LocalTime
 
CTooltips m_tooltip
 
union {
   DWORD   dwFlags
 
   struct {
      DWORD   IsTimerEnabled: 1
 
      DWORD   IsInitTimerEnabled: 1
 
      DWORD   LinesMeasured: 1
 
      DWORD   IsHorizontal: 1
 
   } 
 
}; 
 
DWORD LineSpacing
 
SIZE CurrentSize
 
WORD VisibleLines
 
SIZE LineSizes [CLOCKWND_FORMAT_COUNT]
 
WCHAR szLines [CLOCKWND_FORMAT_COUNT][48]
 

Additional Inherited Members

- Public Types inherited from ATL::CWindowImplRoot< CWindow >
enum  
 
- Public Types inherited from IOleWindow
typedef IOleWindowLPOLEWINDOW
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Static Public Member Functions inherited from ATL::CComCoClass< CTrayClockWnd >
static LPCTSTR WINAPI GetObjectDescription ()
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Static Public Member Functions inherited from ATL::CWindowImpl< CTrayClockWnd, CWindow, CControlWinTraits >
static LPCTSTR GetWndCaption ()
 
- Static Public Member Functions inherited from ATL::CWindowImplBaseT< CWindow, CControlWinTraits >
static DWORD GetWndStyle (DWORD dwStyle)
 
static DWORD GetWndExStyle (DWORD dwExStyle)
 
static LRESULT CALLBACK StartWindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK WindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
- Static Public Member Functions inherited from ATL::CWindow
static LPCTSTR GetWndClassName ()
 
static LRESULT SendMessage (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 
- Public Attributes inherited from ATL::CWindowImplBaseT< CWindow, CControlWinTraits >
WNDPROC m_pfnSuperWindowProc
 
- Public Attributes inherited from ATL::CWindowImplRoot< CWindow >
CWndProcThunk m_thunk
 
const _ATL_MSGm_pCurrentMsg
 
DWORD m_dwState
 
- Public Attributes inherited from ATL::CWindow
HWND m_hWnd
 
- Static Public Attributes inherited from ATL::CWindow
static RECT rcDefault
 

Detailed Description

Definition at line 44 of file trayclock.cpp.

Constructor & Destructor Documentation

◆ CTrayClockWnd()

CTrayClockWnd::CTrayClockWnd ( )

Definition at line 151 of file trayclock.cpp.

151  :
152  hFont(NULL),
153  dwFlags(0),
154  LineSpacing(0),
155  VisibleLines(0)
156 {
157  ZeroMemory(&textColor, sizeof(textColor));
158  ZeroMemory(&rcText, sizeof(rcText));
159  ZeroMemory(&LocalTime, sizeof(LocalTime));
161  ZeroMemory(LineSizes, sizeof(LineSizes));
162  ZeroMemory(szLines, sizeof(szLines));
163 }
#define ZeroMemory
Definition: winbase.h:1648
SIZE LineSizes[CLOCKWND_FORMAT_COUNT]
Definition: trayclock.cpp:70
smooth NULL
Definition: ftsmooth.c:416
DWORD LineSpacing
Definition: trayclock.cpp:67
SIZE CurrentSize
Definition: trayclock.cpp:68
COLORREF textColor
Definition: trayclock.cpp:51
WCHAR szLines[CLOCKWND_FORMAT_COUNT][48]
Definition: trayclock.cpp:71
WORD VisibleLines
Definition: trayclock.cpp:69
SYSTEMTIME LocalTime
Definition: trayclock.cpp:53

◆ ~CTrayClockWnd()

CTrayClockWnd::~CTrayClockWnd ( )
virtual

Definition at line 164 of file trayclock.cpp.

164 { }

Member Function Documentation

◆ CalculateDueTime()

UINT CTrayClockWnd::CalculateDueTime ( )
private

Definition at line 423 of file trayclock.cpp.

424 {
425  UINT uiDueTime;
426 
428  uiDueTime = 1000 - (UINT) LocalTime.wMilliseconds;
430  uiDueTime += (59 - (UINT) LocalTime.wSecond) * 1000;
431 
432  if (uiDueTime < USER_TIMER_MINIMUM || uiDueTime > USER_TIMER_MAXIMUM)
433  uiDueTime = 1000;
434  else
435  {
436  /* Add an artificial delay of 0.05 seconds to make sure the timer
437  doesn't fire too early*/
438  uiDueTime += 50;
439  }
440 
441  return uiDueTime;
442 }
BOOL bShowSeconds
Definition: precomp.h:207
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
if(!(yy_init))
Definition: macro.lex.yy.c:714
WORD wSecond
Definition: winbase.h:889
WORD wMilliseconds
Definition: winbase.h:890
#define USER_TIMER_MAXIMUM
Definition: winuser.h:895
unsigned int UINT
Definition: ndis.h:50
SYSTEMTIME LocalTime
Definition: trayclock.cpp:53

Referenced by CalibrateTimer(), and ResetTime().

◆ CalibrateTimer()

VOID CTrayClockWnd::CalibrateTimer ( )
private

Definition at line 469 of file trayclock.cpp.

470 {
471  UINT uiDueTime;
472  BOOL Ret;
473  UINT uiWait1, uiWait2;
474 
475  /* Kill the initialization timer */
478 
479  uiDueTime = CalculateDueTime();
480 
482  {
483  uiWait1 = 1000 - 200;
484  uiWait2 = 1000;
485  }
486  else
487  {
488  uiWait1 = 60 * 1000 - 200;
489  uiWait2 = 60 * 1000;
490  }
491 
492  if (uiDueTime > uiWait1)
493  {
494  /* The update of the clock will be up to 200 ms late, but that's
495  acceptable. We're going to setup a timer that fires depending
496  uiWait2. */
497  Ret = SetTimer(ID_TRAYCLOCK_TIMER, uiWait2, NULL) != 0;
498  IsTimerEnabled = Ret;
499  }
500  else
501  {
502  /* Recalibrate the timer and recalculate again when the current
503  minute/second ends. */
504  ResetTime();
505  }
506 
507  /* Update the time */
508  Update();
509 }
BOOL bShowSeconds
Definition: precomp.h:207
#define ID_TRAYCLOCK_TIMER_INIT
Definition: trayclock.cpp:146
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
UINT_PTR SetTimer(UINT_PTR nIDEvent, UINT nElapse, void(CALLBACK *lpfnTimer)(HWND, UINT, UINT_PTR, DWORD)=NULL)
Definition: atlwin.h:1190
BOOL KillTimer(UINT_PTR nIDEvent)
Definition: atlwin.h:908
smooth NULL
Definition: ftsmooth.c:416
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
UINT CalculateDueTime()
Definition: trayclock.cpp:423
#define ID_TRAYCLOCK_TIMER
Definition: trayclock.cpp:145
DWORD IsInitTimerEnabled
Definition: trayclock.cpp:62
unsigned int UINT
Definition: ndis.h:50
DWORD IsTimerEnabled
Definition: trayclock.cpp:61
BOOL ResetTime()
Definition: trayclock.cpp:444

Referenced by OnTimer().

◆ ContextSensitiveHelp()

HRESULT WINAPI CTrayClockWnd::ContextSensitiveHelp ( BOOL  fEnterMode)
inline

Implements IOleWindow.

Definition at line 112 of file trayclock.cpp.

113  {
114  return E_NOTIMPL;
115  }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ DrawBackground()

LRESULT CTrayClockWnd::DrawBackground ( HDC  hdc)
private

Definition at line 596 of file trayclock.cpp.

597 {
598  RECT rect;
599 
602 
603  return TRUE;
604 }
#define TRUE
Definition: types.h:120
& rect
Definition: startmenu.cpp:1413
BOOL GetClientRect(LPRECT lpRect) const
Definition: atlwin.h:507
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
HDC hdc
Definition: main.c:9
HWND m_hWnd
Definition: atlwin.h:268

Referenced by OnEraseBackground().

◆ GetMinimumSize()

WORD CTrayClockWnd::GetMinimumSize ( IN BOOL  Horizontal,
IN OUT PSIZE  pSize 
)
private

Definition at line 269 of file trayclock.cpp.

270 {
271  WORD iLinesVisible = 0;
272  UINT i;
273  SIZE szMax = { 0, 0 };
274 
275  if (!LinesMeasured)
277 
278  if (!LinesMeasured)
279  return 0;
280 
281  for (i = 0; i < CLOCKWND_FORMAT_COUNT; i++)
282  {
283  if (LineSizes[i].cx != 0)
284  {
285  if (iLinesVisible > 0)
286  {
287  if (Horizontal)
288  {
289  if (szMax.cy + LineSizes[i].cy + (LONG) LineSpacing >
290  pSize->cy - (2 * TRAY_CLOCK_WND_SPACING_Y))
291  {
292  break;
293  }
294  }
295  else
296  {
297  if (LineSizes[i].cx > pSize->cx - (2 * TRAY_CLOCK_WND_SPACING_X))
298  break;
299  }
300 
301  /* Add line spacing */
302  szMax.cy += LineSpacing;
303  }
304 
305  iLinesVisible++;
306 
307  /* Increase maximum rectangle */
308  szMax.cy += LineSizes[i].cy;
309  if (LineSizes[i].cx > szMax.cx)
310  szMax.cx = LineSizes[i].cx;
311  }
312  }
313 
314  szMax.cx += 2 * TRAY_CLOCK_WND_SPACING_X;
315  szMax.cy += 2 * TRAY_CLOCK_WND_SPACING_Y;
316 
317  *pSize = szMax;
318 
319  return iLinesVisible;
320 }
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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
long LONG
Definition: pedump.c:60
SIZE LineSizes[CLOCKWND_FORMAT_COUNT]
Definition: trayclock.cpp:70
LONG cx
Definition: windef.h:334
DWORD LineSpacing
Definition: trayclock.cpp:67
#define TRAY_CLOCK_WND_SPACING_X
Definition: trayclock.cpp:148
unsigned short WORD
Definition: ntddk_ex.h:93
#define CLOCKWND_FORMAT_COUNT
Definition: trayclock.cpp:40
DWORD LinesMeasured
Definition: trayclock.cpp:63
BOOL MeasureLines()
Definition: trayclock.cpp:213
#define TRAY_CLOCK_WND_SPACING_Y
Definition: trayclock.cpp:149
unsigned int UINT
Definition: ndis.h:50
_Out_opt_ int * cx
Definition: commctrl.h:581
LONG cy
Definition: windef.h:335

Referenced by OnGetMinimumSize(), OnSize(), and UpdateWnd().

◆ GetWindow()

HRESULT WINAPI CTrayClockWnd::GetWindow ( HWND phwnd)
inline

Implements IOleWindow.

Definition at line 104 of file trayclock.cpp.

105  {
106  if (!phwnd)
107  return E_INVALIDARG;
108  *phwnd = m_hWnd;
109  return S_OK;
110  }
#define E_INVALIDARG
Definition: ddrawi.h:101
HWND m_hWnd
Definition: atlwin.h:268
#define S_OK
Definition: intsafe.h:51

◆ Initialize()

HRESULT CTrayClockWnd::Initialize ( IN HWND  hWndParent)

Definition at line 753 of file trayclock.cpp.

754 {
755  IsHorizontal = TRUE;
756 
757  /* Create the window. The tray window is going to move it to the correct
758  position and resize it as needed. */
759  DWORD dwStyle = WS_CHILD | WS_CLIPSIBLINGS;
761  dwStyle |= WS_VISIBLE;
762 
763  Create(hWndParent, 0, NULL, dwStyle);
764  if (!m_hWnd)
765  return E_FAIL;
766 
767  SetWindowTheme(m_hWnd, L"TrayNotify", NULL);
768 
769  return S_OK;
770 
771 };
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
DWORD HideClock
Definition: precomp.h:195
DWORD IsHorizontal
Definition: trayclock.cpp:64
#define TRUE
Definition: types.h:120
HWND Create(HWND hWndParent, _U_RECT rect=NULL, LPCTSTR szWindowName=NULL, DWORD dwStyle=0, DWORD dwExStyle=0, _U_MENUorID MenuOrID=0U, LPVOID lpCreateParam=NULL)
Definition: atlwin.h:1637
#define WS_CHILD
Definition: pedump.c:617
#define E_FAIL
Definition: ddrawi.h:102
TW_STRUCKRECTS2 sr
Definition: precomp.h:209
HRESULT WINAPI SetWindowTheme(_In_ HWND hwnd, _In_ LPCWSTR pszSubAppName, _In_ LPCWSTR pszSubIdList)
Definition: uxthemesupp.c:69
smooth NULL
Definition: ftsmooth.c:416
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
HWND m_hWnd
Definition: atlwin.h:268
#define S_OK
Definition: intsafe.h:51
#define WS_VISIBLE
Definition: pedump.c:620

◆ MeasureLines()

BOOL CTrayClockWnd::MeasureLines ( )
private

Definition at line 213 of file trayclock.cpp.

214 {
215  HDC hDC;
216  HFONT hPrevFont;
217  UINT c, i;
218  BOOL bRet = TRUE;
219 
220  hDC = GetDC();
221  if (hDC != NULL)
222  {
223  if (hFont)
224  hPrevFont = (HFONT) SelectObject(hDC, hFont);
225 
226  for (i = 0; i < CLOCKWND_FORMAT_COUNT && bRet; i++)
227  {
228  if (szLines[i][0] != L'\0' &&
230  &LineSizes[i]))
231  {
232  bRet = FALSE;
233  break;
234  }
235  }
236 
237  if (hFont)
238  SelectObject(hDC, hPrevFont);
239 
240  ReleaseDC(hDC);
241 
242  if (bRet)
243  {
244  LineSpacing = 0;
245 
246  /* calculate the line spacing */
247  for (i = 0, c = 0; i < CLOCKWND_FORMAT_COUNT; i++)
248  {
249  if (LineSizes[i].cx > 0)
250  {
252  c++;
253  }
254  }
255 
256  if (c > 0)
257  {
258  /* We want a spacing of 1/2 line */
259  LineSpacing = (LineSpacing / c) / 2;
260  }
261 
262  return TRUE;
263  }
264  }
265 
266  return FALSE;
267 }
#define TRUE
Definition: types.h:120
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
SIZE LineSizes[CLOCKWND_FORMAT_COUNT]
Definition: trayclock.cpp:70
smooth NULL
Definition: ftsmooth.c:416
DWORD LineSpacing
Definition: trayclock.cpp:67
const GLubyte * c
Definition: glext.h:8905
#define CLOCKWND_FORMAT_COUNT
Definition: trayclock.cpp:40
static const WCHAR L[]
Definition: oid.c:1250
int ReleaseDC(HDC hDC)
Definition: atlwin.h:1006
WCHAR szLines[CLOCKWND_FORMAT_COUNT][48]
Definition: trayclock.cpp:71
static HDC hDC
Definition: 3dtext.c:33
unsigned int UINT
Definition: ndis.h:50
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
_Out_opt_ int * cx
Definition: commctrl.h:581
#define c
Definition: ke_i.h:80
LONG cy
Definition: windef.h:335
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
HDC GetDC()
Definition: atlwin.h:513
BOOL WINAPI GetTextExtentPointW(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE lpsz)

Referenced by GetMinimumSize(), SetFont(), and UpdateWnd().

◆ OnContextMenu()

LRESULT CTrayClockWnd::OnContextMenu ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 641 of file trayclock.cpp.

642 {
643  return GetParent().SendMessage(uMsg, wParam, lParam);
644 }
WPARAM wParam
Definition: combotst.c:138
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048
CWindow GetParent() const
Definition: atlwin.h:654
LPARAM lParam
Definition: combotst.c:139

◆ OnCreate()

LRESULT CTrayClockWnd::OnCreate ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 652 of file trayclock.cpp.

653 {
655 
656  TOOLINFOW ti = { 0 };
657  ti.cbSize = TTTOOLINFOW_V1_SIZE;
658  ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
659  ti.hwnd = m_hWnd;
660  ti.uId = reinterpret_cast<UINT_PTR>(m_hWnd);
661  ti.lpszText = NULL;
662  ti.lParam = NULL;
663 
664  m_tooltip.AddTool(&ti);
665 
667  {
668  ResetTime();
669  }
670 
671  /* Update the time */
672  Update();
673 
674  return TRUE;
675 }
DWORD HideClock
Definition: precomp.h:195
#define TRUE
Definition: types.h:120
BOOL AddTool(IN CONST TTTOOLINFOW *pInfo)
Definition: rosctrls.h:635
TW_STRUCKRECTS2 sr
Definition: precomp.h:209
#define TTTOOLINFOW_V1_SIZE
Definition: commctrl.h:1717
CTooltips m_tooltip
Definition: trayclock.cpp:54
#define TTS_ALWAYSTIP
Definition: commctrl.h:1753
#define TTF_IDISHWND
Definition: commctrl.h:1760
smooth NULL
Definition: ftsmooth.c:416
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
#define TOOLINFOW
Definition: commctrl.h:1711
HWND m_hWnd
Definition: atlwin.h:268
HWND Create(HWND hWndParent, DWORD dwStyles=WS_POPUP|TTS_NOPREFIX, DWORD dwExStyles=WS_EX_TOPMOST)
Definition: rosctrls.h:614
#define WS_POPUP
Definition: pedump.c:616
#define TTS_NOPREFIX
Definition: commctrl.h:1754
#define TTF_SUBCLASS
Definition: commctrl.h:1763
BOOL ResetTime()
Definition: trayclock.cpp:444

◆ OnDestroy()

LRESULT CTrayClockWnd::OnDestroy ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 511 of file trayclock.cpp.

512 {
513  /* Disable all timers */
514  if (IsTimerEnabled)
515  {
517  }
518  else if (IsInitTimerEnabled)
519  {
521  }
522 
523  return TRUE;
524 }
#define TRUE
Definition: types.h:120
#define ID_TRAYCLOCK_TIMER_INIT
Definition: trayclock.cpp:146
BOOL KillTimer(UINT_PTR nIDEvent)
Definition: atlwin.h:908
#define ID_TRAYCLOCK_TIMER
Definition: trayclock.cpp:145
DWORD IsInitTimerEnabled
Definition: trayclock.cpp:62
DWORD IsTimerEnabled
Definition: trayclock.cpp:61

◆ OnEraseBackground()

LRESULT CTrayClockWnd::OnEraseBackground ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 606 of file trayclock.cpp.

607 {
608  HDC hdc = (HDC) wParam;
609 
610  if (!IsAppThemed())
611  {
612  bHandled = FALSE;
613  return 0;
614  }
615 
616  return DrawBackground(hdc);
617 }
static HDC
Definition: imagelist.c:92
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
BOOL WINAPI IsAppThemed(void)
Definition: system.c:596
HDC hdc
Definition: main.c:9
LRESULT DrawBackground(HDC hdc)
Definition: trayclock.cpp:596

◆ OnGetMinimumSize()

LRESULT CTrayClockWnd::OnGetMinimumSize ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 634 of file trayclock.cpp.

635 {
637 
638  return (LRESULT) GetMinimumSize((BOOL) wParam, (PSIZE) lParam) != 0;
639 }
WORD GetMinimumSize(IN BOOL Horizontal, IN OUT PSIZE pSize)
Definition: trayclock.cpp:269
DWORD IsHorizontal
Definition: trayclock.cpp:64
#define BOOL
Definition: nt_native.h:43
WPARAM wParam
Definition: combotst.c:138
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139

◆ OnLButtonDblClick()

LRESULT CTrayClockWnd::OnLButtonDblClick ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 743 of file trayclock.cpp.

744 {
745  if (IsWindowVisible())
746  {
747  //FIXME: use SHRunControlPanel
748  ShellExecuteW(m_hWnd, NULL, L"timedate.cpl", NULL, NULL, SW_NORMAL);
749  }
750  return TRUE;
751 }
#define SW_NORMAL
Definition: winuser.h:763
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR L[]
Definition: oid.c:1250
HWND m_hWnd
Definition: atlwin.h:268
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2274
BOOL IsWindowVisible() const
Definition: atlwin.h:890

◆ OnPaint()

LRESULT CTrayClockWnd::OnPaint ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 526 of file trayclock.cpp.

527 {
528  RECT rcClient;
529  HFONT hPrevFont;
530  INT iPrevBkMode;
531  UINT i, line;
532 
533  PAINTSTRUCT ps;
534  HDC hDC = (HDC) wParam;
535 
536  if (wParam == 0)
537  {
538  hDC = BeginPaint(&ps);
539  }
540 
541  if (hDC == NULL)
542  return FALSE;
543 
544  if (LinesMeasured &&
545  GetClientRect(&rcClient))
546  {
547  iPrevBkMode = SetBkMode(hDC, TRANSPARENT);
548 
550 
551  hPrevFont = (HFONT) SelectObject(hDC, hFont);
552 
553  rcClient.top = (rcClient.bottom - CurrentSize.cy) / 2;
554  rcClient.bottom = rcClient.top + CurrentSize.cy;
555 
556  for (i = 0, line = 0;
558  i++)
559  {
560  if (LineSizes[i].cx != 0)
561  {
562  TextOut(hDC,
563  (rcClient.right - LineSizes[i].cx) / 2,
564  rcClient.top + TRAY_CLOCK_WND_SPACING_Y,
565  szLines[i],
566  wcslen(szLines[i]));
567 
568  rcClient.top += LineSizes[i].cy + LineSpacing;
569  line++;
570  }
571  }
572 
573  SelectObject(hDC, hPrevFont);
574 
575  SetBkMode(hDC, iPrevBkMode);
576  }
577 
578  if (wParam == 0)
579  {
580  EndPaint(&ps);
581  }
582 
583  return TRUE;
584 }
#define TRUE
Definition: types.h:120
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
void EndPaint(LPPAINTSTRUCT lpPaint)
Definition: atlwin.h:495
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:58
WPARAM wParam
Definition: combotst.c:138
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1034
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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
BOOL GetClientRect(LPRECT lpRect) const
Definition: atlwin.h:507
#define TRANSPARENT
Definition: wingdi.h:949
SIZE LineSizes[CLOCKWND_FORMAT_COUNT]
Definition: trayclock.cpp:70
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
Definition: parser.c:48
DWORD LineSpacing
Definition: trayclock.cpp:67
SIZE CurrentSize
Definition: trayclock.cpp:68
HDC BeginPaint(LPPAINTSTRUCT lpPaint)
Definition: atlwin.h:297
#define CLOCKWND_FORMAT_COUNT
Definition: trayclock.cpp:40
char line[200]
Definition: main.c:97
DWORD LinesMeasured
Definition: trayclock.cpp:63
COLORREF textColor
Definition: trayclock.cpp:51
WCHAR szLines[CLOCKWND_FORMAT_COUNT][48]
Definition: trayclock.cpp:71
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
static HDC hDC
Definition: 3dtext.c:33
#define TRAY_CLOCK_WND_SPACING_Y
Definition: trayclock.cpp:149
unsigned int UINT
Definition: ndis.h:50
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
_Out_opt_ int * cx
Definition: commctrl.h:581
#define TextOut
Definition: wingdi.h:4482
LONG bottom
Definition: windef.h:309
WORD VisibleLines
Definition: trayclock.cpp:69
LONG cy
Definition: windef.h:335
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ OnSetFont()

LRESULT CTrayClockWnd::OnSetFont ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 646 of file trayclock.cpp.

647 {
649  return TRUE;
650 }
#define TRUE
Definition: types.h:120
WPARAM wParam
Definition: combotst.c:138
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID SetFont(IN HFONT hNewFont, IN BOOL bRedraw)
Definition: trayclock.cpp:586
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

◆ OnSize()

LRESULT CTrayClockWnd::OnSize ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 677 of file trayclock.cpp.

678 {
679  SIZE szClient;
680 
681  szClient.cx = LOWORD(lParam);
682  szClient.cy = HIWORD(lParam);
683 
685  CurrentSize = szClient;
686 
688  return TRUE;
689 }
WORD GetMinimumSize(IN BOOL Horizontal, IN OUT PSIZE pSize)
Definition: trayclock.cpp:269
DWORD IsHorizontal
Definition: trayclock.cpp:64
#define TRUE
Definition: types.h:120
BOOL InvalidateRect(LPCRECT lpRect, BOOL bErase=TRUE)
Definition: atlwin.h:834
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
SIZE CurrentSize
Definition: trayclock.cpp:68
#define HIWORD(l)
Definition: typedefs.h:247
WORD VisibleLines
Definition: trayclock.cpp:69
LONG cy
Definition: windef.h:335
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

◆ OnTaskbarSettingsChanged()

LRESULT CTrayClockWnd::OnTaskbarSettingsChanged ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 691 of file trayclock.cpp.

692 {
693  BOOL bRealign = FALSE;
694 
695  TaskbarSettings* newSettings = (TaskbarSettings*)lParam;
696  if (newSettings->bShowSeconds != g_TaskbarSettings.bShowSeconds)
697  {
700  {
701  bRealign = TRUE;
702 
703  ResetTime();
704  }
705  }
706 
707  if (newSettings->sr.HideClock != g_TaskbarSettings.sr.HideClock)
708  {
709  g_TaskbarSettings.sr.HideClock = newSettings->sr.HideClock;
711  bRealign = TRUE;
712 
714  {
715  /* Disable all timers */
716  if (IsTimerEnabled)
717  {
720  }
721  else if (IsInitTimerEnabled)
722  {
725  }
726  }
727  else
728  {
729  ResetTime();
730  }
731  }
732 
733  if (bRealign)
734  {
735  /* Ask the parent to resize */
736  NMHDR nmh = {GetParent(), 0, NTNWM_REALIGN};
737  GetParent().SendMessage(WM_NOTIFY, 0, (LPARAM) &nmh);
738  Update();
739  }
740  return 0;
741 }
DWORD HideClock
Definition: precomp.h:195
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
BOOL bShowSeconds
Definition: precomp.h:207
#define ID_TRAYCLOCK_TIMER_INIT
Definition: trayclock.cpp:146
TW_STRUCKRECTS2 sr
Definition: precomp.h:209
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL KillTimer(UINT_PTR nIDEvent)
Definition: atlwin.h:908
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
LONG_PTR LPARAM
Definition: windef.h:208
#define SW_SHOW
Definition: winuser.h:769
#define NTNWM_REALIGN
Definition: precomp.h:336
#define ID_TRAYCLOCK_TIMER
Definition: trayclock.cpp:145
DWORD IsInitTimerEnabled
Definition: trayclock.cpp:62
BOOL ShowWindow(int nCmdShow)
Definition: atlwin.h:1265
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048
CWindow GetParent() const
Definition: atlwin.h:654
LPARAM lParam
Definition: combotst.c:139
DWORD IsTimerEnabled
Definition: trayclock.cpp:61
#define WM_NOTIFY
Definition: richedit.h:61
BOOL ResetTime()
Definition: trayclock.cpp:444

◆ OnThemeChanged() [1/2]

LRESULT CTrayClockWnd::OnThemeChanged ( )
private

Definition at line 166 of file trayclock.cpp.

167 {
168  LOGFONTW clockFont;
169  HTHEME clockTheme;
170  HFONT hFont;
171 
172  clockTheme = OpenThemeData(m_hWnd, L"Clock");
173 
174  if (clockTheme)
175  {
176  GetThemeFont(clockTheme,
177  NULL,
178  CLP_TIME,
179  0,
180  TMT_FONT,
181  &clockFont);
182 
183  hFont = CreateFontIndirectW(&clockFont);
184 
185  GetThemeColor(clockTheme,
186  CLP_TIME,
187  0,
189  &textColor);
190 
191  if (this->hFont != NULL)
192  DeleteObject(this->hFont);
193 
194  SetFont(hFont, FALSE);
195  }
196  else
197  {
198  /* We don't need to set a font here, our parent will use
199  * WM_SETFONT to set the right one when themes are not enabled. */
200  textColor = RGB(0, 0, 0);
201  }
202 
203  CloseThemeData(clockTheme);
204 
205  return TRUE;
206 }
#define RGB(r, g, b)
Definition: precomp.h:62
#define TRUE
Definition: types.h:120
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HRESULT WINAPI GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, LOGFONTW *pFont)
Definition: property.c:108
#define FALSE
Definition: types.h:117
VOID SetFont(IN HFONT hNewFont, IN BOOL bRedraw)
Definition: trayclock.cpp:586
#define TMT_TEXTCOLOR
Definition: vssym32.h:328
smooth NULL
Definition: ftsmooth.c:416
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
#define TMT_FONT
Definition: vssym32.h:144
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
Definition: system.c:835
static const WCHAR L[]
Definition: oid.c:1250
COLORREF textColor
Definition: trayclock.cpp:51
HWND m_hWnd
Definition: atlwin.h:268
HRESULT WINAPI GetThemeColor(HTHEME hTheme, int iPartId, int iStateId, int iPropId, COLORREF *pColor)
Definition: property.c:45
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950

Referenced by OnThemeChanged().

◆ OnThemeChanged() [2/2]

LRESULT CTrayClockWnd::OnThemeChanged ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 208 of file trayclock.cpp.

209 {
210  return OnThemeChanged();
211 }
LRESULT OnThemeChanged()
Definition: trayclock.cpp:166

◆ OnTimer()

LRESULT CTrayClockWnd::OnTimer ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 619 of file trayclock.cpp.

620 {
621  switch (wParam)
622  {
623  case ID_TRAYCLOCK_TIMER:
624  Update();
625  break;
626 
628  CalibrateTimer();
629  break;
630  }
631  return TRUE;
632 }
#define TRUE
Definition: types.h:120
#define ID_TRAYCLOCK_TIMER_INIT
Definition: trayclock.cpp:146
WPARAM wParam
Definition: combotst.c:138
#define ID_TRAYCLOCK_TIMER
Definition: trayclock.cpp:145
VOID CalibrateTimer()
Definition: trayclock.cpp:469

◆ ResetTime()

BOOL CTrayClockWnd::ResetTime ( )
private

Definition at line 444 of file trayclock.cpp.

445 {
446  UINT uiDueTime;
447  BOOL Ret;
448 
449  /* Disable all timers */
450  if (IsTimerEnabled)
451  {
454  }
455  else if (IsInitTimerEnabled)
456  {
458  }
459 
460  uiDueTime = CalculateDueTime();
461 
462  /* Set the new timer */
463  Ret = SetTimer(ID_TRAYCLOCK_TIMER_INIT, uiDueTime, NULL) != 0;
464  IsInitTimerEnabled = Ret;
465 
466  return Ret;
467 }
#define ID_TRAYCLOCK_TIMER_INIT
Definition: trayclock.cpp:146
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
UINT_PTR SetTimer(UINT_PTR nIDEvent, UINT nElapse, void(CALLBACK *lpfnTimer)(HWND, UINT, UINT_PTR, DWORD)=NULL)
Definition: atlwin.h:1190
BOOL KillTimer(UINT_PTR nIDEvent)
Definition: atlwin.h:908
smooth NULL
Definition: ftsmooth.c:416
UINT CalculateDueTime()
Definition: trayclock.cpp:423
#define ID_TRAYCLOCK_TIMER
Definition: trayclock.cpp:145
DWORD IsInitTimerEnabled
Definition: trayclock.cpp:62
unsigned int UINT
Definition: ndis.h:50
DWORD IsTimerEnabled
Definition: trayclock.cpp:61

Referenced by CalibrateTimer(), OnCreate(), and OnTaskbarSettingsChanged().

◆ SetFont()

VOID CTrayClockWnd::SetFont ( IN HFONT  hNewFont,
IN BOOL  bRedraw 
)
private

Definition at line 586 of file trayclock.cpp.

587 {
588  hFont = hNewFont;
590  if (bRedraw)
591  {
593  }
594 }
#define TRUE
Definition: types.h:120
BOOL InvalidateRect(LPCRECT lpRect, BOOL bErase=TRUE)
Definition: atlwin.h:834
smooth NULL
Definition: ftsmooth.c:416
DWORD LinesMeasured
Definition: trayclock.cpp:63
BOOL MeasureLines()
Definition: trayclock.cpp:213

Referenced by OnSetFont(), and OnThemeChanged().

◆ Update()

VOID CTrayClockWnd::Update ( )
private

Definition at line 417 of file trayclock.cpp.

418 {
420  UpdateWnd();
421 }
VOID UpdateWnd()
Definition: trayclock.cpp:322
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
SYSTEMTIME LocalTime
Definition: trayclock.cpp:53

Referenced by CalibrateTimer(), OnCreate(), OnTaskbarSettingsChanged(), and OnTimer().

◆ UpdateWnd()

VOID CTrayClockWnd::UpdateWnd ( )
private

Definition at line 322 of file trayclock.cpp.

323 {
324  SIZE szPrevCurrent;
325  UINT BufSize, i;
326  INT iRet;
327  RECT rcClient;
328 
329  ZeroMemory(LineSizes, sizeof(LineSizes));
330 
331  szPrevCurrent = CurrentSize;
332 
333  for (i = 0; i < CLOCKWND_FORMAT_COUNT; i++)
334  {
335  szLines[i][0] = L'\0';
336  BufSize = _countof(szLines[0]);
337 
338  if (ClockWndFormats[i].IsTime)
339  {
342  &LocalTime,
343  ClockWndFormats[i].lpFormat,
344  szLines[i],
345  BufSize);
346  }
347  else
348  {
351  &LocalTime,
353  szLines[i],
354  BufSize);
355  }
356 
357  if (iRet != 0 && i == 0)
358  {
359  /* Set the window text to the time only */
361  }
362  }
363 
365 
366  if (LinesMeasured &&
367  GetClientRect(&rcClient))
368  {
369  SIZE szWnd;
370 
371  szWnd.cx = rcClient.right;
372  szWnd.cy = rcClient.bottom;
373 
375  CurrentSize = szWnd;
376  }
377 
378  if (IsWindowVisible())
379  {
381 
382  if (szPrevCurrent.cx != CurrentSize.cx ||
383  szPrevCurrent.cy != CurrentSize.cy)
384  {
385  /* Ask the parent to resize */
386  NMHDR nmh = {GetParent(), 0, NTNWM_REALIGN};
387  GetParent().SendMessage(WM_NOTIFY, 0, (LPARAM) &nmh);
388  }
389  }
390 
391  int iDateLength = GetDateFormat(LOCALE_USER_DEFAULT,
393  &LocalTime,
394  NULL,
395  NULL,
396  0);
397  if (iDateLength <= 0)
398  {
399  return;
400  }
401 
402  WCHAR* szDate = new WCHAR[iDateLength];
405  &LocalTime,
406  NULL,
407  szDate,
408  iDateLength) > 0)
409  {
411  reinterpret_cast<UINT_PTR>(m_hWnd),
412  szDate);
413  }
414  delete[] szDate;
415 }
const struct @84 ClockWndFormats[]
DWORD dwFormatFlags
Definition: trayclock.cpp:31
WORD GetMinimumSize(IN BOOL Horizontal, IN OUT PSIZE pSize)
Definition: trayclock.cpp:269
DWORD IsHorizontal
Definition: trayclock.cpp:64
#define TRUE
Definition: types.h:120
#define LOCALE_USER_DEFAULT
BOOL IsTime
Definition: trayclock.cpp:30
#define ZeroMemory
Definition: winbase.h:1648
BOOL bShowSeconds
Definition: precomp.h:207
BOOL SetWindowText(LPCTSTR lpszString)
Definition: atlwin.h:1232
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:58
BOOL InvalidateRect(LPCRECT lpRect, BOOL bErase=TRUE)
Definition: atlwin.h:834
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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
CTooltips m_tooltip
Definition: trayclock.cpp:54
VOID UpdateTipText(IN HWND hwndToolOwner, IN UINT uId, IN PCWSTR szText, IN HINSTANCE hinstResourceOwner=NULL)
Definition: rosctrls.h:683
BOOL GetClientRect(LPRECT lpRect) const
Definition: atlwin.h:507
SIZE LineSizes[CLOCKWND_FORMAT_COUNT]
Definition: trayclock.cpp:70
smooth NULL
Definition: ftsmooth.c:416
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
LONG cx
Definition: windef.h:334
LONG_PTR LPARAM
Definition: windef.h:208
#define BufSize
Definition: FsRtlTunnel.c:28
#define NTNWM_REALIGN
Definition: precomp.h:336
SIZE CurrentSize
Definition: trayclock.cpp:68
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define CLOCKWND_FORMAT_COUNT
Definition: trayclock.cpp:40
static const WCHAR L[]
Definition: oid.c:1250
DWORD LinesMeasured
Definition: trayclock.cpp:63
static const WCHAR szDate[]
Definition: http.c:100
HWND m_hWnd
Definition: atlwin.h:268
LPCWSTR lpFormat
Definition: trayclock.cpp:32
#define GetTimeFormat
Definition: winnls.h:1186
WCHAR szLines[CLOCKWND_FORMAT_COUNT][48]
Definition: trayclock.cpp:71
BOOL MeasureLines()
Definition: trayclock.cpp:213
#define GetDateFormat
Definition: winnls.h:1181
#define DATE_LONGDATE
Definition: winnls.h:194
unsigned int UINT
Definition: ndis.h:50
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048
LONG bottom
Definition: windef.h:309
WORD VisibleLines
Definition: trayclock.cpp:69
#define TIME_NOSECONDS
Definition: winnls.h:275
SYSTEMTIME LocalTime
Definition: trayclock.cpp:53
CWindow GetParent() const
Definition: atlwin.h:654
LONG cy
Definition: windef.h:335
#define WM_NOTIFY
Definition: richedit.h:61
BOOL IsWindowVisible() const
Definition: atlwin.h:890

Referenced by Update().

Member Data Documentation

◆ @86

union { ... }

◆ CurrentSize

SIZE CTrayClockWnd::CurrentSize
private

Definition at line 68 of file trayclock.cpp.

Referenced by CTrayClockWnd(), OnPaint(), OnSize(), and UpdateWnd().

◆ dwFlags

DWORD CTrayClockWnd::dwFlags

Definition at line 58 of file trayclock.cpp.

◆ hFont

HFONT CTrayClockWnd::hFont
private

Definition at line 50 of file trayclock.cpp.

Referenced by MeasureLines(), OnPaint(), OnThemeChanged(), and SetFont().

◆ IsHorizontal

DWORD CTrayClockWnd::IsHorizontal

Definition at line 64 of file trayclock.cpp.

Referenced by Initialize(), OnGetMinimumSize(), OnSize(), and UpdateWnd().

◆ IsInitTimerEnabled

DWORD CTrayClockWnd::IsInitTimerEnabled

Definition at line 62 of file trayclock.cpp.

Referenced by CalibrateTimer(), OnDestroy(), OnTaskbarSettingsChanged(), and ResetTime().

◆ IsTimerEnabled

DWORD CTrayClockWnd::IsTimerEnabled

Definition at line 61 of file trayclock.cpp.

Referenced by CalibrateTimer(), OnDestroy(), OnTaskbarSettingsChanged(), and ResetTime().

◆ LineSizes

SIZE CTrayClockWnd::LineSizes[CLOCKWND_FORMAT_COUNT]
private

Definition at line 70 of file trayclock.cpp.

Referenced by CTrayClockWnd(), GetMinimumSize(), MeasureLines(), OnPaint(), and UpdateWnd().

◆ LinesMeasured

DWORD CTrayClockWnd::LinesMeasured

Definition at line 63 of file trayclock.cpp.

Referenced by GetMinimumSize(), OnPaint(), SetFont(), and UpdateWnd().

◆ LineSpacing

DWORD CTrayClockWnd::LineSpacing
private

Definition at line 67 of file trayclock.cpp.

Referenced by GetMinimumSize(), MeasureLines(), and OnPaint().

◆ LocalTime

SYSTEMTIME CTrayClockWnd::LocalTime
private

Definition at line 53 of file trayclock.cpp.

Referenced by CalculateDueTime(), CTrayClockWnd(), Update(), and UpdateWnd().

◆ m_tooltip

CTooltips CTrayClockWnd::m_tooltip
private

Definition at line 54 of file trayclock.cpp.

Referenced by OnCreate(), and UpdateWnd().

◆ rcText

RECT CTrayClockWnd::rcText
private

Definition at line 52 of file trayclock.cpp.

Referenced by CTrayClockWnd().

◆ szLines

WCHAR CTrayClockWnd::szLines[CLOCKWND_FORMAT_COUNT][48]
private

Definition at line 71 of file trayclock.cpp.

Referenced by CTrayClockWnd(), MeasureLines(), OnPaint(), and UpdateWnd().

◆ textColor

COLORREF CTrayClockWnd::textColor
private

Definition at line 51 of file trayclock.cpp.

Referenced by CTrayClockWnd(), OnPaint(), and OnThemeChanged().

◆ VisibleLines

WORD CTrayClockWnd::VisibleLines
private

Definition at line 69 of file trayclock.cpp.

Referenced by OnPaint(), OnSize(), and UpdateWnd().


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