From 031115465b64f90fc2c0dcc36bcbd6a616be9838 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 7 Feb 2019 14:52:57 -0800 Subject: [PATCH] Minor code review --- DDSView/ddsview.cpp | 26 +++++++++++++------------- Texassemble/texassemble.cpp | 6 +++--- Texconv/texconv.cpp | 10 +++++----- Texdiag/texdiag.cpp | 6 +++--- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/DDSView/ddsview.cpp b/DDSView/ddsview.cpp index 448b5d7..7ade2b6 100644 --- a/DDSView/ddsview.cpp +++ b/DDSView/ddsview.cpp @@ -108,7 +108,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, if ( !*lpCmdLine ) { - MessageBox( nullptr, L"Usage: ddsview ", L"DDSView", MB_OK | MB_ICONEXCLAMATION ); + MessageBoxW( nullptr, L"Usage: ddsview ", L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; } @@ -118,7 +118,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, { wchar_t buff[2048] = {}; swprintf_s( buff, L"Failed to open texture file\n\nFilename = %ls\nHRESULT %08X", lpCmdLine, hr ); - MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); + MessageBoxW( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; } @@ -139,7 +139,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, { wchar_t buff[2048] = {}; swprintf_s( buff, L"Arrays of volume textures are not supported\n\nFilename = %ls\nArray size %zu", lpCmdLine, mdata.arraySize ); - MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); + MessageBoxW( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; } @@ -162,7 +162,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, { wchar_t buff[2048] = {}; swprintf_s( buff, L"BC6H/BC7 requires DirectX 11 hardware\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d", lpCmdLine, mdata.format, g_featureLevel ); - MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); + MessageBoxW( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; } break; @@ -175,7 +175,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, { wchar_t buff[2048] = {}; swprintf_s( buff, L"Format not supported by DirectX hardware\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d\nHRESULT = %08X", lpCmdLine, mdata.format, g_featureLevel, hr ); - MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); + MessageBoxW( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; } } @@ -188,7 +188,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, { wchar_t buff[2048] = {}; swprintf_s( buff, L"Failed to load texture file\n\nFilename = %ls\nHRESULT %08X", lpCmdLine, hr ); - MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); + MessageBoxW( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; } @@ -200,7 +200,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, { wchar_t buff[2048] = {}; swprintf_s( buff, L"Failed creating texture from file\n\nFilename = %ls\nHRESULT = %08X", lpCmdLine, hr ); - MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); + MessageBoxW( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; } @@ -228,8 +228,8 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow, const TexMetadata& mdata ) { // Register class - WNDCLASSEX wcex; - wcex.cbSize = sizeof( WNDCLASSEX ); + WNDCLASSEXW wcex; + wcex.cbSize = sizeof( WNDCLASSEXW ); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; @@ -241,7 +241,7 @@ HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow, const TexMetadata& mdata wcex.lpszMenuName = nullptr; wcex.lpszClassName = L"DDSViewWindowClass"; wcex.hIconSm = LoadIcon( wcex.hInstance, ( LPCTSTR )IDI_MAIN_ICON ); - if( !RegisterClassEx( &wcex ) ) + if( !RegisterClassExW( &wcex ) ) return E_FAIL; // Create window @@ -265,9 +265,9 @@ HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow, const TexMetadata& mdata rc.bottom = screenY; AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE ); - g_hWnd = CreateWindow( L"DDSViewWindowClass", L"DDS View", WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInstance, - nullptr ); + g_hWnd = CreateWindowW( L"DDSViewWindowClass", L"DDS View", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInstance, + nullptr ); if( !g_hWnd ) return E_FAIL; diff --git a/Texassemble/texassemble.cpp b/Texassemble/texassemble.cpp index 2655278..047d89f 100644 --- a/Texassemble/texassemble.cpp +++ b/Texassemble/texassemble.cpp @@ -329,7 +329,7 @@ namespace void SearchForFiles(const wchar_t* path, std::list& files, bool recursive) { // Process files - WIN32_FIND_DATA findData = {}; + WIN32_FIND_DATAW findData = {}; ScopedFindHandle hFile(safe_handle(FindFirstFileExW(path, FindExInfoBasic, &findData, FindExSearchNameMatch, nullptr, @@ -349,7 +349,7 @@ namespace files.push_back(conv); } - if (!FindNextFile(hFile.get(), &findData)) + if (!FindNextFileW(hFile.get(), &findData)) break; } } @@ -394,7 +394,7 @@ namespace } } - if (!FindNextFile(hFile.get(), &findData)) + if (!FindNextFileW(hFile.get(), &findData)) break; } } diff --git a/Texconv/texconv.cpp b/Texconv/texconv.cpp index ae58cd0..ecf7b94 100644 --- a/Texconv/texconv.cpp +++ b/Texconv/texconv.cpp @@ -482,7 +482,7 @@ namespace void SearchForFiles(const wchar_t* path, std::list& files, bool recursive) { // Process files - WIN32_FIND_DATA findData = {}; + WIN32_FIND_DATAW findData = {}; ScopedFindHandle hFile(safe_handle(FindFirstFileExW(path, FindExInfoBasic, &findData, FindExSearchNameMatch, nullptr, @@ -502,7 +502,7 @@ namespace files.push_back(conv); } - if (!FindNextFile(hFile.get(), &findData)) + if (!FindNextFileW(hFile.get(), &findData)) break; } } @@ -547,7 +547,7 @@ namespace } } - if (!FindNextFile(hFile.get(), &findData)) + if (!FindNextFileW(hFile.get(), &findData)) break; } } @@ -679,7 +679,7 @@ namespace if (!s_CreateDXGIFactory1) { - HMODULE hModDXGI = LoadLibrary(L"dxgi.dll"); + HMODULE hModDXGI = LoadLibraryW(L"dxgi.dll"); if (!hModDXGI) return false; @@ -804,7 +804,7 @@ namespace if (!s_DynamicD3D11CreateDevice) { - HMODULE hModD3D11 = LoadLibrary(L"d3d11.dll"); + HMODULE hModD3D11 = LoadLibraryW(L"d3d11.dll"); if (!hModD3D11) return false; diff --git a/Texdiag/texdiag.cpp b/Texdiag/texdiag.cpp index 8f17305..b7048cb 100644 --- a/Texdiag/texdiag.cpp +++ b/Texdiag/texdiag.cpp @@ -394,7 +394,7 @@ namespace void SearchForFiles(const wchar_t* path, std::list& files, bool recursive) { // Process files - WIN32_FIND_DATA findData = {}; + WIN32_FIND_DATAW findData = {}; ScopedFindHandle hFile(safe_handle(FindFirstFileExW(path, FindExInfoBasic, &findData, FindExSearchNameMatch, nullptr, @@ -414,7 +414,7 @@ namespace files.push_back(conv); } - if (!FindNextFile(hFile.get(), &findData)) + if (!FindNextFileW(hFile.get(), &findData)) break; } } @@ -459,7 +459,7 @@ namespace } } - if (!FindNextFile(hFile.get(), &findData)) + if (!FindNextFileW(hFile.get(), &findData)) break; } }