/**
* @file XTPCalendarMsgNotifier.h
*
* @copyright
* (c) 1998-2025 Codejock Software, All Rights Reserved.
*
* This source file is the property of Codejock Software and must not be
* redistributed by any means without the explicit written permission of
* Codejock Software.
*
* The use of this source code is governed by the terms and conditions specified
* in the Toolkit Pro license agreement. Codejock Software grants you, as a
* single software developer, the limited right to use this software on one
* computer only.
*
* Contact Information:
* support@codejock.com
* http://www.codejock.com
*
*/
#if !defined(_XTP_CALENDARMSGNOTIFIER_H__)
# define _XTP_CALENDARMSGNOTIFIER_H__
# if _MSC_VER > 1000
# pragma once
# endif // _MSC_VER > 1000
# include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h"
/////////////////////////////////////////////////////////////////////////////
// CXTPCalendarMsgNotifier window
/**
* @brief
* Define windows message sent by CXTPCalendarMsgNotifier when the
* current timezone is changed.
*/
extern UINT XTP_WM_TIME_ZONE_CHANGED;
class CXTPCalendarMsgNotifier;
/**
* @brief
* This global function is used to get a library static common top-level
* window object to catch windows messages, which the system sends to
* top-level windows (like WM_TIMECHANGE, WM_SYSCOLORCHANGE).
*
* @details
* Using CXTPCalendarMsgNotifier you can advise your non-top-level
* (child) windows to receive these messages.
*
* @return A pointer to CXTPCalendarMsgNotifier object.
*/
_XTP_EXT_CLASS CXTPCalendarMsgNotifier* AFX_CDECL XTPCalendarMsgNotifier();
/**
* @brief
* This class is used to catch windows messages, which the system sends to
* top-level windows, and to send them to subscribers windows.
* The following messages are supported:
* WM_TIMECHANGE
* WM_SYSCOLORCHANGE
*
* @see WM_TIMECHANGE
* @see WM_SYSCOLORCHANGE
*/
class _XTP_EXT_CLASS CXTPCalendarMsgNotifier : public CWnd
{
public:
/**
* @brief
* Default object constructor.
*/
CXTPCalendarMsgNotifier();
/**
* @brief
* Default object destructor.
*/
virtual ~CXTPCalendarMsgNotifier();
/**
* @brief
* This enum contains additional parameter value(s).
*/
enum EnumParams
{
msgAll = 0 /**< This value means all messages or any message. */
};
/**
* @brief
* Advise CWnd object to receive specified top-level windows message(s).
*
* @param pWnd [in] A pointer to client window.
* @param uWndMsg [in] Windows message ID.
*
* @details
* If uWndMsg is msgAll than all supported messages
* will be sent to client window.
*
* @see Unadvise
*/
void Advise(CWnd* pWnd, UINT uWndMsg = msgAll);
/**
* @brief
* Unadvise CWnd object from receive specified top-level windows message(s).
*
* @param pWnd [in] A pointer to client window.
* @param uWndMsg [in] Windows message ID.
*
* @details
* If uWndMsg is msgAll unadvised from all supported
* messages.
*
* @see Advise
*/
void Unadvise(CWnd* pWnd, UINT uWndMsg = msgAll);
protected:
friend _XTP_EXT_CLASS CXTPCalendarMsgNotifier* AFX_CDECL XTPCalendarMsgNotifier();
/**
* @brief
* This method is used to Create a CWnd object.
*
* @details
* A simple top-level window will be created.
*
* @return TRUE is successfull, FALSE otherwise.
*/
BOOL CreateWnd();
DECLARE_MESSAGE_MAP()
afx_msg void OnTimeChange();
afx_msg void OnSysColorChange();
afx_msg void OnTimer(UINT_PTR uTimerID);
private:
struct CLIENT_INFO
{
CWnd* m_pWnd;
UINT m_uWndMsg;
};
class CClientsArray : public CArray
{
public:
CClientsArray();
virtual ~CClientsArray();
int FindExact(CWnd* pWnd, UINT uWndMsg = CXTPCalendarMsgNotifier::msgAll) const;
int FindClient(CWnd* pWnd, UINT uWndMsg = CXTPCalendarMsgNotifier::msgAll) const;
void Remove(CWnd* pWnd, UINT uWndMsg = CXTPCalendarMsgNotifier::msgAll);
};
CClientsArray m_arClients;
SYSTEMTIME m_timeLastDate;
TIME_ZONE_INFORMATION m_tziLast;
void SendToClients(UINT uWndMsg, WPARAM wParam, LPARAM lParam);
void _ProcessTimeZone();
BOOL IsTimeZoneEqual(const TIME_ZONE_INFORMATION& rTzi1,
const TIME_ZONE_INFORMATION& rTzi2) const;
};
/////////////////////////////////////////////////////////////////////////////
# include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h"
#endif // !defined(_XTP_CALENDARMSGNOTIFIER_H__)