--- np2/win9x/dialog/d_clnd.cpp 2003/10/31 03:40:10 1.3 +++ np2/win9x/dialog/d_clnd.cpp 2005/03/20 13:12:50 1.8 @@ -10,12 +10,21 @@ #include "calendar.h" -static BYTE cbuf[8]; +#if !defined(OSLANG_UTF8) +#define tchar_2x str_2x +#define tchar_2d str_2d +#else +static const TCHAR tchar_2x[] = _T("%.2x"); +static const TCHAR tchar_2d[] = _T("%.2d"); +#endif + + +static UINT8 cbuf[8]; typedef struct { UINT16 res; - BYTE min; - BYTE max; + UINT8 min; + UINT8 max; } VIRCAL_T; static const VIRCAL_T vircal[6] = { {IDC_VIRYEAR, 0x00, 0x99}, @@ -26,17 +35,17 @@ static const VIRCAL_T vircal[6] = { {IDC {IDC_VIRSECOND, 0x00, 0x59}}; -static void set_cal2dlg(HWND hWnd, const BYTE *cbuf) { +static void set_cal2dlg(HWND hWnd, const UINT8 *cbuf) { int i; - char work[8]; + TCHAR work[8]; for (i=0; i<6; i++) { if (i != 1) { - wsprintf(work, str_2x, cbuf[i]); + wsprintf(work, tchar_2x, cbuf[i]); } else { - wsprintf(work, str_2d, cbuf[1] >> 4); + wsprintf(work, tchar_2d, cbuf[1] >> 4); } SetDlgItemText(hWnd, vircal[i].res, work); } @@ -52,14 +61,11 @@ static void vircalendar(HWND hWnd, BOOL EnableWindow(GetDlgItem(hWnd, IDC_SETNOW), disp); } -static DWORD getbcd(char *str, int len) { +static UINT8 getbcd(const TCHAR *str, int len) { - DWORD ret; - BYTE c; + UINT ret; + TCHAR c; - if (!(*str)) { - return(0xff); - } ret = 0; while(len--) { c = *str++; @@ -70,15 +76,15 @@ static DWORD getbcd(char *str, int len) return(0xff); } ret <<= 4; - ret |= (BYTE)(c - '0'); + ret |= (UINT)(c - '0'); } - return(ret); + return((UINT8)ret); } LRESULT CALLBACK ClndDialogProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { - char work[32]; - BYTE b; + TCHAR work[32]; + UINT8 b; int i; HWND subwnd; @@ -100,7 +106,7 @@ LRESULT CALLBACK ClndDialogProc(HWND hWn return(FALSE); case WM_COMMAND: - switch (LOWORD(wp)) { + switch(LOWORD(wp)) { case IDOK: b = GetDlgItemCheck(hWnd, IDC_CLNDREAL); if (np2cfg.calendar != b) { @@ -109,8 +115,8 @@ LRESULT CALLBACK ClndDialogProc(HWND hWn } for (i=0; i<6; i++) { GetDlgItemText(hWnd, vircal[i].res, - work, sizeof(work)); - b = (BYTE)getbcd(work, 2); + work, NELEMENTS(work)); + b = getbcd(work, 2); if ((b >= vircal[i].min) && (b <= vircal[i].max)) { if (i == 1) { b = ((b & 0x10) * 10) + (b << 4);