Skip to content

Commit

Permalink
Merge pull request #107 from Stateford/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Stateford authored Aug 17, 2019
2 parents 24a7ff7 + 0c9e225 commit 68bb9cd
Show file tree
Hide file tree
Showing 17 changed files with 476 additions and 91 deletions.
6 changes: 3 additions & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
environment:
vers: "2.1.4"
vers: "2.1.6"
type: "develop"

version: '{branch}/2.1.4.{build}'
version: '{branch}/2.1.6.{build}'

image: Visual Studio 2017
image: Visual Studio 2019

platform:
- x64
Expand Down
11 changes: 6 additions & 5 deletions Display-Lock/Display-Lock.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{293E2BAD-0F56-458B-AF84-718F92CAF6DF}</ProjectGuid>
<RootNamespace>DisplayLock</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down Expand Up @@ -144,6 +144,7 @@
<Manifest Include="resources\DisplayLock.manifest" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="resources\resourceRC.h" />
<ClInclude Include="resources\version.h" />
<ClInclude Include="resources\versionRC.h" />
<ClInclude Include="resources\resource.h" />
Expand Down
181 changes: 134 additions & 47 deletions Display-Lock/DisplayLock.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ WINDOW_VIEW_CONTROLS windowControls = { 0 };
SETTINGS settings = { 0 }; // application settings
ARGS args = {0};
BOOL running = FALSE;
VERSION gVersion = { 0 };
BOOL initalUpdate = FALSE;

// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
Expand All @@ -44,6 +46,7 @@ INT_PTR CALLBACK MainWindow(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP
INT_PTR CALLBACK windowViewProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK settingsViewProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK about(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK updateProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
Expand Down Expand Up @@ -157,11 +160,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

case WM_CREATE:
if (settings.checkUpdateStartup) {
getVersion(&gVersion);
initalUpdate = !compareVersion(&gVersion);
}

CreateDialog(NULL, MAKEINTRESOURCE(IDD_MAIN_VIEW), hWnd, MainWindow);
invokeReadSettings(&settings);
notifyInit(hWnd, &sysTray);
Shell_NotifyIcon(NIM_ADD, &sysTray);
Shell_NotifyIcon(NIM_SETVERSION, &sysTray);

break;

case NOTIFY_MSG:
Expand Down Expand Up @@ -190,63 +199,79 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break;

case WM_COMMAND:
{
int wmId = LOWORD(wParam);
// Parse the menu selections:
// item from submenu in notifications
if (wParam >= SUBMENU_ITEM_BASE && wParam <= (SUBMENU_ITEM_BASE + 100))
{
int wmId = LOWORD(wParam);
// Parse the menu selections:
// item from submenu in notifications
if (wParam >= SUBMENU_ITEM_BASE && wParam <= (SUBMENU_ITEM_BASE + 100))
{
settings.foreground = TRUE;
windowsButtonStart(&windowControls, &args, &running, ((int)wParam - SUBMENU_ITEM_BASE));
settings.foreground = FALSE;
}
settings.foreground = TRUE;
windowsButtonStart(&windowControls, &args, &running, ((int)wParam - SUBMENU_ITEM_BASE));
settings.foreground = FALSE;
}

switch (wmId)
{
case ID_CONTEXTMENU_STOP:
notifyChildWindows(hWnd, IDC_BUTTON_WINDOWS_STOP);
break;
case ID_CONTEXTMENU_SHOWWINDOW:
ShowWindow(hWnd, TRUE);
break;
case ID_CONTEXTMENU_EXIT:
SendMessage(hWnd, WM_CLOSE, 0, 0);
break;
case ID_CONTEXTMENU_SETTINGS_MINIMIZE:
settings.minimize = !settings.minimize;
notifyChildWindows(hWnd, NOTIFY_SETTINGS_CHANGED);
break;
case ID_CONTEXTMENU_SETTINGS_FOREGROUND:
settings.foreground = !settings.foreground;
notifyChildWindows(hWnd, NOTIFY_SETTINGS_CHANGED);
break;
case ID_CONTEXTMENU_SETTINGS_BORDERLESS:
settings.borderless = !settings.borderless;
notifyChildWindows(hWnd, NOTIFY_SETTINGS_CHANGED);
break;
case ID_CONTEXTMENU_SETTINGS_FULLSCREEN:
settings.fullScreen = !settings.fullScreen;
notifyChildWindows(hWnd, NOTIFY_SETTINGS_CHANGED);
break;
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), hWnd, about);
break;
case IDM_EXIT:
{
SendMessage(hWnd, WM_CLOSE, 0, 0);
break;
}
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
switch (wmId)
{
case ID_CONTEXTMENU_STOP:
notifyChildWindows(hWnd, IDC_BUTTON_WINDOWS_STOP);
break;
case ID_CONTEXTMENU_SHOWWINDOW:
ShowWindow(hWnd, TRUE);
break;
case ID_CONTEXTMENU_EXIT:
SendMessage(hWnd, WM_CLOSE, 0, 0);
break;
case ID_CONTEXTMENU_SETTINGS_MINIMIZE:
settings.minimize = !settings.minimize;
notifyChildWindows(hWnd, NOTIFY_SETTINGS_CHANGED);
break;
case ID_CONTEXTMENU_SETTINGS_FOREGROUND:
settings.foreground = !settings.foreground;
notifyChildWindows(hWnd, NOTIFY_SETTINGS_CHANGED);
break;
case ID_CONTEXTMENU_SETTINGS_BORDERLESS:
settings.borderless = !settings.borderless;
notifyChildWindows(hWnd, NOTIFY_SETTINGS_CHANGED);
break;
case ID_CONTEXTMENU_SETTINGS_FULLSCREEN:
settings.fullScreen = !settings.fullScreen;
notifyChildWindows(hWnd, NOTIFY_SETTINGS_CHANGED);
break;
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), hWnd, about);
break;
case ID_HELP_CHECKFORUPDATES:
{
if (gVersion.verArr[0] == 0)
getVersion(&gVersion);

if(!compareVersion(&gVersion))
DialogBox(hInst, MAKEINTRESOURCE(IDD_UPDATE), hWnd, updateProc);

break;
}
case IDM_EXIT:
{
SendMessage(hWnd, WM_CLOSE, 0, 0);
break;
}
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code that uses hdc here...
EndPaint(hWnd, &ps);

if (initalUpdate)
{
SendMessage(hWnd, WM_COMMAND, LOWORD(ID_HELP_CHECKFORUPDATES), 0);
initalUpdate = FALSE;
}
}
break;
case WM_CLOSE:
Expand Down Expand Up @@ -282,6 +307,7 @@ INT_PTR CALLBACK MainWindow(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPara
// show the default window
ShowWindow(mainWindowControls.windowView, SW_SHOW);
args.controls = mainWindowControls;

return (INT_PTR)TRUE;

case WM_NOTIFY:
Expand Down Expand Up @@ -327,6 +353,7 @@ INT_PTR CALLBACK windowViewProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
initalizeWindowView(hDlg, &menu, &settings, &running, &windowControls, &args);
parent = GetParent(GetParent(GetParent(hDlg)));
args.hWnd = parent;

return (INT_PTR)TRUE;

case WM_COMMAND:
Expand Down Expand Up @@ -386,6 +413,7 @@ INT_PTR CALLBACK settingsViewProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM
settings = previousSettings;
else if ((BOOL)wParam == TRUE)
previousSettings = settings;

break;

case WM_INITDIALOG:
Expand Down Expand Up @@ -422,6 +450,12 @@ INT_PTR CALLBACK settingsViewProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM
settings.minimize = (BOOL)SendMessage(settingsControls.minimize, BM_GETCHECK, 0, 0);
break;

case IDC_CHECK_STARTUP_UPDATES:
EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_SETTINGS_SAVE), TRUE);
settingsControls.settingsChanged = TRUE;
settings.checkUpdateStartup = (BOOL)SendMessage(settingsControls.checkForUpdatesStartup, BM_GETCHECK, 0, 0);
break;

case IDC_HOTKEY:
EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_SETTINGS_SAVE), TRUE);
settingsControls.settingsChanged = TRUE;
Expand Down Expand Up @@ -468,6 +502,59 @@ INT_PTR CALLBACK about(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
//ShellExecuteW(NULL, TEXT("open"), TEXT("https://github.com/idietmoran/Display-Lock"), NULL, NULL, SW_SHOWNORMAL);
break;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}

break;
default:
break;
}
return (INT_PTR)FALSE;
}

INT_PTR CALLBACK updateProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{

UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
{
break;
}
return (INT_PTR)TRUE;

case WM_NOTIFY:

switch (((NMHDR*)lParam)->code)
{
case NM_CLICK:
{
if (wParam == IDC_UPDATE_LINK) {
NMLINK* pNMLink = (NMLINK*)lParam;
LITEM iItem = pNMLink->item;
ShellExecuteW(
NULL,
TEXT("open"),
iItem.szUrl,
NULL,
NULL,
SW_HIDE
);
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
default:
break;
}
break;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
Expand Down
Binary file modified Display-Lock/resources/resource.aps
Binary file not shown.
Binary file modified Display-Lock/resources/resource.h
Binary file not shown.
Binary file modified Display-Lock/resources/resource.rc
Binary file not shown.
19 changes: 19 additions & 0 deletions Display-Lock/resources/resourceRC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by version.rc
//
#define VERSION_MAJOR 0
#define VERSION_MINOR 0
#define VERSION_REVISION 0
#define VERSION_BUILD 0

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Binary file modified Display-Lock/resources/version.aps
Binary file not shown.
Binary file modified Display-Lock/resources/version.rc
Binary file not shown.
Loading

0 comments on commit 68bb9cd

Please sign in to comment.