ReactOS  0.4.14-dev-114-gc8cbd56
monthcal.c File Reference
#include "timedate.h"
#include <windowsx.h>
Include dependency graph for monthcal.c:

Go to the source code of this file.

Classes

struct  _MONTHCALWND
 

Macros

#define MONTHCAL_HEADERBG   COLOR_INACTIVECAPTION
 
#define MONTHCAL_HEADERFG   COLOR_INACTIVECAPTIONTEXT
 
#define MONTHCAL_CTRLBG   COLOR_WINDOW
 
#define MONTHCAL_CTRLFG   COLOR_WINDOWTEXT
 
#define MONTHCAL_SELBG   COLOR_ACTIVECAPTION
 
#define MONTHCAL_SELFG   COLOR_CAPTIONTEXT
 
#define MONTHCAL_DISABLED_HEADERBG   COLOR_INACTIVECAPTION
 
#define MONTHCAL_DISABLED_HEADERFG   COLOR_INACTIVECAPTIONTEXT
 
#define MONTHCAL_DISABLED_CTRLBG   COLOR_WINDOW
 
#define MONTHCAL_DISABLED_CTRLFG   COLOR_WINDOWTEXT
 
#define MONTHCAL_DISABLED_SELBG   COLOR_INACTIVECAPTION
 
#define MONTHCAL_DISABLED_SELFG   COLOR_INACTIVECAPTIONTEXT
 
#define ID_DAYTIMER   1
 

Typedefs

typedef struct _MONTHCALWND MONTHCALWND
 
typedef struct _MONTHCALWNDPMONTHCALWND
 

Functions

static LRESULT MonthCalNotifyControlParent (IN PMONTHCALWND infoPtr, IN UINT code, IN OUT PVOID data)
 
static WORD LeapYear (IN WORD Year)
 
static WORD MonthCalMonthLength (IN WORD Month, IN WORD Year)
 
static WORD MonthCalWeekInMonth (IN WORD Day, IN WORD DayOfWeek)
 
static WORD MonthCalDayOfWeek (IN PMONTHCALWND infoPtr, IN WORD Day, IN WORD Month, IN WORD Year)
 
static WORD MonthCalFirstDayOfWeek (VOID)
 
static BOOL MonthCalValidDate (IN WORD Day, IN WORD Month, IN WORD Year)
 
static VOID MonthCalUpdate (IN PMONTHCALWND infoPtr)
 
static VOID MonthCalSetupDayTimer (IN PMONTHCALWND infoPtr)
 
static VOID MonthCalReload (IN PMONTHCALWND infoPtr)
 
static BOOL MonthCalGetDayRect (IN PMONTHCALWND infoPtr, IN WORD Day, OUT RECT *rcCell)
 
static VOID MonthCalChange (IN PMONTHCALWND infoPtr)
 
static BOOL MonthCalSetDate (IN PMONTHCALWND infoPtr, IN WORD Day, IN WORD Month, IN WORD Year)
 
static VOID MonthCalSetLocalTime (IN PMONTHCALWND infoPtr, OUT SYSTEMTIME *Time)
 
static VOID MonthCalRepaintDay (IN PMONTHCALWND infoPtr, IN WORD Day)
 
static VOID MonthCalPaint (IN PMONTHCALWND infoPtr, IN HDC hDC, IN LPRECT prcUpdate)
 
static HFONT MonthCalChangeFont (IN PMONTHCALWND infoPtr, IN HFONT hFont, IN BOOL Redraw)
 
static WORD MonthCalPtToDay (IN PMONTHCALWND infoPtr, IN INT x, IN INT y)
 
static LRESULT CALLBACK MonthCalWndProc (IN HWND hwnd, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
BOOL RegisterMonthCalControl (IN HINSTANCE hInstance)
 
VOID UnregisterMonthCalControl (IN HINSTANCE hInstance)
 

Variables

static const WCHAR szMonthCalWndClass [] = L"MonthCalWnd"
 

Macro Definition Documentation

◆ ID_DAYTIMER

#define ID_DAYTIMER   1

Definition at line 29 of file monthcal.c.

◆ MONTHCAL_CTRLBG

#define MONTHCAL_CTRLBG   COLOR_WINDOW

Definition at line 18 of file monthcal.c.

◆ MONTHCAL_CTRLFG

#define MONTHCAL_CTRLFG   COLOR_WINDOWTEXT

Definition at line 19 of file monthcal.c.

◆ MONTHCAL_DISABLED_CTRLBG

#define MONTHCAL_DISABLED_CTRLBG   COLOR_WINDOW

Definition at line 24 of file monthcal.c.

◆ MONTHCAL_DISABLED_CTRLFG

#define MONTHCAL_DISABLED_CTRLFG   COLOR_WINDOWTEXT

Definition at line 25 of file monthcal.c.

◆ MONTHCAL_DISABLED_HEADERBG

#define MONTHCAL_DISABLED_HEADERBG   COLOR_INACTIVECAPTION

Definition at line 22 of file monthcal.c.

◆ MONTHCAL_DISABLED_HEADERFG

#define MONTHCAL_DISABLED_HEADERFG   COLOR_INACTIVECAPTIONTEXT

Definition at line 23 of file monthcal.c.

◆ MONTHCAL_DISABLED_SELBG

#define MONTHCAL_DISABLED_SELBG   COLOR_INACTIVECAPTION

Definition at line 26 of file monthcal.c.

◆ MONTHCAL_DISABLED_SELFG

#define MONTHCAL_DISABLED_SELFG   COLOR_INACTIVECAPTIONTEXT

Definition at line 27 of file monthcal.c.

◆ MONTHCAL_HEADERBG

#define MONTHCAL_HEADERBG   COLOR_INACTIVECAPTION

Definition at line 16 of file monthcal.c.

◆ MONTHCAL_HEADERFG

#define MONTHCAL_HEADERFG   COLOR_INACTIVECAPTIONTEXT

Definition at line 17 of file monthcal.c.

◆ MONTHCAL_SELBG

#define MONTHCAL_SELBG   COLOR_ACTIVECAPTION

Definition at line 20 of file monthcal.c.

◆ MONTHCAL_SELFG

#define MONTHCAL_SELFG   COLOR_CAPTIONTEXT

Definition at line 21 of file monthcal.c.

Typedef Documentation

◆ MONTHCALWND

◆ PMONTHCALWND

Function Documentation

◆ LeapYear()

static WORD LeapYear ( IN WORD  Year)
static

Definition at line 84 of file monthcal.c.

85 {
86  return
87 #ifdef WITH_1752
88  (Year <= 1752) ? !(Year % 4) :
89 #endif
90  !(Year % 4) && ((Year % 100) || !(Year % 400));
91 }

Referenced by MonthCalMonthLength(), and RtlTimeToTimeFields().

◆ MonthCalChange()

static VOID MonthCalChange ( IN PMONTHCALWND  infoPtr)
static

Definition at line 318 of file monthcal.c.

319 {
320  infoPtr->Changed = TRUE;
321 
322  /* Kill the day timer */
323  if (infoPtr->DayTimerSet)
324  {
325  KillTimer(infoPtr->hSelf,
326  ID_DAYTIMER);
327  infoPtr->DayTimerSet = FALSE;
328  }
329 }
#define TRUE
Definition: types.h:120
#define ID_DAYTIMER
Definition: monthcal.c:29
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by MonthCalSetDate().

◆ MonthCalChangeFont()

static HFONT MonthCalChangeFont ( IN PMONTHCALWND  infoPtr,
IN HFONT  hFont,
IN BOOL  Redraw 
)
static

Definition at line 648 of file monthcal.c.

651 {
652  HFONT hOldFont = infoPtr->hFont;
653  infoPtr->hFont = hFont;
654 
655  if (Redraw)
656  {
657  InvalidateRect(infoPtr->hSelf,
658  NULL,
659  TRUE);
660  }
661 
662  return hOldFont;
663 }
#define TRUE
Definition: types.h:120
HFONT hFont
Definition: main.c:53
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)

Referenced by MonthCalWndProc().

◆ MonthCalDayOfWeek()

static WORD MonthCalDayOfWeek ( IN PMONTHCALWND  infoPtr,
IN WORD  Day,
IN WORD  Month,
IN WORD  Year 
)
static

Definition at line 120 of file monthcal.c.

124 {
125  const BYTE DayOfWeek[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
126  WORD Ret;
127 
128  Year -= (Month < 3);
129  Ret = (Year + (Year / 4) - (Year / 100) + (Year / 400) + DayOfWeek[Month - 1] + Day + 6) % 7;
130 
131  return (7 + Ret - infoPtr->FirstDayOfWeek) % 7;
132 }
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned char BYTE
Definition: mem.h:68

Referenced by MonthCalGetDayRect(), and MonthCalUpdate().

◆ MonthCalFirstDayOfWeek()

static WORD MonthCalFirstDayOfWeek ( VOID  )
static

Definition at line 135 of file monthcal.c.

136 {
137  WCHAR szBuf[2] = {0};
138  WORD Ret = 0;
139 
142  szBuf,
143  sizeof(szBuf) / sizeof(szBuf[0])) != 0)
144  {
145  Ret = (WORD)(szBuf[0] - TEXT('0'));
146  }
147 
148  return Ret;
149 }
#define LOCALE_USER_DEFAULT
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned short WORD
Definition: ntddk_ex.h:93
#define LOCALE_IFIRSTDAYOFWEEK
Definition: winnls.h:75
#define TEXT(s)
Definition: k32.h:26

Referenced by MonthCalReload().

◆ MonthCalGetDayRect()

static BOOL MonthCalGetDayRect ( IN PMONTHCALWND  infoPtr,
IN WORD  Day,
OUT RECT rcCell 
)
static

Definition at line 291 of file monthcal.c.

294 {
295  if (Day >= 1 && Day <= MonthCalMonthLength(infoPtr->Month,
296  infoPtr->Year))
297  {
298  WORD DayOfWeek;
299 
300  DayOfWeek = MonthCalDayOfWeek(infoPtr,
301  Day,
302  infoPtr->Month,
303  infoPtr->Year);
304 
305  rcCell->left = DayOfWeek * infoPtr->CellSize.cx;
306  rcCell->top = (MonthCalWeekInMonth(Day,
307  DayOfWeek) + 1) * infoPtr->CellSize.cy;
308  rcCell->right = rcCell->left + infoPtr->CellSize.cx;
309  rcCell->bottom = rcCell->top + infoPtr->CellSize.cy;
310 
311  return TRUE;
312  }
313 
314  return FALSE;
315 }
#define TRUE
Definition: types.h:120
static WORD MonthCalWeekInMonth(IN WORD Day, IN WORD DayOfWeek)
Definition: monthcal.c:113
unsigned short WORD
Definition: ntddk_ex.h:93
static WORD MonthCalDayOfWeek(IN PMONTHCALWND infoPtr, IN WORD Day, IN WORD Month, IN WORD Year)
Definition: monthcal.c:120
static WORD MonthCalMonthLength(IN WORD Month, IN WORD Year)
Definition: monthcal.c:94

Referenced by MonthCalRepaintDay(), and MonthCalSetDate().

◆ MonthCalMonthLength()

static WORD MonthCalMonthLength ( IN WORD  Month,
IN WORD  Year 
)
static

Definition at line 94 of file monthcal.c.

96 {
97  const BYTE MonthDays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
98 
99  if(Month == 2)
100  return MonthDays[Month - 1] + LeapYear(Year);
101  else
102  {
103 #ifdef WITH_1752
104  if ((Year == 1752) && (Month == 9))
105  return 19; // Special case: September 1752 has no 3rd-13th
106  else
107 #endif
108  return MonthDays[Month - 1];
109  }
110 }
static WORD LeapYear(IN WORD Year)
Definition: monthcal.c:84
unsigned char BYTE
Definition: mem.h:68

Referenced by MonthCalGetDayRect(), MonthCalUpdate(), MonthCalValidDate(), and MonthCalWndProc().

◆ MonthCalNotifyControlParent()

static LRESULT MonthCalNotifyControlParent ( IN PMONTHCALWND  infoPtr,
IN UINT  code,
IN OUT PVOID  data 
)
static

Definition at line 56 of file monthcal.c.

59 {
60  LRESULT Ret = 0;
61 
62  if (infoPtr->hNotify != NULL)
63  {
64  LPNMHDR pnmh = (LPNMHDR)data;
65 
66  pnmh->hwndFrom = infoPtr->hSelf;
67  pnmh->idFrom = GetWindowLongPtrW(infoPtr->hSelf,
68  GWLP_ID);
69  pnmh->code = code;
70 
71  Ret = SendMessageW(infoPtr->hNotify,
72  WM_NOTIFY,
73  (WPARAM)pnmh->idFrom,
74  (LPARAM)pnmh);
75  }
76 
77  return Ret;
78 }
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWindowLongPtrW
Definition: winuser.h:4730
struct tagNMHDR * LPNMHDR
UINT code
Definition: winuser.h:3133
UINT_PTR idFrom
Definition: winuser.h:3132
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HWND hwndFrom
Definition: winuser.h:3131
int code
Definition: i386-dis.c:3591
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LONG_PTR LRESULT
Definition: windef.h:209
#define GWLP_ID
Definition: winuser.h:854
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by MonthCalSetDate(), and MonthCalSetLocalTime().

◆ MonthCalPaint()

static VOID MonthCalPaint ( IN PMONTHCALWND  infoPtr,
IN HDC  hDC,
IN LPRECT  prcUpdate 
)
static

Definition at line 458 of file monthcal.c.

461 {
462  LONG x, y;
463  RECT rcCell;
464  COLORREF crOldText, crOldCtrlText = CLR_INVALID;
465  HFONT hOldFont;
466  INT iOldBkMode;
467 
468 #if MONTHCAL_CTRLBG != MONTHCAL_DISABLED_CTRLBG
469  if (!infoPtr->Enabled)
470  {
471  FillRect(hDC,
472  prcUpdate,
474  }
475 #endif
476 
477  iOldBkMode = SetBkMode(hDC,
478  TRANSPARENT);
479  hOldFont = (HFONT)SelectObject(hDC,
480  infoPtr->hFont);
481 
482  for (y = prcUpdate->top / infoPtr->CellSize.cy;
483  y <= prcUpdate->bottom / infoPtr->CellSize.cy && y < 7;
484  y++)
485  {
486  rcCell.top = y * infoPtr->CellSize.cy;
487  rcCell.bottom = rcCell.top + infoPtr->CellSize.cy;
488 
489  if (y == 0)
490  {
491  RECT rcHeader;
492 
493  /* Paint the header */
494  rcHeader.left = prcUpdate->left;
495  rcHeader.top = rcCell.top;
496  rcHeader.right = prcUpdate->right;
497  rcHeader.bottom = rcCell.bottom;
498 
499  FillRect(hDC,
500  &rcHeader,
501  infoPtr->hbHeader);
502 
503  crOldText = SetTextColor(hDC,
505 
506  for (x = prcUpdate->left / infoPtr->CellSize.cx;
507  x <= prcUpdate->right / infoPtr->CellSize.cx && x < 7;
508  x++)
509  {
510  rcCell.left = x * infoPtr->CellSize.cx;
511  rcCell.right = rcCell.left + infoPtr->CellSize.cx;
512 
513  /* Write the first letter of each weekday */
514  DrawTextW(hDC,
515  &infoPtr->Week[x],
516  1,
517  &rcCell,
519  }
520 
522  crOldText);
523  }
524  else
525  {
526  if (crOldCtrlText == CLR_INVALID)
527  {
528  crOldCtrlText = SetTextColor(hDC,
530  }
531 
532  for (x = prcUpdate->left / infoPtr->CellSize.cx;
533  x <= prcUpdate->right / infoPtr->CellSize.cx && x < 7;
534  x++)
535  {
536  UINT Day = infoPtr->Days[y - 1][x];
537 
538  rcCell.left = x * infoPtr->CellSize.cx;
539  rcCell.right = rcCell.left + infoPtr->CellSize.cx;
540 
541  /* Write the day number */
542  if (Day != 0 && Day < 100)
543  {
544  WCHAR szDay[3];
545  INT szDayLen;
546  RECT rcText;
547  SIZE TextSize;
548 
549  szDayLen = swprintf(szDay,
550  L"%lu",
551  Day);
552 
554  szDay,
555  szDayLen,
556  &TextSize))
557  {
558  RECT rcHighlight = { 0, 0, 0, 0 };
559 
560  rcText.left = rcCell.left + (infoPtr->CellSize.cx / 2) - (TextSize.cx / 2);
561  rcText.top = rcCell.top + (infoPtr->CellSize.cy / 2) - (TextSize.cy / 2);
562  rcText.right = rcText.left + TextSize.cx;
563  rcText.bottom = rcText.top + TextSize.cy;
564 
565  if (Day == infoPtr->Day)
566  {
567  SIZE TextSel;
568 
569  TextSel.cx = (infoPtr->CellSize.cx * 2) / 3;
570  TextSel.cy = (infoPtr->CellSize.cy * 3) / 4;
571 
572  if (TextSel.cx < rcText.right - rcText.left)
573  TextSel.cx = rcText.right - rcText.left;
574  if (TextSel.cy < rcText.bottom - rcText.top)
575  TextSel.cy = rcText.bottom - rcText.top;
576 
577  rcHighlight.left = rcCell.left + (infoPtr->CellSize.cx / 2) - (TextSel.cx / 2);
578  rcHighlight.right = rcHighlight.left + TextSel.cx;
579  rcHighlight.top = rcCell.top + (infoPtr->CellSize.cy / 2) - (TextSel.cy / 2);
580  rcHighlight.bottom = rcHighlight.top + TextSel.cy;
581 
582  InflateRect(&rcHighlight,
583  GetSystemMetrics(SM_CXFOCUSBORDER),
584  GetSystemMetrics(SM_CYFOCUSBORDER));
585 
586  if (!FillRect(hDC,
587  &rcHighlight,
588  infoPtr->hbSelection))
589  {
590  goto FailNoHighlight;
591  }
592 
593  /* Highlight the selected day */
594  crOldText = SetTextColor(hDC,
595  GetSysColor(infoPtr->Enabled ? MONTHCAL_SELFG : MONTHCAL_DISABLED_SELFG));
596  }
597  else
598  {
599 FailNoHighlight:
600  /* Don't change the text color, we're not highlighting it... */
601  crOldText = CLR_INVALID;
602  }
603 
604  TextOutW(hDC,
605  rcText.left,
606  rcText.top,
607  szDay,
608  szDayLen);
609 
610  if (Day == infoPtr->Day && crOldText != CLR_INVALID)
611  {
612  if (infoPtr->HasFocus && infoPtr->Enabled && !(infoPtr->UIState & UISF_HIDEFOCUS))
613  {
614  COLORREF crOldBk;
615 
616  crOldBk = SetBkColor(hDC,
617  GetSysColor(infoPtr->Enabled ? MONTHCAL_SELBG : MONTHCAL_DISABLED_SELBG));
618 
620  &rcHighlight);
621 
622  SetBkColor(hDC,
623  crOldBk);
624  }
625 
627  crOldText);
628  }
629  }
630  }
631  }
632  }
633  }
634 
635  if (crOldCtrlText != CLR_INVALID)
636  {
638  crOldCtrlText);
639  }
640 
641  SetBkMode(hDC,
642  iOldBkMode);
644  (HGDIOBJ)hOldFont);
645 }
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
#define CLR_INVALID
Definition: wingdi.h:882
LONG top
Definition: windef.h:292
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define MONTHCAL_DISABLED_HEADERFG
Definition: monthcal.c:23
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define DT_NOPREFIX
Definition: winuser.h:537
int32_t INT
Definition: typedefs.h:56
DWORD WINAPI GetSysColor(_In_ int)
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
#define MONTHCAL_DISABLED_CTRLFG
Definition: monthcal.c:25
long LONG
Definition: pedump.c:60
#define TRANSPARENT
Definition: wingdi.h:949
LONG cx
Definition: windef.h:319
GLint GLint bottom
Definition: glext.h:7726
#define DT_VCENTER
Definition: winuser.h:543
#define MONTHCAL_CTRLFG
Definition: monthcal.c:19
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD COLORREF
Definition: windef.h:285
#define MONTHCAL_DISABLED_CTRLBG
Definition: monthcal.c:24
#define swprintf(buf, format,...)
Definition: sprintf.c:56
int WINAPI GetSystemMetrics(_In_ int)
#define MONTHCAL_SELFG
Definition: monthcal.c:21
GLdouble GLdouble right
Definition: glext.h:10859
static const WCHAR L[]
Definition: oid.c:1250
#define MONTHCAL_DISABLED_SELFG
Definition: monthcal.c:27
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
static HDC hDC
Definition: 3dtext.c:33
#define DT_SINGLELINE
Definition: winuser.h:540
#define MONTHCAL_HEADERFG
Definition: monthcal.c:17
unsigned int UINT
Definition: ndis.h:50
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define MONTHCAL_DISABLED_SELBG
Definition: monthcal.c:26
LONG bottom
Definition: windef.h:294
#define DT_CENTER
Definition: winuser.h:527
#define MONTHCAL_SELBG
Definition: monthcal.c:20
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
LONG cy
Definition: windef.h:320
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17

Referenced by MonthCalWndProc().

◆ MonthCalPtToDay()

static WORD MonthCalPtToDay ( IN PMONTHCALWND  infoPtr,
IN INT  x,
IN INT  y 
)
static

Definition at line 666 of file monthcal.c.

669 {
670  WORD Ret = 0;
671 
672  if (infoPtr->CellSize.cx != 0 && infoPtr->CellSize.cy != 0 &&
673  x >= 0 && y >= 0)
674  {
675  x /= infoPtr->CellSize.cx;
676  y /= infoPtr->CellSize.cy;
677 
678  if (x < 7 && y != 0 && y < 7)
679  {
680  Ret = (WORD)infoPtr->Days[y - 1][x];
681  }
682  }
683 
684  return Ret;
685 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by MonthCalWndProc().

◆ MonthCalReload()

static VOID MonthCalReload ( IN PMONTHCALWND  infoPtr)
static

Definition at line 257 of file monthcal.c.

258 {
259  WCHAR szBuf[64];
260  UINT i;
261 
262  infoPtr->UIState = (DWORD)SendMessageW(GetAncestor(infoPtr->hSelf,
263  GA_PARENT),
264  WM_QUERYUISTATE,
265  0,
266  0);
267 
268  /* Cache the configuration */
269  infoPtr->FirstDayOfWeek = MonthCalFirstDayOfWeek();
270 
271  infoPtr->hbHeader = GetSysColorBrush(infoPtr->Enabled ? MONTHCAL_HEADERBG : MONTHCAL_DISABLED_HEADERBG);
272  infoPtr->hbSelection = GetSysColorBrush(infoPtr->Enabled ? MONTHCAL_SELBG : MONTHCAL_DISABLED_SELBG);
273 
274  for (i = 0; i < 7; i++)
275  {
278  ((i + infoPtr->FirstDayOfWeek) % 7),
279  szBuf,
280  sizeof(szBuf) / sizeof(szBuf[0])) != 0)
281  {
282  infoPtr->Week[i] = szBuf[0];
283  }
284  }
285 
286  /* Update the control */
287  MonthCalUpdate(infoPtr);
288 }
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)
#define MONTHCAL_DISABLED_HEADERBG
Definition: monthcal.c:22
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
#define LOCALE_USER_DEFAULT
#define DWORD
Definition: nt_native.h:44
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
static VOID MonthCalUpdate(IN PMONTHCALWND infoPtr)
Definition: monthcal.c:168
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 GA_PARENT
Definition: winuser.h:2763
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MONTHCAL_HEADERBG
Definition: monthcal.c:16
static WORD MonthCalFirstDayOfWeek(VOID)
Definition: monthcal.c:135
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50
#define MONTHCAL_DISABLED_SELBG
Definition: monthcal.c:26
#define MONTHCAL_SELBG
Definition: monthcal.c:20
HBRUSH WINAPI GetSysColorBrush(_In_ int)

Referenced by MonthCalWndProc().

◆ MonthCalRepaintDay()

static VOID MonthCalRepaintDay ( IN PMONTHCALWND  infoPtr,
IN WORD  Day 
)
static

Definition at line 442 of file monthcal.c.

444 {
445  RECT rcCell;
446 
447  if (MonthCalGetDayRect(infoPtr,
448  Day,
449  &rcCell))
450  {
451  InvalidateRect(infoPtr->hSelf,
452  &rcCell,
453  TRUE);
454  }
455 }
#define TRUE
Definition: types.h:120
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
static BOOL MonthCalGetDayRect(IN PMONTHCALWND infoPtr, IN WORD Day, OUT RECT *rcCell)
Definition: monthcal.c:291

Referenced by MonthCalWndProc().

◆ MonthCalSetDate()

static BOOL MonthCalSetDate ( IN PMONTHCALWND  infoPtr,
IN WORD  Day,
IN WORD  Month,
IN WORD  Year 
)
static

Definition at line 333 of file monthcal.c.

337 {
338  NMMCCSELCHANGE sc;
339  BOOL Ret = FALSE;
340 
341  sc.OldDay = infoPtr->Day;
342  sc.OldMonth = infoPtr->Month;
343  sc.OldYear = infoPtr->Year;
344  sc.NewDay = Day;
345  sc.NewMonth = Month;
346  sc.NewYear = Year;
347 
348  /* Notify the parent */
349  if (!MonthCalNotifyControlParent(infoPtr,
351  &sc))
352  {
353  /* Check if we actually need to update */
354  if (infoPtr->Month != sc.NewMonth ||
355  infoPtr->Year != sc.NewYear)
356  {
357  infoPtr->Day = sc.NewDay;
358  infoPtr->Month = sc.NewMonth;
359  infoPtr->Year = sc.NewYear;
360 
361  MonthCalChange(infoPtr);
362 
363  /* Repaint the entire control */
364  MonthCalUpdate(infoPtr);
365 
366  Ret = TRUE;
367  }
368  else if (infoPtr->Day != sc.NewDay)
369  {
370  RECT rcUpdate;
371 
372  infoPtr->Day = sc.NewDay;
373 
374  MonthCalChange(infoPtr);
375 
376  if (MonthCalGetDayRect(infoPtr,
377  sc.OldDay,
378  &rcUpdate))
379  {
380  /* Repaint the day cells that need to be updated */
381  InvalidateRect(infoPtr->hSelf,
382  &rcUpdate,
383  TRUE);
384  if (MonthCalGetDayRect(infoPtr,
385  sc.NewDay,
386  &rcUpdate))
387  {
388  InvalidateRect(infoPtr->hSelf,
389  &rcUpdate,
390  TRUE);
391  }
392  }
393 
394  Ret = TRUE;
395  }
396  }
397 
398  return Ret;
399 }
static VOID MonthCalChange(IN PMONTHCALWND infoPtr)
Definition: monthcal.c:318
#define TRUE
Definition: types.h:120
static VOID MonthCalUpdate(IN PMONTHCALWND infoPtr)
Definition: monthcal.c:168
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define MCCN_SELCHANGE
Definition: timedate.h:75
static LRESULT MonthCalNotifyControlParent(IN PMONTHCALWND infoPtr, IN UINT code, IN OUT PVOID data)
Definition: monthcal.c:56
static BOOL MonthCalGetDayRect(IN PMONTHCALWND infoPtr, IN WORD Day, OUT RECT *rcCell)
Definition: monthcal.c:291

Referenced by MonthCalSetLocalTime(), and MonthCalWndProc().

◆ MonthCalSetLocalTime()

static VOID MonthCalSetLocalTime ( IN PMONTHCALWND  infoPtr,
OUT SYSTEMTIME Time 
)
static

Definition at line 402 of file monthcal.c.

404 {
405  NMMCCAUTOUPDATE au;
406  SYSTEMTIME LocalTime = {0};
407 
408  GetLocalTime(&LocalTime);
409 
410  au.SystemTime = LocalTime;
411  if (!MonthCalNotifyControlParent(infoPtr,
413  &au))
414  {
415  if (MonthCalSetDate(infoPtr,
416  LocalTime.wDay,
417  LocalTime.wMonth,
418  LocalTime.wYear))
419  {
420  infoPtr->Changed = FALSE;
421  }
422  }
423 
424  /* Kill the day timer */
425  if (infoPtr->DayTimerSet)
426  {
427  KillTimer(infoPtr->hSelf,
428  ID_DAYTIMER);
429  infoPtr->DayTimerSet = FALSE;
430  }
431 
432  /* Setup the new day timer */
433  MonthCalSetupDayTimer(infoPtr);
434 
435  if (Time != NULL)
436  {
437  *Time = LocalTime;
438  }
439 }
WORD wMonth
Definition: winbase.h:878
static BOOL MonthCalSetDate(IN PMONTHCALWND infoPtr, IN WORD Day, IN WORD Month, IN WORD Year)
Definition: monthcal.c:333
static VOID MonthCalSetupDayTimer(IN PMONTHCALWND infoPtr)
Definition: monthcal.c:227
#define ID_DAYTIMER
Definition: monthcal.c:29
SYSTEMTIME SystemTime
Definition: timedate.h:90
WORD wYear
Definition: winbase.h:877
smooth NULL
Definition: ftsmooth.c:416
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:276
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
static LRESULT MonthCalNotifyControlParent(IN PMONTHCALWND infoPtr, IN UINT code, IN OUT PVOID data)
Definition: monthcal.c:56
WORD wDay
Definition: winbase.h:880
static PLARGE_INTEGER Time
Definition: time.c:105
#define MCCN_AUTOUPDATE
Definition: timedate.h:86

Referenced by MonthCalWndProc().

◆ MonthCalSetupDayTimer()

static VOID MonthCalSetupDayTimer ( IN PMONTHCALWND  infoPtr)
static

Definition at line 227 of file monthcal.c.

228 {
229  SYSTEMTIME LocalTime = {0};
230  UINT uElapse;
231 
232  /* Update the current date */
233  GetLocalTime(&LocalTime);
234 
235  /* Calculate the number of remaining milliseconds until midnight */
236  uElapse = 1000 - (UINT)LocalTime.wMilliseconds;
237  uElapse += (59 - (UINT)LocalTime.wSecond) * 1000;
238  uElapse += (59 - (UINT)LocalTime.wMinute) * 60 * 1000;
239  uElapse += (23 - (UINT)LocalTime.wHour) * 60 * 60 * 1000;
240 
241  if (uElapse < USER_TIMER_MINIMUM || uElapse > USER_TIMER_MAXIMUM)
242  uElapse = 1000;
243  else
244  uElapse += 100; /* Add a delay of 0.1 seconds */
245 
246  /* Setup the new timer */
247  if (SetTimer(infoPtr->hSelf,
248  ID_DAYTIMER,
249  uElapse,
250  NULL) != 0)
251  {
252  infoPtr->DayTimerSet = TRUE;
253  }
254 }
#define TRUE
Definition: types.h:120
#define ID_DAYTIMER
Definition: monthcal.c:29
WORD wMinute
Definition: winbase.h:882
smooth NULL
Definition: ftsmooth.c:416
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:276
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
WORD wSecond
Definition: winbase.h:883
WORD wMilliseconds
Definition: winbase.h:884
#define USER_TIMER_MAXIMUM
Definition: winuser.h:895
WORD wHour
Definition: winbase.h:881
unsigned int UINT
Definition: ndis.h:50

Referenced by MonthCalSetLocalTime().

◆ MonthCalUpdate()

static VOID MonthCalUpdate ( IN PMONTHCALWND  infoPtr)
static

Definition at line 168 of file monthcal.c.

169 {
170  PBYTE pDay, pDayEnd;
171  WORD DayOfWeek, MonthLength, d = 0;
172  SIZE NewCellSize;
173  BOOL RepaintHeader = FALSE;
174 
175  NewCellSize.cx = infoPtr->ClientSize.cx / 7;
176  NewCellSize.cy = infoPtr->ClientSize.cy / 7;
177 
178  if (infoPtr->CellSize.cx != NewCellSize.cx ||
179  infoPtr->CellSize.cy != NewCellSize.cy)
180  {
181  infoPtr->CellSize = NewCellSize;
182  RepaintHeader = TRUE;
183  }
184 
185  /* Update the days layout of the current month */
186  ZeroMemory(infoPtr->Days,
187  sizeof(infoPtr->Days));
188 
189  DayOfWeek = MonthCalDayOfWeek(infoPtr,
190  1,
191  infoPtr->Month,
192  infoPtr->Year);
193 
194  MonthLength = MonthCalMonthLength(infoPtr->Month,
195  infoPtr->Year);
196 
197  pDay = &infoPtr->Days[0][DayOfWeek];
198  pDayEnd = pDay + MonthLength;
199  while (pDay != pDayEnd)
200  {
201  *(pDay++) = (BYTE)++d;
202  }
203 
204  /* Repaint the control */
205  if (RepaintHeader)
206  {
207  InvalidateRect(infoPtr->hSelf,
208  NULL,
209  TRUE);
210  }
211  else
212  {
213  RECT rcClient;
214 
215  rcClient.left = 0;
216  rcClient.top = infoPtr->CellSize.cy;
217  rcClient.right = infoPtr->ClientSize.cx;
218  rcClient.bottom = infoPtr->ClientSize.cy;
219 
220  InvalidateRect(infoPtr->hSelf,
221  &rcClient,
222  TRUE);
223  }
224 }
#define TRUE
Definition: types.h:120
LONG top
Definition: windef.h:292
#define ZeroMemory
Definition: winbase.h:1642
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
#define d
Definition: ke_i.h:81
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned short WORD
Definition: ntddk_ex.h:93
static WORD MonthCalDayOfWeek(IN PMONTHCALWND infoPtr, IN WORD Day, IN WORD Month, IN WORD Year)
Definition: monthcal.c:120
unsigned char BYTE
Definition: mem.h:68
LONG bottom
Definition: windef.h:294
static WORD MonthCalMonthLength(IN WORD Month, IN WORD Year)
Definition: monthcal.c:94
LONG cy
Definition: windef.h:320
BYTE * PBYTE
Definition: pedump.c:66

Referenced by MonthCalReload(), MonthCalSetDate(), and MonthCalWndProc().

◆ MonthCalValidDate()

static BOOL MonthCalValidDate ( IN WORD  Day,
IN WORD  Month,
IN WORD  Year 
)
static

Definition at line 152 of file monthcal.c.

155 {
156  if (Month < 1 || Month > 12 ||
157  Day == 0 || Day > MonthCalMonthLength(Month,
158  Year) ||
159  Year < 1899 || Year > 9999)
160  {
161  return FALSE;
162  }
163 
164  return TRUE;
165 }
#define TRUE
Definition: types.h:120
static WORD MonthCalMonthLength(IN WORD Month, IN WORD Year)
Definition: monthcal.c:94

Referenced by MonthCalWndProc().

◆ MonthCalWeekInMonth()

static WORD MonthCalWeekInMonth ( IN WORD  Day,
IN WORD  DayOfWeek 
)
static

Definition at line 113 of file monthcal.c.

115 {
116  return (Day - DayOfWeek + 5) / 7;
117 }

Referenced by MonthCalGetDayRect().

◆ MonthCalWndProc()

static LRESULT CALLBACK MonthCalWndProc ( IN HWND  hwnd,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 688 of file monthcal.c.

692 {
693  PMONTHCALWND infoPtr;
694  LRESULT Ret = 0;
695 
697  0);
698 
699  if (infoPtr == NULL && uMsg != WM_CREATE)
700  {
701  goto HandleDefaultMessage;
702  }
703 
704  switch (uMsg)
705  {
706 #if MONTHCAL_CTRLBG != MONTHCAL_DISABLED_CTRLBG
707  case WM_ERASEBKGND:
708  Ret = !infoPtr->Enabled;
709  break;
710 #endif
711 
712  case WM_PAINT:
713  case WM_PRINTCLIENT:
714  {
715  if (infoPtr->CellSize.cx != 0 && infoPtr->CellSize.cy != 0)
716  {
717  PAINTSTRUCT ps;
718  HDC hDC;
719 
720  if (wParam != 0)
721  {
722  if (!GetUpdateRect(hwnd,
723  &ps.rcPaint,
724  TRUE))
725  {
726  break;
727  }
728  hDC = (HDC)wParam;
729  }
730  else
731  {
732  hDC = BeginPaint(hwnd,
733  &ps);
734  if (hDC == NULL)
735  {
736  break;
737  }
738  }
739 
740  MonthCalPaint(infoPtr,
741  hDC,
742  &ps.rcPaint);
743 
744  if (wParam == 0)
745  {
746  EndPaint(hwnd,
747  &ps);
748  }
749  }
750  break;
751  }
752 
753  case WM_LBUTTONDBLCLK:
754  case WM_LBUTTONDOWN:
755  {
756  WORD SelDay;
757 
758  SelDay = MonthCalPtToDay(infoPtr,
761  if (SelDay != 0 && SelDay != infoPtr->Day)
762  {
763  MonthCalSetDate(infoPtr,
764  SelDay,
765  infoPtr->Month,
766  infoPtr->Year);
767  }
768 
769  /* Fall through */
770  }
771 
772  case WM_MBUTTONDOWN:
773  case WM_RBUTTONDOWN:
774  {
775  if (!infoPtr->HasFocus)
776  {
777  SetFocus(hwnd);
778  }
779  break;
780  }
781 
782  case WM_KEYDOWN:
783  {
784  WORD NewDay = 0;
785 
786  switch (wParam)
787  {
788  case VK_UP:
789  {
790  if (infoPtr->Day > 7)
791  {
792  NewDay = infoPtr->Day - 7;
793  }
794  break;
795  }
796 
797  case VK_DOWN:
798  {
799  if (infoPtr->Day + 7 <= MonthCalMonthLength(infoPtr->Month,
800  infoPtr->Year))
801  {
802  NewDay = infoPtr->Day + 7;
803  }
804  break;
805  }
806 
807  case VK_LEFT:
808  {
809  if (infoPtr->Day > 1)
810  {
811  NewDay = infoPtr->Day - 1;
812  }
813  break;
814  }
815 
816  case VK_RIGHT:
817  {
818  if (infoPtr->Day < MonthCalMonthLength(infoPtr->Month,
819  infoPtr->Year))
820  {
821  NewDay = infoPtr->Day + 1;
822  }
823  break;
824  }
825  }
826 
827  /* Update the selection */
828  if (NewDay != 0)
829  {
830  MonthCalSetDate(infoPtr,
831  NewDay,
832  infoPtr->Month,
833  infoPtr->Year);
834  }
835 
836  goto HandleDefaultMessage;
837  }
838 
839  case WM_GETDLGCODE:
840  {
841  INT virtKey;
842 
843  virtKey = (lParam != 0 ? (INT)((LPMSG)lParam)->wParam : 0);
844  switch (virtKey)
845  {
846  case VK_TAB:
847  {
848  /* Change the UI status */
850  GA_PARENT),
851  WM_CHANGEUISTATE,
852  MAKEWPARAM(UIS_INITIALIZE,
853  0),
854  0);
855  break;
856  }
857  }
858 
859  Ret |= DLGC_WANTARROWS;
860  break;
861  }
862 
863  case WM_SETFOCUS:
864  {
865  infoPtr->HasFocus = TRUE;
866  MonthCalRepaintDay(infoPtr,
867  infoPtr->Day);
868  break;
869  }
870 
871  case WM_KILLFOCUS:
872  {
873  infoPtr->HasFocus = FALSE;
874  MonthCalRepaintDay(infoPtr,
875  infoPtr->Day);
876  break;
877  }
878 
879  case WM_UPDATEUISTATE:
880  {
881  DWORD OldUIState;
882 
883  Ret = DefWindowProcW(hwnd,
884  uMsg,
885  wParam,
886  lParam);
887 
888  OldUIState = infoPtr->UIState;
889  switch (LOWORD(wParam))
890  {
891  case UIS_SET:
892  infoPtr->UIState |= HIWORD(wParam);
893  break;
894 
895  case UIS_CLEAR:
896  infoPtr->UIState &= ~HIWORD(wParam);
897  break;
898  }
899 
900  if (infoPtr->UIState != OldUIState)
901  {
902  MonthCalRepaintDay(infoPtr,
903  infoPtr->Day);
904  }
905  break;
906  }
907 
908  case MCCM_SETDATE:
909  {
910  WORD Day, Month, Year, DaysCount;
911 
912  Day = LOWORD(wParam);
913  Month = HIWORD(wParam);
914  Year = LOWORD(lParam);
915 
916  if (Day == (WORD)-1)
917  Day = infoPtr->Day;
918  if (Month == (WORD)-1)
919  Month = infoPtr->Month;
920  if (Year == (WORD)-1)
921  Year = infoPtr->Year;
922 
923  DaysCount = MonthCalMonthLength(Month,
924  Year);
925  if (Day > DaysCount)
926  Day = DaysCount;
927 
928  if (MonthCalValidDate(Day,
929  Month,
930  Year))
931  {
932  if (Day != infoPtr->Day ||
933  Month != infoPtr->Month ||
934  Year != infoPtr->Year)
935  {
936  Ret = MonthCalSetDate(infoPtr,
937  Day,
938  Month,
939  Year);
940  }
941  }
942  break;
943  }
944 
945  case MCCM_GETDATE:
946  {
947  LPSYSTEMTIME lpSystemTime = (LPSYSTEMTIME)wParam;
948 
949  lpSystemTime->wYear = infoPtr->Year;
950  lpSystemTime->wMonth = infoPtr->Month;
951  lpSystemTime->wDay = infoPtr->Day;
952 
953  Ret = TRUE;
954  break;
955  }
956 
957  case MCCM_RESET:
958  {
959  MonthCalSetLocalTime(infoPtr,
960  NULL);
961  Ret = TRUE;
962  break;
963  }
964 
965  case MCCM_CHANGED:
966  {
967  Ret = infoPtr->Changed;
968  break;
969  }
970 
971  case WM_TIMER:
972  {
973  switch (wParam)
974  {
975  case ID_DAYTIMER:
976  {
977  /* Kill the timer */
978  KillTimer(hwnd,
979  ID_DAYTIMER);
980  infoPtr->DayTimerSet = FALSE;
981 
982  if (!infoPtr->Changed)
983  {
984  /* Update the system time and setup the new day timer */
985  MonthCalSetLocalTime(infoPtr,
986  NULL);
987 
988  /* Update the control */
989  MonthCalUpdate(infoPtr);
990  }
991  break;
992  }
993  }
994  break;
995  }
996 
997  case WM_SETFONT:
998  {
999  Ret = (LRESULT)MonthCalChangeFont(infoPtr,
1000  (HFONT)wParam,
1001  (BOOL)LOWORD(lParam));
1002  break;
1003  }
1004 
1005  case WM_SIZE:
1006  {
1007  infoPtr->ClientSize.cx = LOWORD(lParam);
1008  infoPtr->ClientSize.cy = HIWORD(lParam);
1009  infoPtr->CellSize.cx = infoPtr->ClientSize.cx / 7;
1010  infoPtr->CellSize.cy = infoPtr->ClientSize.cy / 7;
1011 
1012  /* Repaint the control */
1014  NULL,
1015  TRUE);
1016  break;
1017  }
1018 
1019  case WM_GETFONT:
1020  {
1021  Ret = (LRESULT)infoPtr->hFont;
1022  break;
1023  }
1024 
1025  case WM_ENABLE:
1026  {
1027  infoPtr->Enabled = ((BOOL)wParam != FALSE);
1028  MonthCalReload(infoPtr);
1029  break;
1030  }
1031 
1032  case WM_STYLECHANGED:
1033  {
1034  if (wParam == GWL_STYLE)
1035  {
1036  unsigned int OldEnabled = infoPtr->Enabled;
1037  infoPtr->Enabled = !(((LPSTYLESTRUCT)lParam)->styleNew & WS_DISABLED);
1038 
1039  if (OldEnabled != infoPtr->Enabled)
1040  {
1041  MonthCalReload(infoPtr);
1042  }
1043  }
1044  break;
1045  }
1046 
1047  case WM_CREATE:
1048  {
1049  infoPtr = (MONTHCALWND*) HeapAlloc(GetProcessHeap(),
1050  0,
1051  sizeof(MONTHCALWND));
1052  if (infoPtr == NULL)
1053  {
1054  Ret = (LRESULT)-1;
1055  break;
1056  }
1057 
1059  0,
1060  (LONG_PTR)infoPtr);
1061 
1062  ZeroMemory(infoPtr,
1063  sizeof(MONTHCALWND));
1064 
1065  infoPtr->hSelf = hwnd;
1066  infoPtr->hNotify = ((LPCREATESTRUCTW)lParam)->hwndParent;
1067  infoPtr->Enabled = !(((LPCREATESTRUCTW)lParam)->style & WS_DISABLED);
1068 
1069  MonthCalSetLocalTime(infoPtr,
1070  NULL);
1071 
1072  MonthCalReload(infoPtr);
1073  break;
1074  }
1075 
1076  case WM_DESTROY:
1077  {
1079  0,
1080  infoPtr);
1082  0,
1083  (DWORD_PTR)NULL);
1084  break;
1085  }
1086 
1087  default:
1088  {
1089 HandleDefaultMessage:
1090  Ret = DefWindowProcW(hwnd,
1091  uMsg,
1092  wParam,
1093  lParam);
1094  break;
1095  }
1096  }
1097 
1098  return Ret;
1099 }
WORD Month
Definition: monthcal.c:36
#define WS_DISABLED
Definition: pedump.c:621
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MCCM_SETDATE
Definition: timedate.h:70
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3948
#define WM_GETDLGCODE
Definition: winuser.h:1671
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
WORD wMonth
Definition: winbase.h:878
#define MCCM_RESET
Definition: timedate.h:72
UINT Changed
Definition: monthcal.c:49
#define INT
Definition: polytest.cpp:20
static HDC
Definition: imagelist.c:92
static VOID MonthCalSetLocalTime(IN PMONTHCALWND infoPtr, OUT SYSTEMTIME *Time)
Definition: monthcal.c:402
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
#define VK_LEFT
Definition: winuser.h:2199
#define ZeroMemory
Definition: winbase.h:1642
HWND WINAPI SetFocus(_In_opt_ HWND)
static BOOL MonthCalSetDate(IN PMONTHCALWND infoPtr, IN WORD Day, IN WORD Month, IN WORD Year)
Definition: monthcal.c:333
#define VK_TAB
Definition: winuser.h:2174
#define VK_DOWN
Definition: winuser.h:2202
#define GetWindowLongPtrW
Definition: winuser.h:4730
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
int32_t INT
Definition: typedefs.h:56
WPARAM wParam
Definition: combotst.c:138
#define MCCM_CHANGED
Definition: timedate.h:73
#define ID_DAYTIMER
Definition: monthcal.c:29
#define WM_ENABLE
Definition: winuser.h:1597
#define WM_PRINTCLIENT
Definition: richedit.h:70
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
SIZE CellSize
Definition: monthcal.c:41
static VOID MonthCalUpdate(IN PMONTHCALWND infoPtr)
Definition: monthcal.c:168
WORD wYear
Definition: winbase.h:877
#define VK_UP
Definition: winuser.h:2200
#define GA_PARENT
Definition: winuser.h:2763
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
UINT Enabled
Definition: monthcal.c:51
static VOID MonthCalReload(IN PMONTHCALWND infoPtr)
Definition: monthcal.c:257
smooth NULL
Definition: ftsmooth.c:416
#define WM_GETFONT
Definition: winuser.h:1633
LONG cx
Definition: windef.h:319
#define WM_KEYDOWN
Definition: winuser.h:1697
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_RBUTTONDOWN
Definition: winuser.h:1761
SIZE ClientSize
Definition: monthcal.c:42
struct tagSTYLESTRUCT * LPSTYLESTRUCT
#define WM_KILLFOCUS
Definition: winuser.h:1596
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define WM_SIZE
Definition: winuser.h:1593
#define WM_TIMER
Definition: winuser.h:1724
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
static HFONT MonthCalChangeFont(IN PMONTHCALWND infoPtr, IN HFONT hFont, IN BOOL Redraw)
Definition: monthcal.c:648
#define WM_PAINT
Definition: winuser.h:1602
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
DWORD UIState
Definition: monthcal.c:48
BOOL WINAPI GetUpdateRect(_In_ HWND, _Out_opt_ LPRECT, _In_ BOOL)
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1760
#define LRESULT
Definition: ole.h:14
WORD Day
Definition: monthcal.c:35
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define VK_RIGHT
Definition: winuser.h:2201
static BOOL(WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX *)
#define GWL_STYLE
Definition: winuser.h:846
static HDC hDC
Definition: 3dtext.c:33
WORD wDay
Definition: winbase.h:880
WORD Year
Definition: monthcal.c:37
static VOID MonthCalRepaintDay(IN PMONTHCALWND infoPtr, IN WORD Day)
Definition: monthcal.c:442
static WORD MonthCalPtToDay(IN PMONTHCALWND infoPtr, IN INT x, IN INT y)
Definition: monthcal.c:666
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
struct tagCREATESTRUCTW * LPCREATESTRUCTW
struct _MONTHCALWND * PMONTHCALWND
#define WM_MBUTTONDOWN
Definition: winuser.h:1764
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
HWND hNotify
Definition: monthcal.c:34
UINT HasFocus
Definition: monthcal.c:52
#define WM_SETFONT
Definition: winuser.h:1632
HWND hSelf
Definition: monthcal.c:33
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
UINT DayTimerSet
Definition: monthcal.c:50
static VOID MonthCalPaint(IN PMONTHCALWND infoPtr, IN HDC hDC, IN LPRECT prcUpdate)
Definition: monthcal.c:458
#define MCCM_GETDATE
Definition: timedate.h:71
#define WM_CREATE
Definition: winuser.h:1590
#define HIWORD(l)
Definition: typedefs.h:246
#define SetWindowLongPtrW
Definition: winuser.h:5247
static WORD MonthCalMonthLength(IN WORD Month, IN WORD Year)
Definition: monthcal.c:94
#define WM_ERASEBKGND
Definition: winuser.h:1607
#define WM_SETFOCUS
Definition: winuser.h:1595
struct _MONTHCALWND MONTHCALWND
LONG_PTR LRESULT
Definition: windef.h:209
struct _SYSTEMTIME * LPSYSTEMTIME
Definition: time.c:27
LONG cy
Definition: windef.h:320
HFONT hFont
Definition: monthcal.c:44
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:394
#define DLGC_WANTARROWS
Definition: winuser.h:2585
static BOOL MonthCalValidDate(IN WORD Day, IN WORD Month, IN WORD Year)
Definition: monthcal.c:152

Referenced by RegisterMonthCalControl().

◆ RegisterMonthCalControl()

BOOL RegisterMonthCalControl ( IN HINSTANCE  hInstance)

Definition at line 1102 of file monthcal.c.

1103 {
1104  WNDCLASSW wc = {0};
1105 
1106  wc.style = CS_DBLCLKS;
1108  wc.cbWndExtra = sizeof(PMONTHCALWND);
1109  wc.hInstance = hInstance;
1110  wc.hCursor = LoadCursorW(NULL,
1111  (LPWSTR)IDC_ARROW);
1112  wc.hbrBackground = (HBRUSH)(MONTHCAL_CTRLBG + 1);
1114 
1115  return RegisterClassW(&wc) != 0;
1116 }
UINT style
Definition: winuser.h:3150
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
HINSTANCE hInstance
Definition: charmap.c:20
WNDPROC lpfnWndProc
Definition: winuser.h:3151
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszClassName
Definition: winuser.h:3159
int cbWndExtra
Definition: winuser.h:3153
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define CS_DBLCLKS
Definition: winuser.h:646
HCURSOR hCursor
Definition: winuser.h:3156
#define MONTHCAL_CTRLBG
Definition: monthcal.c:18
HBRUSH hbrBackground
Definition: winuser.h:3157
struct _MONTHCALWND * PMONTHCALWND
static const WCHAR szMonthCalWndClass[]
Definition: monthcal.c:14
HINSTANCE hInstance
Definition: winuser.h:3154
#define IDC_ARROW
Definition: winuser.h:682
static LRESULT CALLBACK MonthCalWndProc(IN HWND hwnd, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: monthcal.c:688
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by Applet().

◆ UnregisterMonthCalControl()

VOID UnregisterMonthCalControl ( IN HINSTANCE  hInstance)

Definition at line 1119 of file monthcal.c.

1120 {
1122  hInstance);
1123 }
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
HINSTANCE hInstance
Definition: charmap.c:20
static const WCHAR szMonthCalWndClass[]
Definition: monthcal.c:14

Referenced by Applet().

Variable Documentation

◆ szMonthCalWndClass

const WCHAR szMonthCalWndClass[] = L"MonthCalWnd"
static

Definition at line 14 of file monthcal.c.

Referenced by RegisterMonthCalControl(), and UnregisterMonthCalControl().