mirror of
https://github.com/reactos/reactos.git
synced 2025-07-09 10:37:52 +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
7 changed files with 592 additions and 221 deletions
|
@ -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
|
||||||
|
|
|
@ -8,15 +8,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#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;
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +129,19 @@ DateTimePageProc(HWND hwndDlg,
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -578,7 +584,8 @@ 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",
|
||||||
|
@ -592,7 +599,7 @@ CreateNTPServerList(HWND hwnd)
|
||||||
{
|
{
|
||||||
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,
|
||||||
|
@ -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,12 +631,76 @@ 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
|
||||||
|
@ -635,23 +709,20 @@ InetTimePageProc(HWND hwndDlg,
|
||||||
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);
|
||||||
|
//UpdateSystemTime(hwndDlg);
|
||||||
|
MessageBox(NULL, L"Not yet implemented", NULL, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_SERVERLIST:
|
case IDC_SERVERLIST:
|
||||||
|
@ -663,9 +734,19 @@ InetTimePageProc(HWND hwndDlg,
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -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:
|
||||||
|
|
|
@ -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…
Add table
Add a link
Reference in a new issue