aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-26 03:17:09 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-26 03:17:09 +0200
commiteb7709d8617bec27349eebb43e8941b3aaaf453e (patch)
tree7c8627586ed18132b0304b779a00d8acc61e7a0d /c
parenta9a74875dbd5340b6f3ea6d8b6f66a04b360b22a (diff)
downloadEpisodeBrowser-eb7709d8617bec27349eebb43e8941b3aaaf453e.tar.gz
Use FunctionW names explicitly instead of macros.
It's uglier, but it makes Visual Studio show better tooltips.
Diffstat (limited to 'c')
-rw-r--r--c/data.cpp5
-rw-r--r--c/episodelistview.cpp4
-rw-r--r--c/ext.cpp10
-rw-r--r--c/layout.cpp6
-rw-r--r--c/listview.cpp10
-rw-r--r--c/main.cpp34
-rw-r--r--c/win.cpp14
7 files changed, 42 insertions, 41 deletions
diff --git a/c/data.cpp b/c/data.cpp
index 4b8033a..1da1428 100644
--- a/c/data.cpp
+++ b/c/data.cpp
@@ -8,6 +8,7 @@
#include "resource.h"
#include "data.h"
#include "episodelistview.h"
+#include "util.h"
#include "win.h"
struct XmlError : public std::exception
@@ -31,7 +32,7 @@ using XmlXPathContextPtr = Managed<xmlXPathContextPtr, xmlXPathFreeContext, XmlE
using XmlXPathObjectPtr = Managed<xmlXPathObjectPtr, xmlXPathFreeObject, XmlError>;
using XmlCharPtr = Managed<xmlChar*, XmlFree, XmlError>;
-static InternetHandle s_hi = InternetOpen(L"Episode Browser", INTERNET_OPEN_TYPE_DIRECT, nullptr, nullptr, 0);
+static InternetHandle s_hi = InternetOpenW(L"Episode Browser", INTERNET_OPEN_TYPE_DIRECT, nullptr, nullptr, 0);
/* ParsedDoc downloads and parses an HTML document. */
struct ParsedDoc
@@ -45,7 +46,7 @@ struct ParsedDoc
char bufX[1024];
ParsedDoc(const wchar_t* wszUrl, const char* szUrl)
- : hiUrl(InternetOpenUrl(s_hi, wszUrl, nullptr, 0, INTERNET_FLAG_NO_UI, 0)),
+ : hiUrl(InternetOpenUrlW(s_hi, wszUrl, nullptr, 0, INTERNET_FLAG_NO_UI, 0)),
ctxt(htmlCreatePushParserCtxt(nullptr, nullptr, bufX, sizeof(bufX), szUrl, XML_CHAR_ENCODING_UTF8))
{
htmlCtxtUseOptions(ctxt, HTML_PARSE_RECOVER|HTML_PARSE_NOERROR|HTML_PARSE_NOWARNING);
diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp
index 8185b51..071fbce 100644
--- a/c/episodelistview.cpp
+++ b/c/episodelistview.cpp
@@ -387,7 +387,7 @@ void EpisodeListView::Update()
LVITEM lviEpisode = {LVIF_TEXT|LVIF_PARAM};
/* Retrieve episode data and add list view items. */
- SendMessage(hWnd, WM_SETREDRAW, FALSE, 0);
+ SendMessageW(hWnd, WM_SETREDRAW, FALSE, 0);
ListView_DeleteAllItems(hWnd);
for (int iEp = 1; iEp <= g_cfg.cEp; iEp++) {
ElvDataA e = g_fvElv.At(iEp-1);
@@ -461,7 +461,7 @@ void EpisodeListView::Update()
SetTop(iItemTopNew);
}
- SendMessage(hWnd, WM_SETREDRAW, TRUE, 0);
+ SendMessageW(hWnd, WM_SETREDRAW, TRUE, 0);
}
LRESULT CALLBACK EpisodeListView::WndProc(const HWND hWnd, const UINT uMsg,
diff --git a/c/ext.cpp b/c/ext.cpp
index d8f3eb9..272f4a3 100644
--- a/c/ext.cpp
+++ b/c/ext.cpp
@@ -13,7 +13,7 @@ bool OpenOnline(int iEp)
wchar_t url[sizeof(g_cfg.url)+4];
Swprintf(url, L"%s%d", g_cfg.url, iEp);
INT_PTR r = reinterpret_cast<INT_PTR>(
- ShellExecute(nullptr, L"open", url, nullptr, nullptr, SW_SHOWNORMAL));
+ ShellExecuteW(nullptr, L"open", url, nullptr, nullptr, SW_SHOWNORMAL));
if (r <= 32)
throw Win32Error();
return true;
@@ -25,7 +25,7 @@ bool OpenWiki(int iEp)
wchar_t url[sizeof(d.wiki)+35];
Swprintf(url, L"https://www.detectiveconanworld.com%s", d.wiki);
INT_PTR r = reinterpret_cast<INT_PTR>(
- ShellExecute(nullptr, L"open", url, nullptr, nullptr, SW_SHOWNORMAL));
+ ShellExecuteW(nullptr, L"open", url, nullptr, nullptr, SW_SHOWNORMAL));
if (r <= 32)
throw Win32Error();
return true;
@@ -88,7 +88,7 @@ static bool FindMatchingFile(wchar_t (&file)[MAX_PATH], const wchar_t* const roo
Swprintf(pat, L"%s\\*", root);
WIN32_FIND_DATA fdata;
- FindHandle h = FindFirstFile(pat, &fdata);
+ FindHandle h = FindFirstFileW(pat, &fdata);
do
if (fdata.cFileName[0] == L'.')
@@ -103,7 +103,7 @@ static bool FindMatchingFile(wchar_t (&file)[MAX_PATH], const wchar_t* const roo
Swprintf(file, L"%s\\%s", root, fdata.cFileName);
return true;
}
- while (FindNextFile(h, &fdata));
+ while (FindNextFileW(h, &fdata));
if (GetLastError() != ERROR_NO_MORE_FILES)
throw Win32Error();
@@ -116,7 +116,7 @@ bool OpenLocally(int iEp)
wchar_t file[MAX_PATH];
if (FindMatchingFile(file, g_cfg.root, g_fvElv.At(iEp-1).siEp)) {
INT_PTR r = reinterpret_cast<INT_PTR>(
- ShellExecute(nullptr, L"open", file, nullptr, nullptr, SW_SHOWNORMAL));
+ ShellExecuteW(nullptr, L"open", file, nullptr, nullptr, SW_SHOWNORMAL));
if (r <= 32)
throw Win32Error();
return true;
diff --git a/c/layout.cpp b/c/layout.cpp
index 36edf32..23ee490 100644
--- a/c/layout.cpp
+++ b/c/layout.cpp
@@ -19,7 +19,7 @@ void UpdateLayout(int w, int h)
else Require(GetClientRect(g_hWnd, &rc));
Require(GetRelativeRect(g_hWndStatus, &rrStatus));
- SendMessage(g_hWnd, WM_SETREDRAW, FALSE, 0);
+ SendMessageW(g_hWnd, WM_SETREDRAW, FALSE, 0);
/* Resize list views. */
const long pad = EBIsThemeActive()? Dpi(6): 0; /* Add padding in modern themes. */
@@ -31,10 +31,10 @@ void UpdateLayout(int w, int h)
/* Resize status bar parts. */
const int aParts[] = {rc.right-Dpi(55), rc.right};
- SendMessage(g_hWndStatus, SB_SETPARTS,
+ SendMessageW(g_hWndStatus, SB_SETPARTS,
sizeof(aParts), reinterpret_cast<LPARAM>(aParts));
- SendMessage(g_hWnd, WM_SETREDRAW, TRUE, 0);
+ SendMessageW(g_hWnd, WM_SETREDRAW, TRUE, 0);
RedrawWindow(g_hWnd, nullptr, nullptr,
RDW_ERASE|RDW_FRAME|RDW_INVALIDATE|RDW_ALLCHILDREN);
}
diff --git a/c/listview.cpp b/c/listview.cpp
index 9ca088c..41f68a7 100644
--- a/c/listview.cpp
+++ b/c/listview.cpp
@@ -14,7 +14,7 @@ ListView::ListView(const HWND hWndParent, const HMENU hMenu, const DWORD dwStyle
extern HFONT g_hfNormal;
m_hWndParent = hWndParent;
- hWnd = Require(CreateWindowEx(
+ hWnd = Require(CreateWindowExW(
WS_EX_CLIENTEDGE,
WC_LISTVIEW,
L"",
@@ -24,9 +24,9 @@ ListView::ListView(const HWND hWndParent, const HMENU hMenu, const DWORD dwStyle
m_proc0 = reinterpret_cast<WNDPROC>(SetWindowLongPtr(
hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(::WndProc)));
- Require(SetProp(hWnd, L"this", reinterpret_cast<HANDLE>(this)));
+ Require(SetPropW(hWnd, L"this", reinterpret_cast<HANDLE>(this)));
ListView_SetExtendedListViewStyle(hWnd, LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER);
- SendMessage(hWnd, WM_SETFONT, reinterpret_cast<WPARAM>(g_hfNormal), MAKELPARAM(FALSE, 0));
+ SendMessageW(hWnd, WM_SETFONT, reinterpret_cast<WPARAM>(g_hfNormal), MAKELPARAM(FALSE, 0));
}
int ListView::Height()
@@ -56,7 +56,7 @@ void ListView::UpdateTheme(const bool bThemeActive)
SetWindowTheme(hWnd, theme, nullptr);
/* Hide focus rectangles. */
- SendMessage(hWnd, WM_UPDATEUISTATE, MAKEWPARAM(action, UISF_HIDEFOCUS), 0);
+ SendMessageW(hWnd, WM_UPDATEUISTATE, MAKEWPARAM(action, UISF_HIDEFOCUS), 0);
}
LRESULT CALLBACK ListView::WndProc(const HWND hWnd, const UINT uMsg,
@@ -87,7 +87,7 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam,
ListView* const lv = reinterpret_cast<ListView*>(GetProp(hWnd, L"this"));
if (uMsg == WM_DESTROY)
- RemoveProp(hWnd, L"this");
+ RemovePropW(hWnd, L"this");
return lv? lv->WndProc(hWnd, uMsg, wParam, lParam): FALSE;
}
diff --git a/c/main.cpp b/c/main.cpp
index 1ad62cf..7608f05 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -35,8 +35,8 @@ static auto _ = std::set_terminate([]() noexcept
int g_dpi = 96;
/* Cursors. */
-HCURSOR g_hcArrow = LoadCursor(nullptr, IDC_ARROW);
-HCURSOR g_hcSizeNs = LoadCursor(nullptr, IDC_SIZENS);
+HCURSOR g_hcArrow = LoadCursorW(nullptr, IDC_ARROW);
+HCURSOR g_hcSizeNs = LoadCursorW(nullptr, IDC_SIZENS);
/* Fonts. */
HFONT g_hfNormal;
@@ -98,19 +98,19 @@ int WINAPI WinMain(
wc.cbSize = sizeof(WNDCLASSEX);
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
+ wc.hIcon = LoadIconW(nullptr, IDI_APPLICATION);
wc.hCursor = g_hcArrow;
wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW);
- wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU);
+ wc.lpszMenuName = MAKEINTRESOURCEW(IDR_MENU);
wc.lpszClassName = L"Episode Browser";
- wc.hIconSm = LoadIcon(nullptr, IDI_APPLICATION);
- Require(RegisterClassEx(&wc));
+ wc.hIconSm = LoadIconW(nullptr, IDI_APPLICATION);
+ Require(RegisterClassExW(&wc));
/* InitializeMainWindow is called before the first message is
* sent to WndProc. This is important, as it initializes
* global state on which WndProc relies. */
WithNextWindow(InitializeMainWindow);
- const HWND hWnd = Require(CreateWindowEx(
+ const HWND hWnd = Require(CreateWindowExW(
0,
L"Episode Browser",
L"Episode Browser",
@@ -118,7 +118,7 @@ int WINAPI WinMain(
XMAIN, YMAIN, 0, 0,
nullptr, nullptr, hInstance, nullptr));
- g_hWndStatus = Require(CreateWindowEx(
+ g_hWndStatus = Require(CreateWindowExW(
0,
STATUSCLASSNAME,
nullptr,
@@ -138,10 +138,10 @@ int WINAPI WinMain(
#endif
MSG msg;
- while (GetMessage(&msg, nullptr, 0, 0) > 0) {
- if (IsDialogMessage(hWnd, &msg)) continue;
+ while (GetMessageW(&msg, nullptr, 0, 0) > 0) {
+ if (IsDialogMessageW(hWnd, &msg)) continue;
TranslateMessage(&msg);
- DispatchMessage(&msg);
+ DispatchMessageW(&msg);
}
return 0;
@@ -162,27 +162,27 @@ void InitializeMainWindow(const HWND hWnd)
if (auto lib = Library::Maybe(L"User32.dll");
lib && lib->GetProcAddress<void>("SystemParametersInfoW")) {
NONCLIENTMETRICS m = {sizeof(NONCLIENTMETRICS)};
- Require(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &m, 0));
- g_hfNormal = Require(CreateFontIndirect(&m.lfMessageFont));
+ Require(SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &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(GetObject(g_hfNormal, sizeof(LOGFONT), &lf));
+ Require(GetObjectW(g_hfNormal, sizeof(LOGFONT), &lf));
lf.lfWeight = FW_BOLD;
- g_hfBold = Require(CreateFontIndirect(&lf));
+ g_hfBold = Require(CreateFontIndirectW(&lf));
}
/* Load theme functions, if available. */
- if (HMODULE hModule = LoadLibrary(L"uxtheme.dll")) {
+ if (HMODULE hModule = LoadLibraryW(L"uxtheme.dll")) {
IsThemeActive = (decltype(IsThemeActive))(void*)GetProcAddress(hModule, "IsThemeActive");
SetWindowTheme = (decltype(SetWindowTheme))(void*)GetProcAddress(hModule, "SetWindowTheme");
}
/* Load context menu. */
- g_hMenuPopup = Require(LoadMenu(nullptr, MAKEINTRESOURCE(IDR_POPUPMENU)));
+ g_hMenuPopup = Require(LoadMenuW(nullptr, MAKEINTRESOURCE(IDR_POPUPMENU)));
g_hMenuPopup = Require(GetSubMenu(g_hMenuPopup, 0));
/* Create child windows. */
diff --git a/c/win.cpp b/c/win.cpp
index 43744dd..e1349bc 100644
--- a/c/win.cpp
+++ b/c/win.cpp
@@ -27,7 +27,7 @@ void WithNextWindow(void (*proc)(HWND))
* accept a capturing lambda as the hook procedure. */
static thread_local auto procNext = proc;
- static thread_local HHOOK hHook = Require(SetWindowsHookEx(WH_CBT, [](const int nCode,
+ static thread_local HHOOK hHook = Require(SetWindowsHookExW(WH_CBT, [](const int nCode,
const WPARAM wParam, const LPARAM lParam) -> LRESULT CALLBACK
{
if (nCode == HCBT_CREATEWND) {
@@ -56,7 +56,7 @@ static void CenterNextWindow(HWND hWnd)
hWndParent = hWnd;
hWndNext = nullptr;
- hHook = Require(SetWindowsHookEx(WH_CBT, [](const int nCode,
+ hHook = Require(SetWindowsHookExW(WH_CBT, [](const int nCode,
const WPARAM wParam, const LPARAM lParam) noexcept -> LRESULT CALLBACK
{
if (!hWndNext && nCode == HCBT_CREATEWND) {
@@ -66,7 +66,7 @@ static void CenterNextWindow(HWND hWnd)
&& reinterpret_cast<HWND>(wParam) == hWndNext) {
Require(UnhookWindowsHookEx(hHook));
- long lStyle = GetWindowLong(hWndNext, GWL_STYLE);
+ long lStyle = GetWindowLongW(hWndNext, GWL_STYLE);
if (!(lStyle & WS_POPUP)) return 0;
RECT rcMain, rcMsg;
@@ -156,7 +156,7 @@ const char* Win32Error::what() const noexcept
const wchar_t* Win32Error::What() const noexcept
{
if (!m_wszMsg)
- FormatMessage(
+ FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|FORMAT_MESSAGE_FROM_SYSTEM
|FORMAT_MESSAGE_FROM_HMODULE
@@ -184,7 +184,7 @@ InternetError::InternetError(DWORD codeSystem)
cch = len+1;
m_wszMsg = new wchar_t[cch];
- if (!InternetGetLastResponseInfo(&code, m_wszMsg, &len))
+ if (!InternetGetLastResponseInfoW(&code, m_wszMsg, &len))
throw Win32Error();
}
@@ -206,7 +206,7 @@ const wchar_t* InternetError::What() const noexcept
std::optional<Library> Library::Maybe(const wchar_t* const lib) noexcept
{
- HMODULE hModule = LoadLibrary(lib);
+ HMODULE hModule = LoadLibraryW(lib);
if (!hModule) return {};
return Library(hModule);
}
@@ -216,7 +216,7 @@ Library::Library(const HMODULE hModule) noexcept
Library::Library(const wchar_t* const lib)
{
- m_hModule = LoadLibrary(lib);
+ m_hModule = LoadLibraryW(lib);
if (!m_hModule)
throw Win32Error();
}