Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New welcome screen and prevent Spooky View getting transparent #18

Merged
merged 15 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,9 @@ and for preparation of the GUI.
1.0.6 (Nicely spoken release)
- Added Dutch translation
- Added user language to updater request
- Upgrade installer creator from WiX 4.0.0-rc.1 to 4.0.5
- Upgrade installer creator from WiX 4.0.0-rc.1 to 4.0.5

1.0.7 (A warm welcome release)
- Added new welcome screen
- Removed notification area balloons on first start
- Prevent setting transparency on Spooky View itself
35 changes: 0 additions & 35 deletions SpookyView/AppMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ int AppMain::Run()
return FALSE;
}
GetIsWindows8();
GetIsWindows10orNewer();
windowsEnum.CreateHook();
settingsManager = std::make_unique<CRegistrySettingsManager>();
if (!settingsManager->Init())
Expand Down Expand Up @@ -164,37 +163,3 @@ void AppMain::GetIsWindows8()
OutputDebugString(isWindows8 ? _T("Running on Windows 8 or 8.1\r\n") : _T("Not running on Windows 8 or 8.1\r\n"));
#endif
}

void AppMain::GetIsWindows10orNewer()
{
OSVERSIONINFOEX osvi;
DWORDLONG dwlConditionMask = 0;

// Initialize the OSVERSIONINFOEX structure.

ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
osvi.dwMajorVersion = 10;
osvi.dwMinorVersion = 0;
osvi.wServicePackMajor = 0;
osvi.wServicePackMinor = 0;

// Initialize the condition mask.

VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
VER_SET_CONDITION(dwlConditionMask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
VER_SET_CONDITION(dwlConditionMask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL);

// Perform the test.

isWindows10orNewer = VerifyVersionInfo(
&osvi,
VER_MAJORVERSION | VER_MINORVERSION |
VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
dwlConditionMask
);
#ifdef _DEBUG
OutputDebugString(isWindows10orNewer ? _T("Running on Windows 10 or newer\r\n") : _T("Not running on Windows 10 or newer\r\n"));
#endif
}
1 change: 0 additions & 1 deletion SpookyView/AppMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class AppMain
void LoadFunctionAdresses();
void SendAlreadyRunningNotify();
void GetIsWindows8();
void GetIsWindows10orNewer();
};

#endif
17 changes: 15 additions & 2 deletions SpookyView/CDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,23 @@ CDialog::CDialog(HINSTANCE hInstance) : CWnd(hInstance)
{
}

BOOL CDialog::hasInitInstance()
{
return hasInit;
}

BOOL CDialog::InitInstance()
{
SetupDialog();
return Create();
if (!hasInit)
{
SetupDialog();
auto created = Create();
if (created)
{
hasInit = TRUE;
}
}
return hasInit;
}

void CDialog::SetForeground()
Expand Down
2 changes: 2 additions & 0 deletions SpookyView/CDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ class CDialog : protected CWnd
{
public:
CDialog(HINSTANCE hInstance);
BOOL hasInitInstance();
BOOL InitInstance();
void SetForeground();
protected:
LPCTSTR dialogResource;
BOOL hasInit;
virtual BOOL SetupDialog() = 0;
virtual BOOL Create() = 0;
};
Expand Down
97 changes: 97 additions & 0 deletions SpookyView/CIntroDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#include "stdafx.h"
#include "CIntroDialog.h"
#include <WindowsX.h>
#include "ISettingsManager.h"
#include "SpookyView.h"

CIntroDialog::CIntroDialog(HINSTANCE hInstance, HWND hParent) : CModelessDialog(hInstance, hParent)
{
};

BOOL CIntroDialog::SetupDialog()
{
key = IDD_INTRO;
this->dialogResource = MAKEINTRESOURCE(IDD_INTRO);
return TRUE;
}

INT_PTR CALLBACK CIntroDialog::DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
SetupWindow(hDlg);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
case IDCLOSE:
ApplyChoice();
DestroyWindow(hDlg);
return TRUE;
case IDC_BUTTON_INTRO_SETTINGS:
if (!cSettingsDialog)
{
cSettingsDialog = std::make_unique<CSettingsDialog>(this->hInstance, mainHwnd);
}
if (!cSettingsDialog->hasInitInstance())
{
cSettingsDialog->InitInstance();
}
else
{
cSettingsDialog->SetForeground();
}
break;
case IDC_BUTTON_SETUP_APPS:
if (!cSetupDialog)
{
cSetupDialog = std::make_unique<CSetupDialog>(this->hInstance, mainHwnd);
}
if (!cSetupDialog->hasInitInstance())
{
cSetupDialog->InitInstance();
}
else
{
cSetupDialog->SetForeground();
}
break;
}
break;
}
return FALSE;
}

void CIntroDialog::SetupWindow(HWND hDlg)
{
//Set font of header
ZeroMemory(&introFont, sizeof(LOGFONT));
introFont.lfHeight = 20;
introFont.lfWeight = FW_BOLD;
HFONT hFont = CreateFontIndirect(&introFont);
if ((HFONT)0 != hFont)
{
HWND introStaticText = GetDlgItem(hDlg, ID_STATIC_INTRO_TITLE);
SetWindowFont(introStaticText, hFont, TRUE);
}
//Set state of checkbox
HWND skipIntroCheckbox = GetDlgItem(hDlg, IDC_SKIP_INTRO_CHECKBOX);
BOOL skipValue = settingsManager->GetSkipWelcome();
if (skipValue == 1)
{
Button_SetCheck(skipIntroCheckbox, TRUE);
}
}

void CIntroDialog::ApplyChoice()
{
HWND skipIntroCheckbox = GetDlgItem(hWnd, IDC_SKIP_INTRO_CHECKBOX);
settingsManager->SetSkipWelcome(Button_GetCheck(skipIntroCheckbox));
}

void CIntroDialog::setSkipWelcomeCheckbox(BOOL state)
{
HWND skipIntroCheckbox = GetDlgItem(hWnd, IDC_SKIP_INTRO_CHECKBOX);
Button_SetCheck(skipIntroCheckbox, state);
}
19 changes: 19 additions & 0 deletions SpookyView/CIntroDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef CINTRODIALOG_H
#define CINTRODIALOG_H

#include "CModelessDialog.h"

class CIntroDialog :public CModelessDialog
{
public:
CIntroDialog(HINSTANCE hInstance, HWND hParent);
INT_PTR CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void setSkipWelcomeCheckbox(BOOL state);
protected:
BOOL SetupDialog();
LOGFONT introFont;
void SetupWindow(HWND hDlg);
void ApplyChoice();
};

#endif
68 changes: 35 additions & 33 deletions SpookyView/CMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include "Resource.h"
#include "CLimitSingleInstance.h"
#include "CSettingsDialog.h"
#include "CIntroDialog.h"
#include "Defines.h"
#include "UpdateResponse.h"
#include "ISettingsManager.h"
#include "WindowsEnum.h"
#ifdef UNICODE
#include "UnicodeConversion.h"
#endif //UNICODE
#include "SpookyView.h"

const int SINGLE_CLICK_TIMER = 1;

Expand All @@ -25,6 +25,10 @@ BOOL CMainWindow::InitInstance()
{
//Try to create window
BOOL canInit = CWindow::InitInstance(0);
if (canInit)
{
mainHwnd = this->hWnd;
}
return canInit;
}

Expand Down Expand Up @@ -73,6 +77,9 @@ LRESULT CALLBACK CMainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LP
case IDD_ABOUTBOX:
cAboutDialog.reset();
break;
case IDD_INTRO:
cIntroDialog.reset();
break;
}
return FALSE;
#ifdef UNICODE
Expand Down Expand Up @@ -156,7 +163,10 @@ LRESULT CALLBACK CMainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LP
case IDM_SETTINGS:
if (!cSettingsDialog)
{
cSettingsDialog = std::make_unique<CSettingsDialog>(this->hInstance, this->hWnd);
cSettingsDialog = std::make_unique<CSettingsDialog>(this->hInstance, mainHwnd);
}
if (!cSettingsDialog->hasInitInstance())
{
cSettingsDialog->InitInstance();
}
else
Expand All @@ -183,6 +193,21 @@ LRESULT CALLBACK CMainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LP
}
return FALSE;

case IDM_INTRO:
if (!cIntroDialog)
{
cIntroDialog = std::make_unique<CIntroDialog>(this->hInstance, mainHwnd);
}
if (!cIntroDialog->hasInitInstance())
{
cIntroDialog->InitInstance();
}
else
{
cIntroDialog->SetForeground();
}
return false;

case IDM_EXIT:
DestroyWindow(this->hWnd);
return FALSE;
Expand Down Expand Up @@ -226,47 +251,24 @@ void CMainWindow::OpenSetupDialog()
{
if (!cSetupDialog)
{
cSetupDialog = std::make_unique<CSetupDialog>(this->hInstance, this->hWnd);
cSetupDialog->InitInstance();
cSetupDialog = std::make_unique<CSetupDialog>(this->hInstance, mainHwnd);
}
else
{
cSetupDialog->SetForeground();
}
}

void CMainWindow::ShowAlreadyRunningBalloon()
{
TCHAR titleString[100];
TCHAR messageString[100];
LoadString(hInst, IDS_ALREADY_RUNNING, titleString, sizeof(titleString) / sizeof(TCHAR));
if (isWindows10orNewer)
if (!cSetupDialog->hasInitInstance())
{
LoadString(hInst, DS_ALREADY_RUNNING_HINT_WIN10, messageString, sizeof(messageString) / sizeof(TCHAR));
cSetupDialog->InitInstance();
}
else
{
LoadString(hInst, DS_ALREADY_RUNNING_HINT, messageString, sizeof(messageString) / sizeof(TCHAR));
cSetupDialog->SetForeground();
}
cNotifyIcon->ShowBalloon(titleString, messageString);
}

void CMainWindow::CheckIsFirstRun()
{
if (!settingsManager->GetSkipWelcome())
int skipValue = settingsManager->GetSkipWelcome();
if (skipValue == 0 || skipValue == -1)
{
settingsManager->SetSkipWelcome();
TCHAR titleString[100];
TCHAR messageString[100];
LoadString(hInst, IDS_WELCOME_TITLE, titleString, sizeof(titleString) / sizeof(TCHAR));
if (isWindows10orNewer)
{
LoadString(hInst, IDS_WELCOME_MESSAGE_WIN10, messageString, sizeof(messageString) / sizeof(TCHAR));
}
else
{
LoadString(hInst, IDS_WELCOME_MESSAGE, messageString, sizeof(messageString) / sizeof(TCHAR));
}
cNotifyIcon->ShowBalloon(titleString, messageString);
cIntroDialog = std::make_unique<CIntroDialog>(this->hInstance, this->hWnd);
cIntroDialog->InitInstance();
}
}
4 changes: 1 addition & 3 deletions SpookyView/CMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "CWindow.h"
#include "CNotifyIcon.h"
#include "CAbout.h"
#include "CIntroDialog.h"
#include "CSetupDialog.h"
#include "CSettingsDialog.h"
#include <memory>
Expand All @@ -21,16 +22,13 @@ class CMainWindow: public CWindow
void OpenContextMenu();
void OpenSetupDialog();
void CloseWindow();
void ShowAlreadyRunningBalloon();
HMENU GetContextMenu();
//Members
TCHAR pausedString[80];
POINT cursorPos;
BOOL hasDoubleClicked;
std::unique_ptr<CNotifyIcon> cNotifyIcon;
HMENU notifyIconContextMenu;
std::unique_ptr<CSetupDialog> cSetupDialog;
std::unique_ptr<CSettingsDialog> cSettingsDialog;
std::unique_ptr<CAbout> cAboutDialog;
std::unique_ptr<CUpdateAvailableDialog> cUpdateAvailableDialog;
};
Expand Down
Loading