Skip to content

Commit

Permalink
Add option to set arrival time to current time
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-misik committed Mar 30, 2020
1 parent 59a98c5 commit 34d8ce0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
28 changes: 26 additions & 2 deletions main_wnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ static BOOL OnRunAtStartup(
return FALSE;
}

/* Ty to write filename of current executable to registry */
/* Try to write filename of current executable to registry */
if (ERROR_SUCCESS != RegSetValueEx(hKey, lpProjectName, 0,
REG_SZ, (LPBYTE)lpExeName, (dwRes + 1) * sizeof(TCHAR)))
{
Expand Down Expand Up @@ -605,6 +605,21 @@ static VOID IsRegisteredToRunAtStartup(
MF_BYCOMMAND | ((lpData->bOnStartup) ? MF_CHECKED : MF_UNCHECKED));
}

/**
* @brief Set arrival time to current time
*
* @param hwnd Main window hadle
*/
static VOID SetArrivalToNow(
HWND hwnd
)
{
SYSTEMTIME now;
GetLocalTime(&now);
SendDlgItemMessage(hwnd, IDC_ARR_TIME, DTM_SETSYSTEMTIME, GDT_VALID,
(LPARAM)(&now));
}

/******************************************************************************/
/* Windows Messages */
/******************************************************************************/
Expand Down Expand Up @@ -644,6 +659,7 @@ static BOOL OnInitDialog(
/* Change arrival time format */
SendDlgItemMessage(hwnd, IDC_ARR_TIME, DTM_SETFORMAT, 0,
(LPARAM)TEXT(WH_TIME_FORMAT));
SetArrivalToNow(hwnd);

/* Create worked hours font */
lpData->hWorkHoursFont = CreateFont(46, 0, 0, 0, FW_BOLD, FALSE, FALSE,
Expand Down Expand Up @@ -825,7 +841,15 @@ static INT_PTR OnMenuAccCommand(
if(bIsMenu)
OnRunAtStartup(hwnd, !(lpData->bOnStartup));
return TRUE;


case IDM_SETARRIVAL:
if(bIsMenu)
{
SetArrivalToNow(hwnd);
UpdateWorkingHours(hwnd, TRUE);
}
return TRUE;

case IDM_EXIT:
DestroyWindow(hwnd);
return TRUE;
Expand Down
11 changes: 6 additions & 5 deletions resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
/* Menus */
#define IDR_MENU 4000
#define IDM_RUNATSTARTUP 4001
#define IDM_EXIT 4002
#define IDM_DBG_WND 4003
#define IDM_LOAD_DEFAULT 4004
#define IDM_RELOAD 4005
#define IDM_ABOUT 4006
#define IDM_SETARRIVAL 4002
#define IDM_EXIT 4003
#define IDM_DBG_WND 4004
#define IDM_LOAD_DEFAULT 4005
#define IDM_RELOAD 4006
#define IDM_ABOUT 4007

#define IDR_TRAY_MENU 4200
#define IDM_SHOWHIDE 4201
Expand Down
2 changes: 2 additions & 0 deletions resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ BEGIN
BEGIN
MENUITEM "&Run at Startup", IDM_RUNATSTARTUP
MENUITEM SEPARATOR
MENUITEM "&Set Arrival to Now", IDM_SETARRIVAL
MENUITEM SEPARATOR
POPUP "Script"
BEGIN
MENUITEM "&Load Default", IDM_LOAD_DEFAULT
Expand Down

0 comments on commit 34d8ce0

Please sign in to comment.