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
// DateFormatSettings.h : Declaration of the CDateFormatSettings

#pragma once

#include "DateFormatSettingsRes.h"
#include "DateFormat.h"

using namespace ATL;

////////////////////////////////////////////////////////////////////////////////
// CDateFormatSettings

class CDateFormatSettings : 
	public CDialogImpl<CDateFormatSettings>
{
public:
	CDateFormatSettings();
	~CDateFormatSettings();

	enum { IDD = IDD_DATEFORMAT };

BEGIN_MSG_MAP(CDateFormatSettings)
	MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
	COMMAND_HANDLER(IDOK, BN_CLICKED, OnClickedOK)
	COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnClickedCancel)
    COMMAND_HANDLER(IDC_LANGUAGE, CBN_SELCHANGE, OnChangeLanguage)
    COMMAND_HANDLER(IDC_CALENDARTYPE, CBN_SELCHANGE, OnChangeCalendarType)
    COMMAND_HANDLER(IDC_DATEFORMAT, CBN_SELCHANGE, OnChangeCustomDateFormat)
    COMMAND_HANDLER(IDC_DATEFORMAT, CBN_EDITCHANGE, OnEditCustomDateFormat)
    COMMAND_RANGE_CODE_HANDLER(IDC_SHORTDATE, IDC_CUSTOMDATE, BN_CLICKED, OnClickedDateFormat)
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);

	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
    LRESULT OnChangeLanguage(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
    LRESULT OnChangeCalendarType(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
    LRESULT OnChangeCustomDateFormat(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
    LRESULT OnEditCustomDateFormat(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
    LRESULT OnClickedDateFormat(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

public:
    DateFormat m_dateFormat;

private:
    BOOL InitControls();
    BOOL InitControlHwnds();
    BOOL InitLanguages();
    BOOL InitCalendars();
    BOOL InitDateFormat(CALTYPE calType);
    BOOL InitCustomDateFormat();

    BOOL SelectLanguage();
    BOOL SelectCurrentCalendar();
    BOOL SelectDateFormat(int nIDButton);
    BOOL SelectCustomDateFormat();

    BOOL EnumKeyboardLayouts();
    BOOL EnumAvailableDateFormats();

    BOOL UpdateCurrentCalendar();
    BOOL UpdateDateFormat(CALTYPE calTypeHint = CAL_DEFAULT);
    BOOL UpdateSampleDate();

    BOOL AddLocale(LCID lcid);

    LCID GetSelectedLcid() const;
    CALID GetSelectedCalendar() const;
    CALTYPE GetSelectedCalendarType() const;
    CString GetSelectedDateFormat() const;
    CString GetSelectedCustomDateFormat() const;

    BOOL CollectCalendarSettings();

    // enum calendars
    static BOOL CALLBACK EnumCalendarInfoProcEx(LPTSTR lpCalendarInfoString, CALID Calendar);

    BOOL EnumCalendarNames(LCID lcid);
    BOOL AddCalendarName(LPCTSTR lpCalendarName, CALID Calendar);

    BOOL EnumCalendarDateFormats(LCID lcid, CALID Calendar);
    BOOL AddCalendarDateFormat(LPCTSTR lpDateFormat, CALID Calendar);

    CALTYPE m_enumCalendarInfo;
    //

private:
    HWND m_hwndLanguage;
    HWND m_hwndCalendar;
    HWND m_hwndFormat;
    HWND m_hwndSample;
};

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

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
Web04 | 2.8.141223.1 | Last Updated 28 Aug 2009
Article Copyright 2009 by Alex Blekhman
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid