Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Shell Extensibility - Explorer Desk Band, Tray Notification Icon et al.

, 28 Aug 2009 CPOL
A simple Calendar utility that demonstrates basic Shell extensibility techniques: desk band, tray notification icon, locales.
Calendar.zip
Calendar
CalendarDeskBand
CalendarDeskBand.def
CalendarDeskBand.rgs
CalendarDeskBandApp.rgs
CalendarSysTray
Res
01.ico
02.ico
03.ico
04.ico
05.ico
06.ico
07.ico
08.ico
09.ico
10.ico
11.ico
12.ico
13.ico
14.ico
15.ico
16.ico
17.ico
18.ico
19.ico
20.ico
21.ico
22.ico
23.ico
24.ico
25.ico
26.ico
27.ico
28.ico
29.ico
30.ico
31.ico
Blank-16x16-16.ico
Calendar.ico
Common
Win32
Release
Calendar.exe
x64
Release
Calendar.exe
#pragma once

using namespace ATL;

////////////////////////////////////////////////////////////////////////////////
// CCalendarWindow 
class DateFormat;
class CVisualStyle;

class CCalendarWindow :
    public CWindowImpl<CCalendarWindow>
{
public:
    CCalendarWindow();
    ~CCalendarWindow();

    BOOL Create(
        HWND hwndParent,
        LPUNKNOWN pDeskBand,
        LPUNKNOWN pInputObjectSite,
        const DateFormat* pDateFormat);

    POINTL CalcMinimalSize() const;
    POINTL CalcIdealSize() const;
    BOOL HasFocus() const;
    void UpdateCaption();

BEGIN_MSG_MAP(CCalendarWindow)
    MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
    MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
    MESSAGE_HANDLER(WM_PAINT, OnPaint)
    MESSAGE_HANDLER(WM_SETFOCUS, OnFocus)
    MESSAGE_HANDLER(WM_KILLFOCUS, OnFocus)
    MESSAGE_HANDLER(WM_POWERBROADCAST, OnPowerBroadcast)
    MESSAGE_HANDLER(WM_TIMER, OnTimer)
    MESSAGE_HANDLER(WM_TIMECHANGE, OnTimeChange)
    MESSAGE_HANDLER(WM_THEMECHANGED, OnThemeChanged)
END_MSG_MAP()

// Handler prototypes:
//  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
//  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
//  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

private:
    LRESULT OnFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
    LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
    LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
    LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
    LRESULT OnPowerBroadcast(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
    LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
    LRESULT OnTimeChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
    LRESULT OnThemeChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

    void Paint(HDC hdc, const RECT& rcPaint) const;
    UINT_PTR SetUpdateTimer();

private:
    IUnknown* m_pDeskBand;
    BOOL m_fHasFocus;
    CComQIPtr<IInputObjectSite> m_spInputObjectSite;

    CAutoPtr<CVisualStyle> m_ptrVisualStyle;

    const DateFormat* m_pDateFormat;
    SYSTEMTIME m_stLocalTime;
    mutable CString m_sDateString;
};

////////////////////////////////////////////////////////////////////////////////

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Alex Blekhman
Software Developer
Australia Australia
More than ten years of C++ native development, and counting.
 
Smile | :)

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141220.1 | Last Updated 28 Aug 2009
Article Copyright 2009 by Alex Blekhman
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid