aboutsummaryrefslogtreecommitdiff
path: root/c/main.cpp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-04 16:26:27 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-04 17:25:01 +0200
commit2ac7d06a503b256b290678f5bba158bf7d219bdd (patch)
tree86abdf303f8a3059efbd040c6eae95accf5b432c /c/main.cpp
parent407b6cab4093b3c0ee23412ac07cf83fd9f03b82 (diff)
downloadEpisodeBrowser-2ac7d06a503b256b290678f5bba158bf7d219bdd.tar.gz
Add comments.
Diffstat (limited to 'c/main.cpp')
-rw-r--r--c/main.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/c/main.cpp b/c/main.cpp
index 24dd6da..7dcffa6 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -12,6 +12,10 @@
#include "pl.h"
#include "util.h"
+/* main.cpp defines all global (non-template) variables used in the
+ * program. `extern' is used to access them from other files, when
+ * need be. */
+
/* Looked-up constants. */
int g_dpi = 96;
@@ -47,12 +51,19 @@ char g_limitScreenwriter[64];
BOOL (*IsThemeActive)();
BOOL (*SetWindowTheme)(HWND, LPCWSTR, LPCWSTR);
+/* Initialize important global state on parent window creation. */
static LRESULT CALLBACK CBTProc(int, WPARAM, LPARAM);
+/* Process parent window commands. */
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
+/* Process main menu commands. */
static void HandleMainMenu(HWND, unsigned short);
+/* Process context menu commands. */
static void HandleContextMenu(HWND, unsigned short);
+/* Call Prolog predicate in other thread, if available. */
static void WaitFor(const char*, const char*);
+/* Handle messages to Help > About dialog. */
static INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
+/* Try to style application according to current Windows theme. */
static void UpdateTheme();
void OnTerminate() noexcept
@@ -89,7 +100,7 @@ int WINAPI WinMain(const HINSTANCE hInstance, const HINSTANCE, char* const, cons
std::set_terminate(OnTerminate);
/* Initialize Prolog. */
- char* argv[] = { (char*)"EpisodeBrowser", NULL };
+ char* argv[] = { const_cast<char*>("EpisodeBrowser"), NULL };
if (!PL_initialise(1, argv))
throw std::runtime_error("Could not initialize Prolog.");
if (!Pl("track_episodes","attach") || !Pl("episode_data","attach"))
@@ -367,7 +378,6 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam,
return 0;
}
-/* Process main menu commands. */
void HandleMainMenu(const HWND hWnd, unsigned short command)
{
switch (command) {
@@ -434,7 +444,6 @@ void HandleMainMenu(const HWND hWnd, unsigned short command)
}
}
-/* Process context menu commands. */
void HandleContextMenu(const HWND, unsigned short command)
{
int cNotFound = 0;
@@ -493,7 +502,6 @@ void HandleContextMenu(const HWND, unsigned short command)
}
}
-/* Call Prolog predicate in other thread, if available. */
void WaitFor(const char* mod, const char* pred)
{
static atom_t aThread;
@@ -540,7 +548,6 @@ void WaitFor(const char* mod, const char* pred)
}
}
-/* Handle messages to Help > About dialog. */
INT_PTR CALLBACK AboutDlgProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam, const LPARAM)
{
switch (uMsg) {
@@ -561,7 +568,6 @@ INT_PTR CALLBACK AboutDlgProc(const HWND hWnd, const UINT uMsg, const WPARAM wPa
return TRUE;
}
-/* Try to style application according to current Windows theme. */
void UpdateTheme()
{
if (!IsThemeActive) return;