aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-09-02 01:21:58 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-09-02 01:21:58 +0200
commitbb9280267bfb78a8d69adea02f5ed7894833b19d (patch)
tree7cda0c2d80afafb046790955711eb5af1582ebdc
parentc624a89b4f1cccfefd60424a3181d76e4692fa4d (diff)
downloadEpisodeBrowser-bb9280267bfb78a8d69adea02f5ed7894833b19d.tar.gz
Improve Windows XP compatibility.
Various bug fixes.
-rw-r--r--Makefile2
-rw-r--r--c/main.cpp17
-rw-r--r--c/win.h6
-rw-r--r--eb.el2
4 files changed, 16 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index cba8b06..d45a2c7 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ VS_TOOLSET ?= v142
VS_PLATFORM ?= x64
ifeq ($(SYSTEM), mingw)
-DIR = $(DIR)
+DIR = b/mingw
OUT = $(DIR)
else ifeq ($(SYSTEM), vs2019)
DIR = b/vs2019-$(VS_TOOLSET)-$(VS_PLATFORM)
diff --git a/c/main.cpp b/c/main.cpp
index 2af8030..203a24d 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -60,8 +60,8 @@ FileView<ElvDataA> g_fvElv(L"elvdata.dat", g_cfg.cEp+128u);
FileView<DlvDataA> g_fvDlv(L"dlvdata.dat", g_cfg.cEp+128u);
/* Optional Windows functions. */
-BOOL (*IsThemeActive)();
-BOOL (*SetWindowTheme)(HWND, const wchar_t*, const wchar_t*);
+BOOL (__stdcall *IsThemeActive)();
+HRESULT (__stdcall *SetWindowTheme)(HWND, const wchar_t*, const wchar_t*);
/* Initialize important global state on parent window creation. */
static void InitializeMainWindow(HWND);
@@ -157,16 +157,21 @@ void InitializeMainWindow(const HWND hWnd)
/* Load normal font. */
if (auto lib = Library::Maybe(L"User32.dll");
lib && lib->GetProcAddress<void>("SystemParametersInfoW")) {
- NONCLIENTMETRICS m = {sizeof(NONCLIENTMETRICS)};
- Require(SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &m, 0));
+ NONCLIENTMETRICSW m = {sizeof(NONCLIENTMETRICSW)};
+
+#if (WINVER >= 0x0600)
+ m.cbSize -= 4;
+#endif
+
+ Require(SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &m, 0));
g_hfNormal = Require(CreateFontIndirectW(&m.lfMessageFont));
} else
g_hfNormal = static_cast<HFONT>(Require(GetStockObject(DEFAULT_GUI_FONT)));
/* Load bold font. */
{
- LOGFONT lf;
- Require(GetObjectW(g_hfNormal, sizeof(LOGFONT), &lf));
+ LOGFONTW lf;
+ Require(GetObjectW(g_hfNormal, sizeof(LOGFONTW), &lf));
lf.lfWeight = FW_BOLD;
g_hfBold = Require(CreateFontIndirectW(&lf));
}
diff --git a/c/win.h b/c/win.h
index 8329f68..1e09c1f 100644
--- a/c/win.h
+++ b/c/win.h
@@ -133,14 +133,14 @@ inline BOOL SetWindowRect(const HWND hWnd, const RECT r)
* uxtheme.dll exists, and otherwise do nothing. */
inline BOOL EBIsThemeActive()
{
- extern BOOL (*IsThemeActive)();
+ extern BOOL (__stdcall *IsThemeActive)();
return IsThemeActive? IsThemeActive(): 0;
}
-inline BOOL EBSetWindowTheme(const HWND hWnd, const wchar_t* const pszSubAppName,
+inline HRESULT EBSetWindowTheme(const HWND hWnd, const wchar_t* const pszSubAppName,
const wchar_t* const pszSubIdList)
{
- extern BOOL (*SetWindowTheme)(HWND, const wchar_t*, const wchar_t*);
+ extern HRESULT (__stdcall *SetWindowTheme)(HWND, const wchar_t*, const wchar_t*);
return SetWindowTheme? SetWindowTheme(hWnd, pszSubAppName, pszSubIdList): 0;
}
diff --git a/eb.el b/eb.el
index 904da3a..7cb79d4 100644
--- a/eb.el
+++ b/eb.el
@@ -263,7 +263,7 @@
(defun eb--exe ()
(cond
((string-equal eb-system "mingw")
- (concat (eb--cmake-path) "b/mingw/EpisodeBrowser.exe"))
+ (concat (eb--cmake-path) "EpisodeBrowser.exe"))
((string-equal eb-system "vs2019")
(concat (eb--cmake-path) eb-vs-config "/EpisodeBrowser.exe"))
(t (error "eb-system `%s' not supported" eb-system))))