aboutsummaryrefslogtreecommitdiff
path: root/c/main.c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-04-04 21:46:19 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-04-04 21:46:19 +0200
commit9d133477d51dd0271d63520071cdf7a11e71c605 (patch)
tree4d4853a5e587e6bcd36abb86484846c004f9ba99 /c/main.c
parenteaab4e3cf5f5e1c2c4c4e41b91082ea76052122c (diff)
downloadEpisodeBrowser-9d133477d51dd0271d63520071cdf7a11e71c605.tar.gz
Use file-local instead of function-local static variables.
This pollutes the global scope, but it removes the unnecessary check that is otherwise done every time the function is called.
Diffstat (limited to 'c/main.c')
-rw-r--r--c/main.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/c/main.c b/c/main.c
index 2c69d70..b40bb83 100644
--- a/c/main.c
+++ b/c/main.c
@@ -12,6 +12,8 @@ HMENU HPopupMenu;
HWND HFocus;
HWND HWnd;
int IDPI = -1;
+static int BThemes;
+static int CxVScroll;
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
static int Attach(void);
@@ -23,14 +25,20 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, INT nCmdShow)
{
char *argv[2];
+ HMODULE hModule;
HWND hWnd;
LPTSTR tszErr;
MSG msg;
INITCOMMONCONTROLSEX icc;
WNDCLASSEX wc;
- /* Initialize Prolog. */
+ /* Set constant globals. */
+ hModule = LoadLibrary(TEXT("uxtheme.dll"));
+ BThemes = hModule && GetProcAddress(hModule,"SetWindowTheme");
+ if (hModule) FreeLibrary(hModule);
+ CxVScroll = GetSystemMetrics(SM_CXVSCROLL);
+ /* Initialize Prolog. */
argv[0] = "EpisodeBrowser";
argv[1] = NULL;
tszErr = TEXT("Could not initialize Prolog.");
@@ -39,7 +47,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
if (!Attach()) goto f;
/* Initialize common controls, load menu and register window class. */
-
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_WIN95_CLASSES;
tszErr = TEXT("Could not initialize common controls.");
@@ -62,7 +69,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
if (!RegisterClassEx(&wc)) goto f;
/* Create window. */
-
hWnd = CreateWindowEx(
0,
TEXT("Episode Browser"),
@@ -305,17 +311,14 @@ UpdateLayout()
int cxColumn, cyDlv;
RECT rc;
extern HWND HDlv, HElv;
- static int cxVScroll = 0;
GetClientRect(HWnd, &rc);
- if (!cxVScroll)
- cxVScroll = GetSystemMetrics(SM_CXVSCROLL);
#define SETCOLW(lv) \
ListView_SetColumnWidth(lv, 0, LVSCW_AUTOSIZE); \
cxColumn = ListView_GetColumnWidth(lv, 0)+4; \
ListView_SetColumnWidth(lv, 0, cxColumn); \
- ListView_SetColumnWidth(lv, 1, rc.right-cxColumn-cxVScroll-4);
+ ListView_SetColumnWidth(lv, 1, rc.right-cxColumn-CxVScroll-4);
/* Resize data list view. */
SendMessage(HDlv, WM_SETREDRAW, FALSE, 0);
@@ -341,16 +344,8 @@ UpdateTheme()
LPTSTR tszTheme;
WORD wAction;
extern HWND HElv, HDlv;
- static int bThemes = -1;
-
- if (bThemes == -1) {
- HMODULE hModule;
- hModule = LoadLibrary(TEXT("uxtheme.dll"));
- bThemes = hModule && GetProcAddress(hModule,"SetWindowTheme");
- if (hModule) FreeLibrary(hModule);
- }
- if (!bThemes) return;
+ if (!BThemes) return;
if (IsThemeActive()) {
dwStyle = LVS_EX_DOUBLEBUFFER;
tszTheme = TEXT("Explorer");