16#define MONTHCAL_HEADERBG COLOR_INACTIVECAPTION
17#define MONTHCAL_HEADERFG COLOR_INACTIVECAPTIONTEXT
18#define MONTHCAL_CTRLBG COLOR_WINDOW
19#define MONTHCAL_CTRLFG COLOR_WINDOWTEXT
20#define MONTHCAL_SELBG COLOR_ACTIVECAPTION
21#define MONTHCAL_SELFG COLOR_CAPTIONTEXT
22#define MONTHCAL_DISABLED_HEADERBG COLOR_INACTIVECAPTION
23#define MONTHCAL_DISABLED_HEADERFG COLOR_INACTIVECAPTIONTEXT
24#define MONTHCAL_DISABLED_CTRLBG COLOR_WINDOW
25#define MONTHCAL_DISABLED_CTRLFG COLOR_WINDOWTEXT
26#define MONTHCAL_DISABLED_SELBG COLOR_INACTIVECAPTION
27#define MONTHCAL_DISABLED_SELFG COLOR_INACTIVECAPTIONTEXT
62 if (infoPtr->hNotify !=
NULL)
88 (Year <= 1752) ? !(Year % 4) :
90 !(Year % 4) && ((Year % 100) || !(Year % 400));
97 const BYTE MonthDays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
100 return MonthDays[Month - 1] +
LeapYear(Year);
104 if ((Year == 1752) && (Month == 9))
108 return MonthDays[Month - 1];
116 return (Day - DayOfWeek + 5) / 7;
125 const BYTE DayOfWeek[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
129 Ret = (Year + (Year / 4) - (Year / 100) + (Year / 400) + DayOfWeek[Month - 1] + Day + 6) % 7;
131 return (7 + Ret - infoPtr->FirstDayOfWeek) % 7;
137 WCHAR szBuf[2] = {0};
143 sizeof(szBuf) /
sizeof(szBuf[0])) != 0)
156 if (Month < 1 || Month > 12 ||
159 Year < 1899 || Year > 9999)
171 WORD DayOfWeek, MonthLength,
d = 0;
175 NewCellSize.
cx = infoPtr->ClientSize.cx / 7;
176 NewCellSize.
cy = infoPtr->ClientSize.cy / 7;
178 if (infoPtr->CellSize.cx != NewCellSize.
cx ||
179 infoPtr->CellSize.cy != NewCellSize.
cy)
181 infoPtr->CellSize = NewCellSize;
182 RepaintHeader =
TRUE;
187 sizeof(infoPtr->Days));
197 pDay = &infoPtr->Days[0][DayOfWeek];
198 pDayEnd = pDay + MonthLength;
199 while (pDay != pDayEnd)
201 *(pDay++) = (
BYTE)++
d;
216 rcClient.
top = infoPtr->CellSize.cy;
217 rcClient.
right = infoPtr->ClientSize.cx;
218 rcClient.
bottom = infoPtr->ClientSize.cy;
238 uElapse += (59 - (
UINT)LocalTime.
wMinute) * 60 * 1000;
239 uElapse += (23 - (
UINT)LocalTime.
wHour) * 60 * 60 * 1000;
247 infoPtr->DayTimerSet =
TRUE;
269 for (
i = 0;
i < 7;
i++)
273 ((
i + infoPtr->FirstDayOfWeek) % 7),
275 sizeof(szBuf) /
sizeof(szBuf[0])) != 0)
277 infoPtr->Week[
i] = szBuf[0];
300 rcCell->left = DayOfWeek * infoPtr->CellSize.cx;
302 DayOfWeek) + 1) * infoPtr->CellSize.cy;
303 rcCell->right = rcCell->left + infoPtr->CellSize.cx;
304 rcCell->bottom = rcCell->top + infoPtr->CellSize.cy;
315 infoPtr->Changed =
TRUE;
318 if (infoPtr->DayTimerSet)
322 infoPtr->DayTimerSet =
FALSE;
349 if (infoPtr->Month != sc.
NewMonth ||
363 else if (infoPtr->Day != sc.
NewDay)
415 infoPtr->Changed =
FALSE;
420 if (infoPtr->DayTimerSet)
424 infoPtr->DayTimerSet =
FALSE;
463#if MONTHCAL_CTRLBG != MONTHCAL_DISABLED_CTRLBG
464 if (!infoPtr->Enabled)
477 for (
y = prcUpdate->top / infoPtr->CellSize.cy;
478 y <= prcUpdate->
bottom / infoPtr->CellSize.cy &&
y < 7;
481 rcCell.
top =
y * infoPtr->CellSize.cy;
482 rcCell.
bottom = rcCell.
top + infoPtr->CellSize.cy;
489 rcHeader.
left = prcUpdate->left;
490 rcHeader.
top = rcCell.
top;
491 rcHeader.
right = prcUpdate->right;
501 for (
x = prcUpdate->left / infoPtr->CellSize.cx;
502 x <= prcUpdate->
right / infoPtr->CellSize.cx &&
x < 7;
505 rcCell.
left =
x * infoPtr->CellSize.cx;
506 rcCell.
right = rcCell.
left + infoPtr->CellSize.cx;
527 for (
x = prcUpdate->left / infoPtr->CellSize.cx;
528 x <= prcUpdate->
right / infoPtr->CellSize.cx &&
x < 7;
531 UINT Day = infoPtr->Days[
y - 1][
x];
533 rcCell.
left =
x * infoPtr->CellSize.cx;
534 rcCell.
right = rcCell.
left + infoPtr->CellSize.cx;
537 if (Day != 0 && Day < 100)
553 RECT rcHighlight = { 0, 0, 0, 0 };
555 rcText.
left = rcCell.
left + (infoPtr->CellSize.cx / 2) - (TextSize.
cx / 2);
556 rcText.
top = rcCell.
top + (infoPtr->CellSize.cy / 2) - (TextSize.
cy / 2);
560 if (Day == infoPtr->Day)
564 TextSel.
cx = (infoPtr->CellSize.cx * 2) / 3;
565 TextSel.
cy = (infoPtr->CellSize.cy * 3) / 4;
572 rcHighlight.
left = rcCell.
left + (infoPtr->CellSize.cx / 2) - (TextSel.
cx / 2);
574 rcHighlight.
top = rcCell.
top + (infoPtr->CellSize.cy / 2) - (TextSel.
cy / 2);
583 infoPtr->hbSelection))
585 goto FailNoHighlight;
605 if (Day == infoPtr->Day && crOldText !=
CLR_INVALID)
607 if (infoPtr->HasFocus && infoPtr->Enabled && !(infoPtr->UIState & UISF_HIDEFOCUS))
647 HFONT hOldFont = infoPtr->hFont;
648 infoPtr->hFont =
hFont;
667 if (infoPtr->CellSize.cx != 0 && infoPtr->CellSize.cy != 0 &&
670 x /= infoPtr->CellSize.cx;
671 y /= infoPtr->CellSize.cy;
673 if (
x < 7 &&
y != 0 &&
y < 7)
675 Ret = (
WORD)infoPtr->Days[
y - 1][
x];
696 goto HandleDefaultMessage;
701#if MONTHCAL_CTRLBG != MONTHCAL_DISABLED_CTRLBG
756 if (SelDay != 0 && SelDay != infoPtr->
Day)
785 if (infoPtr->
Day > 7)
787 NewDay = infoPtr->
Day - 7;
797 NewDay = infoPtr->
Day + 7;
804 if (infoPtr->
Day > 1)
806 NewDay = infoPtr->
Day - 1;
816 NewDay = infoPtr->
Day + 1;
831 goto HandleDefaultMessage;
874 case WM_UPDATEUISTATE:
895 if (infoPtr->
UIState != OldUIState)
905 WORD Day, Month, Year, DaysCount;
913 if (Month == (
WORD)-1)
914 Month = infoPtr->
Month;
915 if (Year == (
WORD)-1)
916 Year = infoPtr->
Year;
927 if (Day != infoPtr->
Day ||
928 Month != infoPtr->
Month ||
929 Year != infoPtr->
Year)
946 lpSystemTime->
wDay = infoPtr->
Day;
1027 case WM_STYLECHANGED:
1031 unsigned int OldEnabled = infoPtr->
Enabled;
1034 if (OldEnabled != infoPtr->
Enabled)
1047 if (infoPtr ==
NULL)
1060 infoPtr->hSelf =
hwnd;
1084HandleDefaultMessage:
static WORD MonthCalDayOfWeek(IN PMONTHCALWND infoPtr, IN WORD Day, IN WORD Month, IN WORD Year)
static VOID MonthCalUpdate(IN PMONTHCALWND infoPtr)
#define MONTHCAL_DISABLED_HEADERFG
static WORD MonthCalPtToDay(IN PMONTHCALWND infoPtr, IN INT x, IN INT y)
BOOL RegisterMonthCalControl(IN HINSTANCE hInstance)
#define MONTHCAL_DISABLED_HEADERBG
static BOOL MonthCalValidDate(IN WORD Day, IN WORD Month, IN WORD Year)
static VOID MonthCalChange(IN PMONTHCALWND infoPtr)
static WORD MonthCalWeekInMonth(IN WORD Day, IN WORD DayOfWeek)
struct _MONTHCALWND * PMONTHCALWND
#define MONTHCAL_DISABLED_SELFG
static VOID MonthCalSetLocalTime(IN PMONTHCALWND infoPtr, OUT SYSTEMTIME *Time)
static VOID MonthCalRepaintDay(IN PMONTHCALWND infoPtr, IN WORD Day)
static WORD LeapYear(IN WORD Year)
static LRESULT CALLBACK MonthCalWndProc(IN HWND hwnd, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
#define MONTHCAL_DISABLED_CTRLFG
struct _MONTHCALWND MONTHCALWND
static VOID MonthCalReload(IN PMONTHCALWND infoPtr)
static WORD MonthCalFirstDayOfWeek(VOID)
static const WCHAR szMonthCalWndClass[]
static BOOL MonthCalGetDayRect(IN PMONTHCALWND infoPtr, IN WORD Day, OUT RECT *rcCell)
VOID UnregisterMonthCalControl(IN HINSTANCE hInstance)
#define MONTHCAL_HEADERFG
static BOOL MonthCalSetDate(IN PMONTHCALWND infoPtr, IN WORD Day, IN WORD Month, IN WORD Year)
#define MONTHCAL_HEADERBG
#define MONTHCAL_DISABLED_SELBG
static HFONT MonthCalChangeFont(IN PMONTHCALWND infoPtr, IN HFONT hFont, IN BOOL Redraw)
static WORD MonthCalMonthLength(IN WORD Month, IN WORD Year)
#define MONTHCAL_DISABLED_CTRLBG
static VOID MonthCalPaint(IN PMONTHCALWND infoPtr, IN HDC hDC, IN LPRECT prcUpdate)
static LRESULT MonthCalNotifyControlParent(IN PMONTHCALWND infoPtr, IN UINT code, IN OUT PVOID data)
static VOID MonthCalSetupDayTimer(IN PMONTHCALWND infoPtr)
#define HeapFree(x, y, z)
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
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
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static PLARGE_INTEGER Time
#define LOCALE_USER_DEFAULT
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
struct _SYSTEMTIME * LPSYSTEMTIME
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
#define LOCALE_SABBREVDAYNAME1
#define LOCALE_IFIRSTDAYOFWEEK
DWORD WINAPI GetSysColor(_In_ int)
#define GetWindowLongPtrW
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
struct tagSTYLESTRUCT * LPSTYLESTRUCT
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
struct tagNMHDR * LPNMHDR
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define SetWindowLongPtrW
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI GetUpdateRect(_In_ HWND, _Out_opt_ LPRECT, _In_ BOOL)
struct tagCREATESTRUCTW * LPCREATESTRUCTW
int WINAPI GetSystemMetrics(_In_ int)
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)