mirror of
https://github.com/reactos/reactos.git
synced 2024-10-04 08:25:53 +00:00
- Add an analog clock to the timedate cpl.
- Add more code towards setting system time via NTP svn path=/trunk/; revision=21218
This commit is contained in:
parent
7dac3e7a17
commit
c280bc696c
|
@ -15,7 +15,7 @@ BEGIN
|
||||||
GROUPBOX "&Time", -1, 132, 2, 113, 125
|
GROUPBOX "&Time", -1, 132, 2, 113, 125
|
||||||
CONTROL "", IDC_TIMEPICKER, "SysDateTimePick32",
|
CONTROL "", IDC_TIMEPICKER, "SysDateTimePick32",
|
||||||
DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
|
DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
|
||||||
144, 17, 90, 12
|
144, 105, 90, 12
|
||||||
LTEXT "", IDC_TIMEZONE, 4, 136, 241, 8
|
LTEXT "", IDC_TIMEZONE, 4, 136, 241, 8
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ CAPTION "Internet Time"
|
||||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
COMBOBOX IDC_SERVERLIST, 65, 22, 117, 136, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||||
CONTROL "Automatically synchronize with an Internet time server", IDC_AUTOSYNC,
|
AUTOCHECKBOX "Automatically synchronize with an Internet time server", IDC_AUTOSYNC,
|
||||||
"Button", BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP, 11 ,7, 241, 10
|
11 ,7, 241, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
|
||||||
LTEXT "Server:", -1, 34, 22, 28, 13
|
LTEXT "Server:", IDC_SERVERTEXT, 34, 22, 28, 13
|
||||||
PUSHBUTTON "Update Now", IDC_UPDATEBUTTON, 187, 22, 49, 14
|
PUSHBUTTON "Update Now", IDC_UPDATEBUTTON, 187, 22, 49, 14
|
||||||
LTEXT "", IDC_SUCSYNC, 12, 54, 214, 23
|
LTEXT "", IDC_SUCSYNC, 12, 54, 214, 23
|
||||||
LTEXT "", IDC_NEXTSYNC, 12, 96, 137, 12
|
LTEXT "", IDC_NEXTSYNC, 12, 96, 137, 12
|
||||||
|
|
174
reactos/dll/cpl/timedate/clock.c
Normal file
174
reactos/dll/cpl/timedate/clock.c
Normal file
|
@ -0,0 +1,174 @@
|
||||||
|
/* Core functions lifted from Programming Windows, Charles Petzold */
|
||||||
|
|
||||||
|
#include "timedate.h"
|
||||||
|
|
||||||
|
#define TWOPI (2 * 3.14159)
|
||||||
|
|
||||||
|
static const TCHAR szClockWndClass[] = TEXT("ClockWndClass");
|
||||||
|
|
||||||
|
|
||||||
|
VOID SetIsotropic(HDC hdc, INT cxClient, INT cyClient)
|
||||||
|
{
|
||||||
|
SetMapMode (hdc, MM_ISOTROPIC);
|
||||||
|
SetWindowExtEx (hdc, 1000, 1000, NULL);
|
||||||
|
SetViewportExtEx (hdc, cxClient / 2, -cyClient / 2, NULL);
|
||||||
|
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID RotatePoint(POINT pt[], INT iNum, INT iAngle)
|
||||||
|
{
|
||||||
|
INT i;
|
||||||
|
POINT ptTemp;
|
||||||
|
|
||||||
|
for (i = 0 ; i < iNum ; i++)
|
||||||
|
{
|
||||||
|
ptTemp.x = (INT) (pt[i].x * cos (TWOPI * iAngle / 360) +
|
||||||
|
pt[i].y * sin (TWOPI * iAngle / 360));
|
||||||
|
|
||||||
|
ptTemp.y = (INT) (pt[i].y * cos (TWOPI * iAngle / 360) -
|
||||||
|
pt[i].x * sin (TWOPI * iAngle / 360));
|
||||||
|
|
||||||
|
pt[i] = ptTemp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID DrawClock(HDC hdc)
|
||||||
|
{
|
||||||
|
INT iAngle;
|
||||||
|
POINT pt[3];
|
||||||
|
|
||||||
|
for (iAngle = 0; iAngle < 360; iAngle += 6)
|
||||||
|
{
|
||||||
|
pt[0].x = 0;
|
||||||
|
pt[0].y = 900;
|
||||||
|
|
||||||
|
RotatePoint(pt, 1, iAngle);
|
||||||
|
|
||||||
|
pt[2].x = pt[2].y = iAngle % 5 ? 33 : 100;
|
||||||
|
|
||||||
|
pt[0].x -= pt[2].x / 2;
|
||||||
|
pt[0].y -= pt[2].y / 2;
|
||||||
|
|
||||||
|
pt[1].x = pt[0].x + pt[2].x;
|
||||||
|
pt[1].y = pt[0].y + pt[2].y;
|
||||||
|
|
||||||
|
SelectObject(hdc, GetStockObject (BLACK_BRUSH));
|
||||||
|
|
||||||
|
Ellipse(hdc, pt[0].x, pt[0].y, pt[1].x, pt[1].y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID DrawHands(HDC hdc, SYSTEMTIME * pst, BOOL fChange)
|
||||||
|
{
|
||||||
|
static POINT pt[3][5] = { {{0, -150}, {100, 0}, {0, 600}, {-100, 0}, {0, -150}},
|
||||||
|
{{0, -200}, { 50, 0}, {0, 800}, { -50, 0}, {0, -200}},
|
||||||
|
{{0, 0}, { 0, 0}, {0, 0}, { 0, 0}, {0, 800}} };
|
||||||
|
INT i, iAngle[3];
|
||||||
|
POINT ptTemp[3][5];
|
||||||
|
|
||||||
|
iAngle[0] = (pst->wHour * 30) % 360 + pst->wMinute / 2;
|
||||||
|
iAngle[1] = pst->wMinute * 6;
|
||||||
|
iAngle[2] = pst->wSecond * 6;
|
||||||
|
|
||||||
|
memcpy(ptTemp, pt, sizeof(pt));
|
||||||
|
|
||||||
|
for (i = fChange ? 0 : 2 ; i < 3 ; i++)
|
||||||
|
{
|
||||||
|
RotatePoint(ptTemp[i], 5, iAngle[i]);
|
||||||
|
|
||||||
|
Polygon(hdc, ptTemp[i], 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static LRESULT CALLBACK
|
||||||
|
ClockWndProc(HWND hwnd,
|
||||||
|
UINT uMsg,
|
||||||
|
WPARAM wParam,
|
||||||
|
LPARAM lParam)
|
||||||
|
{
|
||||||
|
static INT cxClient, cyClient;
|
||||||
|
static SYSTEMTIME stPrevious;
|
||||||
|
BOOL fChange;
|
||||||
|
HDC hdc;
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
SYSTEMTIME st;
|
||||||
|
|
||||||
|
switch (uMsg)
|
||||||
|
{
|
||||||
|
case WM_CREATE:
|
||||||
|
SetTimer(hwnd, ID_TIMER, 1000, NULL);
|
||||||
|
GetLocalTime(&st);
|
||||||
|
stPrevious = st;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_SIZE:
|
||||||
|
cxClient = LOWORD(lParam);
|
||||||
|
cyClient = HIWORD(lParam);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_TIMER:
|
||||||
|
GetLocalTime(&st);
|
||||||
|
|
||||||
|
fChange = st.wHour != stPrevious.wHour ||
|
||||||
|
st.wMinute != stPrevious.wMinute;
|
||||||
|
|
||||||
|
hdc = GetDC(hwnd);
|
||||||
|
|
||||||
|
SetIsotropic(hdc, cxClient, cyClient);
|
||||||
|
|
||||||
|
InvalidateRect(hwnd, NULL, TRUE);
|
||||||
|
|
||||||
|
SelectObject(hdc, GetStockObject(BLACK_PEN));
|
||||||
|
DrawHands(hdc, &st, TRUE);
|
||||||
|
|
||||||
|
ReleaseDC(hwnd, hdc);
|
||||||
|
|
||||||
|
stPrevious = st;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_PAINT:
|
||||||
|
hdc = BeginPaint(hwnd, &ps);
|
||||||
|
|
||||||
|
SetIsotropic(hdc, cxClient, cyClient);
|
||||||
|
|
||||||
|
DrawClock(hdc);
|
||||||
|
SelectObject(hdc, GetStockObject(WHITE_BRUSH));
|
||||||
|
DrawHands(hdc, &stPrevious, TRUE);
|
||||||
|
|
||||||
|
EndPaint(hwnd, &ps);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
KillTimer(hwnd, ID_TIMER);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
DefWindowProc(hwnd,
|
||||||
|
uMsg,
|
||||||
|
wParam,
|
||||||
|
lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
InitClockWindowClass(VOID)
|
||||||
|
{
|
||||||
|
WNDCLASSEX wc = {0};
|
||||||
|
|
||||||
|
wc.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
|
wc.lpfnWndProc = ClockWndProc;
|
||||||
|
wc.hInstance = hApplet;
|
||||||
|
wc.hIcon = NULL;
|
||||||
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||||
|
wc.lpszClassName = szClockWndClass;
|
||||||
|
wc.hIconSm = NULL;
|
||||||
|
|
||||||
|
return RegisterClassEx(&wc) != (ATOM)0;
|
||||||
|
}
|
87
reactos/dll/cpl/timedate/ntpclient.c
Normal file
87
reactos/dll/cpl/timedate/ntpclient.c
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
#include "timedate.h"
|
||||||
|
|
||||||
|
SOCKET Sock;
|
||||||
|
SOCKADDR_IN myAddr, ntpAddr;
|
||||||
|
|
||||||
|
BOOL InitialiseConnection()
|
||||||
|
{
|
||||||
|
WSADATA wsaData;
|
||||||
|
INT Ret;
|
||||||
|
|
||||||
|
Ret = WSAStartup(MAKEWORD(2, 2),
|
||||||
|
&wsaData);
|
||||||
|
if (Ret != 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
Sock = WSASocket(AF_INET,
|
||||||
|
SOCK_DGRAM,
|
||||||
|
IPPROTO_UDP,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
WSA_FLAG_OVERLAPPED);
|
||||||
|
if (Sock == INVALID_SOCKET )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* setup client socket */
|
||||||
|
ZeroMemory(&myAddr, sizeof(myAddr));
|
||||||
|
myAddr.sin_family = AF_INET;
|
||||||
|
myAddr.sin_port = htons(IPPORT_TIMESERVER);
|
||||||
|
myAddr.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
|
||||||
|
Ret = bind(Sock,
|
||||||
|
(SOCKADDR *)&myAddr,
|
||||||
|
sizeof(SOCKADDR));
|
||||||
|
if (Ret == SOCKET_ERROR)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* setup server socket */
|
||||||
|
ZeroMemory(&ntpAddr, sizeof(ntpAddr));
|
||||||
|
ntpAddr.sin_family = AF_INET;
|
||||||
|
ntpAddr.sin_port = htons(IPPORT_TIMESERVER);
|
||||||
|
ntpAddr.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID DestroyConnection()
|
||||||
|
{
|
||||||
|
WSACleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* send some data to wake the server up */
|
||||||
|
BOOL SendData()
|
||||||
|
{
|
||||||
|
CHAR Packet[] = "";
|
||||||
|
INT Ret;
|
||||||
|
|
||||||
|
Ret = sendto(Sock,
|
||||||
|
Packet,
|
||||||
|
sizeof(Packet),
|
||||||
|
0,
|
||||||
|
(SOCKADDR *)&myAddr,
|
||||||
|
sizeof(SOCKADDR_IN));
|
||||||
|
|
||||||
|
if (Ret == SOCKET_ERROR)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL RecieveData(CHAR *Buf)
|
||||||
|
{
|
||||||
|
INT Ret;
|
||||||
|
INT Size = sizeof(SOCKADDR_IN);
|
||||||
|
|
||||||
|
Ret = recvfrom(Sock,
|
||||||
|
Buf,
|
||||||
|
BUFSIZE,
|
||||||
|
0,
|
||||||
|
(SOCKADDR *)&ntpAddr,
|
||||||
|
&Size);
|
||||||
|
if (Ret == SOCKET_ERROR)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
|
@ -20,6 +20,8 @@
|
||||||
#define IDC_AUTOSYNC 123
|
#define IDC_AUTOSYNC 123
|
||||||
#define IDC_SUCSYNC 126
|
#define IDC_SUCSYNC 126
|
||||||
#define IDC_NEXTSYNC 127
|
#define IDC_NEXTSYNC 127
|
||||||
|
#define IDC_SERVERTEXT 128
|
||||||
|
#define IDC_CLOCK 129
|
||||||
|
|
||||||
#define IDS_CPLNAME 1001
|
#define IDS_CPLNAME 1001
|
||||||
#define IDS_CPLDESCRIPTION 1002
|
#define IDS_CPLDESCRIPTION 1002
|
||||||
|
|
|
@ -5,18 +5,11 @@
|
||||||
* PURPOSE: ReactOS Timedate Control Panel
|
* PURPOSE: ReactOS Timedate Control Panel
|
||||||
* COPYRIGHT: Copyright 2004-2005 Eric Kohl
|
* COPYRIGHT: Copyright 2004-2005 Eric Kohl
|
||||||
* Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
|
* Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <cpl.h>
|
|
||||||
|
|
||||||
#include "resource.h"
|
|
||||||
#include "timedate.h"
|
#include "timedate.h"
|
||||||
|
|
||||||
#define SERVERLISTSIZE 6
|
|
||||||
|
|
||||||
typedef struct _TZ_INFO
|
typedef struct _TZ_INFO
|
||||||
{
|
{
|
||||||
LONG Bias;
|
LONG Bias;
|
||||||
|
@ -44,7 +37,7 @@ typedef struct _SERVERS
|
||||||
} SERVERS;
|
} SERVERS;
|
||||||
|
|
||||||
|
|
||||||
#define NUM_APPLETS (1)
|
#define NUM_APPLETS (1)
|
||||||
|
|
||||||
LONG APIENTRY
|
LONG APIENTRY
|
||||||
Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam);
|
Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam);
|
||||||
|
@ -58,7 +51,7 @@ PTIMEZONE_ENTRY TimeZoneListTail = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* Applets */
|
/* Applets */
|
||||||
APPLET Applets[NUM_APPLETS] =
|
APPLET Applets[NUM_APPLETS] =
|
||||||
{
|
{
|
||||||
{IDC_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, Applet}
|
{IDC_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, Applet}
|
||||||
};
|
};
|
||||||
|
@ -100,7 +93,7 @@ SetTimeZoneName(HWND hwnd)
|
||||||
|
|
||||||
TimeZoneId = GetTimeZoneInformation(&TimeZoneInfo);
|
TimeZoneId = GetTimeZoneInformation(&TimeZoneInfo);
|
||||||
|
|
||||||
LoadString(hApplet, IDS_TIMEZONETEXT, TimeZoneText, 128);
|
LoadStringW(hApplet, IDS_TIMEZONETEXT, TimeZoneText, 128);
|
||||||
|
|
||||||
switch (TimeZoneId)
|
switch (TimeZoneId)
|
||||||
{
|
{
|
||||||
|
@ -113,16 +106,16 @@ SetTimeZoneName(HWND hwnd)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TIME_ZONE_ID_UNKNOWN:
|
case TIME_ZONE_ID_UNKNOWN:
|
||||||
LoadString(hApplet, IDS_TIMEZONEUNKNOWN, TimeZoneName, 128);
|
LoadStringW(hApplet, IDS_TIMEZONEUNKNOWN, TimeZoneName, 128);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TIME_ZONE_ID_INVALID:
|
case TIME_ZONE_ID_INVALID:
|
||||||
default:
|
default:
|
||||||
LoadString(hApplet, IDS_TIMEZONEINVALID, TimeZoneName, 128);
|
LoadStringW(hApplet, IDS_TIMEZONEINVALID, TimeZoneName, 128);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wsprintf(TimeZoneString, TimeZoneText, TimeZoneName);
|
wsprintfW(TimeZoneString, TimeZoneText, TimeZoneName);
|
||||||
SendDlgItemMessageW(hwnd, IDC_TIMEZONE, WM_SETTEXT, 0, (LPARAM)TimeZoneString);
|
SendDlgItemMessageW(hwnd, IDC_TIMEZONE, WM_SETTEXT, 0, (LPARAM)TimeZoneString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,12 +123,25 @@ SetTimeZoneName(HWND hwnd)
|
||||||
/* Property page dialog callback */
|
/* Property page dialog callback */
|
||||||
INT_PTR CALLBACK
|
INT_PTR CALLBACK
|
||||||
DateTimePageProc(HWND hwndDlg,
|
DateTimePageProc(HWND hwndDlg,
|
||||||
UINT uMsg,
|
UINT uMsg,
|
||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
LPARAM lParam)
|
LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
InitClockWindowClass();
|
||||||
|
CreateWindowEx(0,
|
||||||
|
L"ClockWndClass",
|
||||||
|
L"Clock",
|
||||||
|
WS_CHILD | WS_VISIBLE,
|
||||||
|
208, 12, 150, 150,
|
||||||
|
hwndDlg,
|
||||||
|
NULL,
|
||||||
|
hApplet,
|
||||||
|
NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
{
|
{
|
||||||
LPNMHDR lpnm = (LPNMHDR)lParam;
|
LPNMHDR lpnm = (LPNMHDR)lParam;
|
||||||
|
@ -179,7 +185,7 @@ GetLargerTimeZoneEntry(DWORD Index)
|
||||||
while (Entry != NULL)
|
while (Entry != NULL)
|
||||||
{
|
{
|
||||||
if (Entry->Index >= Index)
|
if (Entry->Index >= Index)
|
||||||
return Entry;
|
return Entry;
|
||||||
|
|
||||||
Entry = Entry->Next;
|
Entry = Entry->Next;
|
||||||
}
|
}
|
||||||
|
@ -203,10 +209,10 @@ CreateTimeZoneList(VOID)
|
||||||
PTIMEZONE_ENTRY Current;
|
PTIMEZONE_ENTRY Current;
|
||||||
|
|
||||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
|
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
|
||||||
0,
|
0,
|
||||||
KEY_ALL_ACCESS,
|
KEY_ALL_ACCESS,
|
||||||
&hZonesKey))
|
&hZonesKey))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dwIndex = 0;
|
dwIndex = 0;
|
||||||
|
@ -214,131 +220,131 @@ CreateTimeZoneList(VOID)
|
||||||
{
|
{
|
||||||
dwNameSize = 256;
|
dwNameSize = 256;
|
||||||
lError = RegEnumKeyExW(hZonesKey,
|
lError = RegEnumKeyExW(hZonesKey,
|
||||||
dwIndex,
|
dwIndex,
|
||||||
szKeyName,
|
szKeyName,
|
||||||
&dwNameSize,
|
&dwNameSize,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
if (lError != ERROR_SUCCESS && lError != ERROR_MORE_DATA)
|
if (lError != ERROR_SUCCESS && lError != ERROR_MORE_DATA)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (RegOpenKeyExW(hZonesKey,
|
if (RegOpenKeyExW(hZonesKey,
|
||||||
szKeyName,
|
szKeyName,
|
||||||
0,
|
0,
|
||||||
KEY_ALL_ACCESS,
|
KEY_ALL_ACCESS,
|
||||||
&hZoneKey))
|
&hZoneKey))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Entry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(TIMEZONE_ENTRY));
|
Entry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(TIMEZONE_ENTRY));
|
||||||
if (Entry == NULL)
|
if (Entry == NULL)
|
||||||
{
|
{
|
||||||
RegCloseKey(hZoneKey);
|
RegCloseKey(hZoneKey);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwValueSize = 64 * sizeof(WCHAR);
|
dwValueSize = 64 * sizeof(WCHAR);
|
||||||
if (RegQueryValueExW(hZoneKey,
|
if (RegQueryValueExW(hZoneKey,
|
||||||
L"Display",
|
L"Display",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(LPBYTE)&Entry->Description,
|
(LPBYTE)&Entry->Description,
|
||||||
&dwValueSize))
|
&dwValueSize))
|
||||||
{
|
{
|
||||||
RegCloseKey(hZoneKey);
|
RegCloseKey(hZoneKey);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwValueSize = 32 * sizeof(WCHAR);
|
dwValueSize = 32 * sizeof(WCHAR);
|
||||||
if (RegQueryValueExW(hZoneKey,
|
if (RegQueryValueExW(hZoneKey,
|
||||||
L"Std",
|
L"Std",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(LPBYTE)&Entry->StandardName,
|
(LPBYTE)&Entry->StandardName,
|
||||||
&dwValueSize))
|
&dwValueSize))
|
||||||
{
|
{
|
||||||
RegCloseKey(hZoneKey);
|
RegCloseKey(hZoneKey);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwValueSize = 32 * sizeof(WCHAR);
|
dwValueSize = 32 * sizeof(WCHAR);
|
||||||
if (RegQueryValueExW(hZoneKey,
|
if (RegQueryValueExW(hZoneKey,
|
||||||
L"Dlt",
|
L"Dlt",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(LPBYTE)&Entry->DaylightName,
|
(LPBYTE)&Entry->DaylightName,
|
||||||
&dwValueSize))
|
&dwValueSize))
|
||||||
{
|
{
|
||||||
RegCloseKey(hZoneKey);
|
RegCloseKey(hZoneKey);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwValueSize = sizeof(DWORD);
|
dwValueSize = sizeof(DWORD);
|
||||||
if (RegQueryValueExW(hZoneKey,
|
if (RegQueryValueExW(hZoneKey,
|
||||||
L"Index",
|
L"Index",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(LPBYTE)&Entry->Index,
|
(LPBYTE)&Entry->Index,
|
||||||
&dwValueSize))
|
&dwValueSize))
|
||||||
{
|
{
|
||||||
RegCloseKey(hZoneKey);
|
RegCloseKey(hZoneKey);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwValueSize = sizeof(TZ_INFO);
|
dwValueSize = sizeof(TZ_INFO);
|
||||||
if (RegQueryValueExW(hZoneKey,
|
if (RegQueryValueExW(hZoneKey,
|
||||||
L"TZI",
|
L"TZI",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(LPBYTE)&Entry->TimezoneInfo,
|
(LPBYTE)&Entry->TimezoneInfo,
|
||||||
&dwValueSize))
|
&dwValueSize))
|
||||||
{
|
{
|
||||||
RegCloseKey(hZoneKey);
|
RegCloseKey(hZoneKey);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hZoneKey);
|
RegCloseKey(hZoneKey);
|
||||||
|
|
||||||
if (TimeZoneListHead == NULL &&
|
if (TimeZoneListHead == NULL &&
|
||||||
TimeZoneListTail == NULL)
|
TimeZoneListTail == NULL)
|
||||||
{
|
{
|
||||||
Entry->Prev = NULL;
|
Entry->Prev = NULL;
|
||||||
Entry->Next = NULL;
|
Entry->Next = NULL;
|
||||||
TimeZoneListHead = Entry;
|
TimeZoneListHead = Entry;
|
||||||
TimeZoneListTail = Entry;
|
TimeZoneListTail = Entry;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Current = GetLargerTimeZoneEntry(Entry->Index);
|
Current = GetLargerTimeZoneEntry(Entry->Index);
|
||||||
if (Current != NULL)
|
if (Current != NULL)
|
||||||
{
|
{
|
||||||
if (Current == TimeZoneListHead)
|
if (Current == TimeZoneListHead)
|
||||||
{
|
{
|
||||||
/* Prepend to head */
|
/* Prepend to head */
|
||||||
Entry->Prev = NULL;
|
Entry->Prev = NULL;
|
||||||
Entry->Next = TimeZoneListHead;
|
Entry->Next = TimeZoneListHead;
|
||||||
TimeZoneListHead->Prev = Entry;
|
TimeZoneListHead->Prev = Entry;
|
||||||
TimeZoneListHead = Entry;
|
TimeZoneListHead = Entry;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Insert before current */
|
/* Insert before current */
|
||||||
Entry->Prev = Current->Prev;
|
Entry->Prev = Current->Prev;
|
||||||
Entry->Next = Current;
|
Entry->Next = Current;
|
||||||
Current->Prev->Next = Entry;
|
Current->Prev->Next = Entry;
|
||||||
Current->Prev = Entry;
|
Current->Prev = Entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Append to tail */
|
/* Append to tail */
|
||||||
Entry->Prev = TimeZoneListTail;
|
Entry->Prev = TimeZoneListTail;
|
||||||
Entry->Next = NULL;
|
Entry->Next = NULL;
|
||||||
TimeZoneListTail->Next = Entry;
|
TimeZoneListTail->Next = Entry;
|
||||||
TimeZoneListTail = Entry;
|
TimeZoneListTail = Entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dwIndex++;
|
dwIndex++;
|
||||||
}
|
}
|
||||||
|
@ -358,9 +364,9 @@ DestroyTimeZoneList(VOID)
|
||||||
|
|
||||||
TimeZoneListHead = Entry->Next;
|
TimeZoneListHead = Entry->Next;
|
||||||
if (TimeZoneListHead != NULL)
|
if (TimeZoneListHead != NULL)
|
||||||
{
|
{
|
||||||
TimeZoneListHead->Prev = NULL;
|
TimeZoneListHead->Prev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, Entry);
|
HeapFree(GetProcessHeap(), 0, Entry);
|
||||||
}
|
}
|
||||||
|
@ -385,21 +391,21 @@ ShowTimeZoneList(HWND hwnd)
|
||||||
while (Entry != NULL)
|
while (Entry != NULL)
|
||||||
{
|
{
|
||||||
SendMessageW(hwnd,
|
SendMessageW(hwnd,
|
||||||
CB_ADDSTRING,
|
CB_ADDSTRING,
|
||||||
0,
|
0,
|
||||||
(LPARAM)Entry->Description);
|
(LPARAM)Entry->Description);
|
||||||
|
|
||||||
if (!wcscmp(Entry->StandardName, TimeZoneInfo.StandardName))
|
if (!wcscmp(Entry->StandardName, TimeZoneInfo.StandardName))
|
||||||
dwIndex = i;
|
dwIndex = i;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
Entry = Entry->Next;
|
Entry = Entry->Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendMessageW(hwnd,
|
SendMessageW(hwnd,
|
||||||
CB_SETCURSEL,
|
CB_SETCURSEL,
|
||||||
(WPARAM)dwIndex,
|
(WPARAM)dwIndex,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -412,36 +418,36 @@ SetLocalTimeZone(HWND hwnd)
|
||||||
DWORD i;
|
DWORD i;
|
||||||
|
|
||||||
dwIndex = SendMessage(hwnd,
|
dwIndex = SendMessage(hwnd,
|
||||||
CB_GETCURSEL,
|
CB_GETCURSEL,
|
||||||
0,
|
0,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
Entry = TimeZoneListHead;
|
Entry = TimeZoneListHead;
|
||||||
while (i < dwIndex)
|
while (i < dwIndex)
|
||||||
{
|
{
|
||||||
if (Entry == NULL)
|
if (Entry == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
Entry = Entry->Next;
|
Entry = Entry->Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
wcscpy(TimeZoneInformation.StandardName,
|
wcscpy(TimeZoneInformation.StandardName,
|
||||||
Entry->StandardName);
|
Entry->StandardName);
|
||||||
wcscpy(TimeZoneInformation.DaylightName,
|
wcscpy(TimeZoneInformation.DaylightName,
|
||||||
Entry->DaylightName);
|
Entry->DaylightName);
|
||||||
|
|
||||||
TimeZoneInformation.Bias = Entry->TimezoneInfo.Bias;
|
TimeZoneInformation.Bias = Entry->TimezoneInfo.Bias;
|
||||||
TimeZoneInformation.StandardBias = Entry->TimezoneInfo.StandardBias;
|
TimeZoneInformation.StandardBias = Entry->TimezoneInfo.StandardBias;
|
||||||
TimeZoneInformation.DaylightBias = Entry->TimezoneInfo.DaylightBias;
|
TimeZoneInformation.DaylightBias = Entry->TimezoneInfo.DaylightBias;
|
||||||
|
|
||||||
memcpy(&TimeZoneInformation.StandardDate,
|
memcpy(&TimeZoneInformation.StandardDate,
|
||||||
&Entry->TimezoneInfo.StandardDate,
|
&Entry->TimezoneInfo.StandardDate,
|
||||||
sizeof(SYSTEMTIME));
|
sizeof(SYSTEMTIME));
|
||||||
memcpy(&TimeZoneInformation.DaylightDate,
|
memcpy(&TimeZoneInformation.DaylightDate,
|
||||||
&Entry->TimezoneInfo.DaylightDate,
|
&Entry->TimezoneInfo.DaylightDate,
|
||||||
sizeof(SYSTEMTIME));
|
sizeof(SYSTEMTIME));
|
||||||
|
|
||||||
/* Set time zone information */
|
/* Set time zone information */
|
||||||
SetTimeZoneInformation(&TimeZoneInformation);
|
SetTimeZoneInformation(&TimeZoneInformation);
|
||||||
|
@ -454,18 +460,18 @@ GetAutoDaylightInfo(HWND hwnd)
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
|
|
||||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
L"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
|
L"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
|
||||||
0,
|
0,
|
||||||
KEY_QUERY_VALUE,
|
KEY_QUERY_VALUE,
|
||||||
&hKey))
|
&hKey))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (RegQueryValueExW(hKey,
|
if (RegQueryValueExW(hKey,
|
||||||
L"DisableAutoDaylightTimeSet",
|
L"DisableAutoDaylightTimeSet",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL))
|
NULL))
|
||||||
{
|
{
|
||||||
SendMessage(hwnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
|
SendMessage(hwnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
|
||||||
}
|
}
|
||||||
|
@ -485,25 +491,25 @@ SetAutoDaylightInfo(HWND hwnd)
|
||||||
DWORD dwValue = 1;
|
DWORD dwValue = 1;
|
||||||
|
|
||||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
L"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
|
L"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
|
||||||
0,
|
0,
|
||||||
KEY_SET_VALUE,
|
KEY_SET_VALUE,
|
||||||
&hKey))
|
&hKey))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (SendMessage(hwnd, BM_GETCHECK, 0, 0) == BST_UNCHECKED)
|
if (SendMessage(hwnd, BM_GETCHECK, 0, 0) == BST_UNCHECKED)
|
||||||
{
|
{
|
||||||
RegSetValueExW(hKey,
|
RegSetValueExW(hKey,
|
||||||
L"DisableAutoDaylightTimeSet",
|
L"DisableAutoDaylightTimeSet",
|
||||||
0,
|
0,
|
||||||
REG_DWORD,
|
REG_DWORD,
|
||||||
(LPBYTE)&dwValue,
|
(LPBYTE)&dwValue,
|
||||||
sizeof(DWORD));
|
sizeof(DWORD));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RegDeleteValueW(hKey,
|
RegDeleteValueW(hKey,
|
||||||
L"DisableAutoDaylightTimeSet");
|
L"DisableAutoDaylightTimeSet");
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
|
@ -513,9 +519,9 @@ SetAutoDaylightInfo(HWND hwnd)
|
||||||
/* Property page dialog callback */
|
/* Property page dialog callback */
|
||||||
INT_PTR CALLBACK
|
INT_PTR CALLBACK
|
||||||
TimeZonePageProc(HWND hwndDlg,
|
TimeZonePageProc(HWND hwndDlg,
|
||||||
UINT uMsg,
|
UINT uMsg,
|
||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
LPARAM lParam)
|
LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
|
@ -578,30 +584,31 @@ CreateNTPServerList(HWND hwnd)
|
||||||
LONG Ret;
|
LONG Ret;
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
|
|
||||||
hList = GetDlgItem(hwnd, IDC_SERVERLIST);
|
hList = GetDlgItem(hwnd,
|
||||||
|
IDC_SERVERLIST);
|
||||||
|
|
||||||
Ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
Ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers",
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers",
|
||||||
0,
|
0,
|
||||||
KEY_READ,
|
KEY_READ,
|
||||||
&hKey);
|
&hKey);
|
||||||
if (Ret != ERROR_SUCCESS)
|
if (Ret != ERROR_SUCCESS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
ValSize = MAX_VALUE_NAME;
|
ValSize = MAX_VALUE_NAME;
|
||||||
ValName[0] = '\0';
|
ValName[0] = '\0';
|
||||||
Ret = RegEnumValue(hKey,
|
Ret = RegEnumValueW(hKey,
|
||||||
Index,
|
Index,
|
||||||
ValName,
|
ValName,
|
||||||
&ValSize,
|
&ValSize,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(LPBYTE)Data,
|
(LPBYTE)Data,
|
||||||
&dwNameSize);
|
&dwNameSize);
|
||||||
|
|
||||||
if (Ret == ERROR_SUCCESS)
|
if (Ret == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (wcscmp(ValName, L"") == 0)
|
if (wcscmp(ValName, L"") == 0)
|
||||||
{
|
{
|
||||||
|
@ -610,7 +617,10 @@ CreateNTPServerList(HWND hwnd)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SendMessageW(hList, CB_ADDSTRING, 0, (LPARAM)Data);
|
SendMessageW(hList,
|
||||||
|
CB_ADDSTRING,
|
||||||
|
0,
|
||||||
|
(LPARAM)Data);
|
||||||
Index++;
|
Index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -621,60 +631,131 @@ CreateNTPServerList(HWND hwnd)
|
||||||
if (Default < 1 || Default > Index)
|
if (Default < 1 || Default > Index)
|
||||||
Default = 1;
|
Default = 1;
|
||||||
|
|
||||||
SendMessage(hList, CB_SETCURSEL, --Default, 0);
|
SendMessage(hList,
|
||||||
|
CB_SETCURSEL,
|
||||||
|
--Default,
|
||||||
|
0);
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID SetNTPServer(HWND hwnd)
|
||||||
|
{
|
||||||
|
HKEY hKey;
|
||||||
|
HWND hList;
|
||||||
|
INT Sel;
|
||||||
|
WCHAR szSel[4];
|
||||||
|
LONG Ret;
|
||||||
|
//DebugBreak();
|
||||||
|
hList = GetDlgItem(hwnd,
|
||||||
|
IDC_SERVERLIST);
|
||||||
|
|
||||||
|
Sel = (INT)SendMessage(hList,
|
||||||
|
CB_GETCURSEL,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
|
||||||
|
_itow(Sel, szSel, 10);
|
||||||
|
|
||||||
|
Ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers",
|
||||||
|
0,
|
||||||
|
KEY_READ,
|
||||||
|
&hKey);
|
||||||
|
if (Ret != ERROR_SUCCESS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Ret = RegSetValueExW(hKey,
|
||||||
|
L"",
|
||||||
|
0,
|
||||||
|
REG_SZ,
|
||||||
|
(LPBYTE)szSel,
|
||||||
|
sizeof(szSel));
|
||||||
|
if (Ret == ERROR_SUCCESS)
|
||||||
|
MessageBox(NULL, szSel, NULL, 0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WCHAR Buff[20];
|
||||||
|
_itow(Ret, Buff, 10);
|
||||||
|
//MessageBox(NULL, Buff, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID UpdateSystemTime(HWND hwndDlg)
|
||||||
|
{
|
||||||
|
//SYSTEMTIME systime;
|
||||||
|
CHAR Buf[BUFSIZE];
|
||||||
|
|
||||||
|
InitialiseConnection();
|
||||||
|
SendData();
|
||||||
|
RecieveData(Buf);
|
||||||
|
DestroyConnection();
|
||||||
|
|
||||||
|
//DateTime_SetSystemtime(hwndDlg, 0, systime);
|
||||||
|
}
|
||||||
|
|
||||||
/* Property page dialog callback */
|
/* Property page dialog callback */
|
||||||
INT_PTR CALLBACK
|
INT_PTR CALLBACK
|
||||||
InetTimePageProc(HWND hwndDlg,
|
InetTimePageProc(HWND hwndDlg,
|
||||||
UINT uMsg,
|
UINT uMsg,
|
||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
LPARAM lParam)
|
LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
|
||||||
HWND hCheck;
|
|
||||||
INT Check;
|
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
CreateNTPServerList(hwndDlg);
|
CreateNTPServerList(hwndDlg);
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch(LOWORD(wParam))
|
switch(LOWORD(wParam))
|
||||||
{
|
{
|
||||||
case IDC_UPDATEBUTTON:
|
case IDC_UPDATEBUTTON:
|
||||||
MessageBox(NULL, L"Boo!", NULL, 0);
|
SetNTPServer(hwndDlg);
|
||||||
break;
|
//UpdateSystemTime(hwndDlg);
|
||||||
|
MessageBox(NULL, L"Not yet implemented", NULL, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
case IDC_SERVERLIST:
|
case IDC_SERVERLIST:
|
||||||
if (HIWORD(wParam) == CBN_SELCHANGE)
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
||||||
/* Enable the 'Apply' button */
|
/* Enable the 'Apply' button */
|
||||||
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_AUTOSYNC:
|
case IDC_AUTOSYNC:
|
||||||
if (HIWORD(wParam) == BN_CLICKED)
|
if (HIWORD(wParam) == BN_CLICKED)
|
||||||
{
|
{
|
||||||
hCheck = GetDlgItem(hwndDlg, IDC_AUTOSYNC);
|
HWND hCheck = GetDlgItem(hwndDlg, IDC_AUTOSYNC);
|
||||||
Check = (INT)SendMessageW(hCheck, BM_GETCHECK, 0, 0);
|
//HWND hSerText = GetDlgItem(hwndDlg, IDC_SERVERTEXT);
|
||||||
bSynced = (Check) ? TRUE : FALSE;
|
//HWND hSerList = GetDlgItem(hwndDlg, IDC_SERVERLIST);
|
||||||
|
//HWND hUpdateBut = GetDlgItem(hwndDlg, IDC_UPDATEBUTTON);
|
||||||
|
//HWND hSucSync = GetDlgItem(hwndDlg, IDC_SUCSYNC);
|
||||||
|
//HWND hNextSync = GetDlgItem(hwndDlg, IDC_NEXTSYNC);
|
||||||
|
|
||||||
|
INT Check = (INT)SendMessageW(hCheck, BM_GETCHECK, 0, 0);
|
||||||
|
if (Check)
|
||||||
|
;//show all data
|
||||||
|
else
|
||||||
|
;//hide all data
|
||||||
|
|
||||||
/* Enable the 'Apply' button */
|
/* Enable the 'Apply' button */
|
||||||
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
{
|
{
|
||||||
|
@ -684,11 +765,8 @@ InetTimePageProc(HWND hwndDlg,
|
||||||
{
|
{
|
||||||
case PSN_APPLY:
|
case PSN_APPLY:
|
||||||
//DebugBreak();
|
//DebugBreak();
|
||||||
|
SetNTPServer(hwndDlg);
|
||||||
/* SetNTPServer(GetDlgItem(hwndDlg, IDC_SERVERLIST));
|
|
||||||
SetLocalTimeZone(GetDlgItem(hwndDlg, IDC_TIMEZONELIST));
|
|
||||||
SetWindowLong(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR);
|
|
||||||
*/
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -745,12 +823,12 @@ Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam)
|
||||||
/* Control Panel Callback */
|
/* Control Panel Callback */
|
||||||
LONG CALLBACK
|
LONG CALLBACK
|
||||||
CPlApplet(HWND hwndCpl,
|
CPlApplet(HWND hwndCpl,
|
||||||
UINT uMsg,
|
UINT uMsg,
|
||||||
LPARAM lParam1,
|
LPARAM lParam1,
|
||||||
LPARAM lParam2)
|
LPARAM lParam2)
|
||||||
{
|
{
|
||||||
int i = (int)lParam1;
|
int i = (int)lParam1;
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case CPL_INIT:
|
case CPL_INIT:
|
||||||
|
@ -781,20 +859,20 @@ CPlApplet(HWND hwndCpl,
|
||||||
|
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
DllMain(HINSTANCE hinstDLL,
|
DllMain(HINSTANCE hinstDLL,
|
||||||
DWORD dwReason,
|
DWORD dwReason,
|
||||||
LPVOID lpReserved)
|
LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
switch (dwReason)
|
switch (dwReason)
|
||||||
{
|
{
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
{
|
{
|
||||||
INITCOMMONCONTROLSEX InitControls;
|
INITCOMMONCONTROLSEX InitControls;
|
||||||
|
|
||||||
InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||||
InitControls.dwICC = ICC_DATE_CLASSES | ICC_PROGRESS_CLASS | ICC_UPDOWN_CLASS;
|
InitControls.dwICC = ICC_DATE_CLASSES | ICC_PROGRESS_CLASS | ICC_UPDOWN_CLASS;
|
||||||
InitCommonControlsEx(&InitControls);
|
InitCommonControlsEx(&InitControls);
|
||||||
|
|
||||||
hApplet = hinstDLL;
|
hApplet = hinstDLL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,20 @@
|
||||||
#ifndef __CPL_SAMPLE_H
|
#ifndef __CPL_SAMPLE_H
|
||||||
#define __CPL_SAMPLE_H
|
#define __CPL_SAMPLE_H
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <commctrl.h>
|
||||||
|
#include <cpl.h>
|
||||||
|
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define SERVERLISTSIZE 6
|
||||||
|
#define BUFSIZE 1024
|
||||||
|
#define MYPORT 6
|
||||||
|
#define NTPPORT 6
|
||||||
|
#define ID_TIMER 1
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int idIcon;
|
int idIcon;
|
||||||
|
@ -11,6 +25,18 @@ typedef struct
|
||||||
|
|
||||||
extern HINSTANCE hApplet;
|
extern HINSTANCE hApplet;
|
||||||
|
|
||||||
|
BOOL InitClockWindowClass();
|
||||||
|
|
||||||
|
BOOL InitialiseConnection(VOID);
|
||||||
|
VOID DestroyConnection(VOID);
|
||||||
|
BOOL SendData(VOID);
|
||||||
|
BOOL RecieveData(CHAR *);
|
||||||
|
|
||||||
|
VOID SetIsotropic (HDC hdc, INT cxClient, INT cyClient);
|
||||||
|
VOID RotatePoint (POINT pt[], INT iNum, INT iAngle);
|
||||||
|
VOID DrawClock (HDC hdc);
|
||||||
|
VOID DrawHands (HDC hdc, SYSTEMTIME * pst, BOOL fChange);
|
||||||
|
|
||||||
#endif /* __CPL_SAMPLE_H */
|
#endif /* __CPL_SAMPLE_H */
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -9,8 +9,12 @@
|
||||||
<define name="_WIN32_WINNT">0x501</define>
|
<define name="_WIN32_WINNT">0x501</define>
|
||||||
<library>kernel32</library>
|
<library>kernel32</library>
|
||||||
<library>user32</library>
|
<library>user32</library>
|
||||||
|
<library>gdi32</library>
|
||||||
<library>comctl32</library>
|
<library>comctl32</library>
|
||||||
|
<library>ws2_32</library>
|
||||||
<library>iphlpapi</library>
|
<library>iphlpapi</library>
|
||||||
|
<file>ntpclient.c</file>
|
||||||
|
<file>clock.c</file>
|
||||||
<file>timedate.c</file>
|
<file>timedate.c</file>
|
||||||
<file>timedate.rc</file>
|
<file>timedate.rc</file>
|
||||||
</module>
|
</module>
|
||||||
|
|
Loading…
Reference in a new issue