make existing hard-coded unicode calls switchable back to ansi

This commit is contained in:
Brad Parker 2016-12-02 14:15:39 -05:00
parent d891f1c90b
commit 3b8a81dd31
10 changed files with 110 additions and 93 deletions

View File

@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2016 - Daniel De Matteis
*
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
@ -123,7 +123,7 @@ void fill_pathname_abbreviate_special(char *out_path,
fill_pathname_application_path(application_dir, sizeof(application_dir));
path_basedir(application_dir);
for (i = 0; candidates[i]; i++)
{
if (!string_is_empty(candidates[i]) && strstr(in_path, candidates[i]) == in_path)
@ -131,11 +131,11 @@ void fill_pathname_abbreviate_special(char *out_path,
size_t src_size = strlcpy(out_path, notations[i], size);
retro_assert(src_size < size);
out_path += src_size;
size -= src_size;
in_path += strlen(candidates[i]);
if (!path_char_is_slash(*in_path))
{
retro_assert(strlcpy(out_path, path_default_slash(), size) < size);
@ -207,8 +207,10 @@ void fill_pathname_application_path(char *s, size_t len)
#endif
#ifdef _WIN32
DWORD ret;
#ifdef UNICODE
wchar_t ws[PATH_MAX_LENGTH] = {0};
#endif
#endif
#ifdef __HAIKU__
image_info info;
int32_t cookie = 0;
@ -219,10 +221,13 @@ void fill_pathname_application_path(char *s, size_t len)
return;
#ifdef _WIN32
#ifdef UNICODE
MultiByteToWideChar(CP_UTF8, 0, s, -1, ws, sizeof(ws) / sizeof(ws[0]));
ret = GetModuleFileNameW(GetModuleHandleW(NULL), ws, sizeof(ws) / sizeof(ws[0]));
#else
ret = GetModuleFileName(GetModuleHandle(NULL), s, len - 1);
#endif
s[ret] = '\0';
#elif defined(__APPLE__)
if (bundle)
@ -232,7 +237,7 @@ void fill_pathname_application_path(char *s, size_t len)
CFStringGetCString(bundle_path, s, len, kCFStringEncodingUTF8);
CFRelease(bundle_path);
CFRelease(bundle_url);
retro_assert(strlcat(s, "nobin", len) < len);
return;
}
@ -252,7 +257,7 @@ void fill_pathname_application_path(char *s, size_t len)
char link_path[255];
link_path[0] = *s = '\0';
pid = getpid();
pid = getpid();
/* Linux, BSD and Solaris paths. Not standardized. */
for (i = 0; i < ARRAY_SIZE(exts); i++)
@ -270,7 +275,7 @@ void fill_pathname_application_path(char *s, size_t len)
}
}
}
RARCH_ERR("Cannot resolve application path! This should not happen.\n");
#endif
}
@ -328,7 +333,7 @@ void fill_pathname_application_special(char *s, size_t len, enum application_spe
#ifdef HAVE_ZARCH
{
settings_t *settings = config_get_ptr();
fill_pathname_join(s,
fill_pathname_join(s,
settings->directory.assets,
"zarch",
len);

View File

@ -40,8 +40,8 @@
#include "../../runloop.h"
#include "../../verbosity.h"
/* We only load this library once, so we let it be
* unloaded at application shutdown, since unloading
/* We only load this library once, so we let it be
* unloaded at application shutdown, since unloading
* it early seems to cause issues on some systems.
*/
@ -71,7 +71,7 @@ static bool gfx_init_dwm(void)
}
atexit(gfx_dwm_shutdown);
HRESULT (WINAPI *mmcss)(BOOL) =
HRESULT (WINAPI *mmcss)(BOOL) =
(HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS");
if (mmcss)
{
@ -94,7 +94,7 @@ static void gfx_set_dwm(void)
if (settings->video.disable_composition == dwm_composition_disabled)
return;
HRESULT (WINAPI *composition_enable)(UINT) =
HRESULT (WINAPI *composition_enable)(UINT) =
(HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition");
if (!composition_enable)
{
@ -177,7 +177,7 @@ static void frontend_win32_init(void *data)
{
typedef BOOL (WINAPI *isProcessDPIAwareProc)();
typedef BOOL (WINAPI *setProcessDPIAwareProc)();
HMODULE handle = GetModuleHandleW(L"User32.dll");
HMODULE handle = GetModuleHandle(TEXT("User32.dll"));
isProcessDPIAwareProc isDPIAwareProc = (isProcessDPIAwareProc)dylib_proc(handle, "IsProcessDPIAware");
setProcessDPIAwareProc setDPIAwareProc = (setProcessDPIAwareProc)dylib_proc(handle, "SetProcessDPIAware");
@ -189,13 +189,13 @@ static void frontend_win32_init(void *data)
setDPIAwareProc();
}
}
}
enum frontend_powerstate frontend_win32_get_powerstate(int *seconds, int *percent)
{
SYSTEM_POWER_STATUS status;
enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE;
enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE;
if (!GetSystemPowerStatus(&status))
return ret;
@ -338,7 +338,7 @@ static void frontend_win32_detach_console(void)
{
HWND wnd = GetConsoleWindow();
FreeConsole();
PostMessageW(wnd, WM_CLOSE, 0, 0);
PostMessage(wnd, WM_CLOSE, 0, 0);
}
#endif
}

View File

@ -212,20 +212,20 @@ void win32_monitor_from_window(void)
void win32_monitor_get_info(void)
{
MONITORINFOEXW current_mon;
MONITORINFOEX current_mon;
memset(&current_mon, 0, sizeof(current_mon));
current_mon.cbSize = sizeof(MONITORINFOEXW);
current_mon.cbSize = sizeof(MONITORINFOEX);
GetMonitorInfoW(win32_monitor_last, (MONITORINFOEXW*)&current_mon);
ChangeDisplaySettingsExW(current_mon.szDevice, NULL, NULL, 0, NULL);
GetMonitorInfo(win32_monitor_last, (MONITORINFOEX*)&current_mon);
ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL);
}
void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id)
{
unsigned i, fs_monitor;
settings_t *settings = config_get_ptr();
MONITORINFOEXW *mon = (MONITORINFOEXW*)data;
MONITORINFOEX *mon = (MONITORINFOEX*)data;
HMONITOR *hm_to_use = (HMONITOR*)hm_data;
if (!win32_monitor_last)
@ -254,8 +254,8 @@ void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id)
}
memset(mon, 0, sizeof(*mon));
mon->cbSize = sizeof(MONITORINFOEXW);
GetMonitorInfoW(*hm_to_use, (MONITORINFOEXW*)mon);
mon->cbSize = sizeof(MONITORINFOEX);
GetMonitorInfo(*hm_to_use, (MONITORINFOEX*)mon);
}
/* Get the count of the files dropped */
@ -264,18 +264,19 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
char szFilename[1024] = {0};
wchar_t wszFilename[1024] = {0};
if (DragQueryFileW((HDROP)wparam, 0xFFFFFFFF, NULL, 0))
if (DragQueryFile((HDROP)wparam, 0xFFFFFFFF, NULL, 0))
{
/*poll list of current cores */
size_t list_size;
content_ctx_info_t content_info = {0};
core_info_list_t *core_info_list = NULL;
const core_info_t *core_info = NULL;
#ifdef UNICODE
DragQueryFileW((HDROP)wparam, 0, wszFilename, sizeof(wszFilename) / sizeof(wszFilename[0]));
utf16_to_char_string((const uint16_t*)wszFilename, szFilename, sizeof(szFilename));
#else
DragQueryFile((HDROP)wparam, 0, szFilename, sizeof(szFilename));
#endif
core_info_get_list(&core_info_list);
if (!core_info_list)
@ -335,7 +336,7 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
else
{
/* Pick one core that could be compatible, ew */
if(DialogBoxParamW(GetModuleHandleW(NULL),MAKEINTRESOURCE(IDD_PICKCORE),
if(DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_PICKCORE),
hwnd,PickCoreProc,(LPARAM)NULL)==IDOK)
{
task_push_content_load_default(
@ -507,7 +508,7 @@ LRESULT CALLBACK WndProcGL(HWND hwnd, UINT message,
if (dinput_wgl && dinput_handle_message(dinput_wgl, message, wparam, lparam))
return 0;
return DefWindowProcW(hwnd, message, wparam, lparam);
return DefWindowProc(hwnd, message, wparam, lparam);
}
bool win32_window_create(void *data, unsigned style,
@ -515,7 +516,7 @@ bool win32_window_create(void *data, unsigned style,
unsigned height, bool fullscreen)
{
#ifndef _XBOX
main_window.hwnd = CreateWindowExW(0, L"RetroArch", L"RetroArch",
main_window.hwnd = CreateWindowEx(0, TEXT("RetroArch"), TEXT("RetroArch"),
style,
fullscreen ? mon_rect->left : g_pos_x,
fullscreen ? mon_rect->top : g_pos_y,
@ -583,7 +584,8 @@ static bool win32_monitor_set_fullscreen(unsigned width, unsigned height,
{
#ifndef _XBOX
DEVMODE devmode;
wchar_t dev_name_wide[1024] = {0};
unsigned res = 0;
CHAR_TO_WCHAR_ALLOC(dev_name, dev_name_wide)
memset(&devmode, 0, sizeof(devmode));
devmode.dmSize = sizeof(DEVMODE);
@ -595,10 +597,13 @@ static bool win32_monitor_set_fullscreen(unsigned width, unsigned height,
RARCH_LOG("Setting fullscreen to %ux%u @ %uHz on device %s.\n",
width, height, refresh, dev_name);
MultiByteToWideChar(CP_UTF8, 0, dev_name, -1, dev_name_wide, sizeof(dev_name_wide) / sizeof(dev_name_wide[0]));
return ChangeDisplaySettingsExW(dev_name_wide, &devmode,
res = ChangeDisplaySettingsEx(dev_name_wide, &devmode,
NULL, CDS_FULLSCREEN, NULL) == DISP_CHANGE_SUCCESSFUL;
if (dev_name_wide)
free(dev_name_wide);
return res;
#endif
}
@ -655,7 +660,7 @@ bool win32_suppress_screensaver(void *data, bool enable)
typedef HANDLE (WINAPI * PowerCreateRequestPtr)(REASON_CONTEXT *context);
typedef BOOL (WINAPI * PowerSetRequestPtr)(HANDLE PowerRequest,
POWER_REQUEST_TYPE RequestType);
HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
PowerCreateRequestPtr powerCreateRequest =
(PowerCreateRequestPtr)GetProcAddress(kernel32, "PowerCreateRequest");
PowerSetRequestPtr powerSetRequest =
@ -689,7 +694,7 @@ bool win32_suppress_screensaver(void *data, bool enable)
}
/* FIXME: It should not be necessary to add the W after MONITORINFOEX, but linking fails without it. */
void win32_set_style(MONITORINFOEXW *current_mon, HMONITOR *hm_to_use,
void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
unsigned *width, unsigned *height, bool fullscreen, bool windowed_full,
RECT *rect, RECT *mon_rect, DWORD *style)
{
@ -724,7 +729,7 @@ void win32_set_style(MONITORINFOEXW *current_mon, HMONITOR *hm_to_use,
{}
/* Display settings might have changed, get new coordinates. */
GetMonitorInfoW(*hm_to_use, (MONITORINFOEXW*)current_mon);
GetMonitorInfo(*hm_to_use, (MONITORINFOEX*)current_mon);
*mon_rect = current_mon->rcMonitor;
}
}
@ -755,8 +760,8 @@ void win32_set_window(unsigned *width, unsigned *height,
{
RECT rc_temp = {0, 0, (LONG)*height, 0x7FFF};
SetMenu(main_window.hwnd,
LoadMenuW(GetModuleHandleW(NULL),MAKEINTRESOURCE(IDR_MENU)));
SendMessageW(main_window.hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp);
LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU)));
SendMessage(main_window.hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp);
g_resize_height = *height += rc_temp.top + rect->top;
SetWindowPos(main_window.hwnd, NULL, 0, 0, *width, *height, SWP_NOMOVE);
}
@ -782,7 +787,7 @@ bool win32_set_video_mode(void *data,
MSG msg;
RECT mon_rect;
unsigned mon_id;
MONITORINFOEXW current_mon;
MONITORINFOEX current_mon;
bool windowed_full;
RECT rect = {0};
HMONITOR hm_to_use = NULL;
@ -805,10 +810,10 @@ bool win32_set_video_mode(void *data,
win32_set_window(&width, &height, fullscreen, windowed_full, &rect);
/* Wait until context is created (or failed to do so ...) */
while (!g_inited && !g_quit && GetMessageW(&msg, main_window.hwnd, 0, 0))
while (!g_inited && !g_quit && GetMessage(&msg, main_window.hwnd, 0, 0))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
DispatchMessage(&msg);
}
if (g_quit)
@ -866,7 +871,7 @@ void win32_window_reset(void)
void win32_destroy_window(void)
{
#ifndef _XBOX
UnregisterClassW(L"RetroArch", GetModuleHandleW(NULL));
UnregisterClass(TEXT("RetroArch"), GetModuleHandle(NULL));
#endif
main_window.hwnd = NULL;
}

View File

@ -97,7 +97,7 @@ void win32_set_window(unsigned *width, unsigned *height,
#ifndef _XBOX
/* FIXME: It should not be necessary to add the W after MONITORINFOEX, but linking fails without it. */
void win32_set_style(MONITORINFOEXW *current_mon, HMONITOR *hm_to_use,
void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
unsigned *width, unsigned *height, bool fullscreen, bool windowed_full,
RECT *rect, RECT *mon_rect, DWORD *style);
#endif

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2016 - Daniel De Matteis
*
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
@ -18,6 +18,7 @@
#include "../../config.h"
#endif
#include <encodings/win32.h>
#include "../drivers/d3d.h"
#include "../font_driver.h"
@ -46,7 +47,7 @@ static void *d3dfonts_w32_init_font(void *video_data,
OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_PITCH,
L"Verdana" /* Hardcode FTL */
TEXT("Verdana") /* Hardcode FTL */
};
d3dfonts = (d3dfonts_t*)calloc(1, sizeof(*d3dfonts));

View File

@ -35,7 +35,7 @@
#endif
#ifdef _WIN32
static TCHAR last_dyn_error[512];
static TCHAR last_dyn_error[512] = {0};
static void set_dl_error(void)
{

View File

@ -35,7 +35,9 @@ struct RDIR *retro_opendir(const char *name)
{
#if defined(_WIN32)
char path_buf[1024] = {0};
#ifdef UNICODE
wchar_t pathW[1024] = {0};
#endif
#endif
struct RDIR *rdir = (struct RDIR*)calloc(1, sizeof(*rdir));
@ -43,9 +45,13 @@ struct RDIR *retro_opendir(const char *name)
return NULL;
#if defined(_WIN32)
#ifdef UNICODE
snprintf(path_buf, sizeof(path_buf), "%s\\*", name);
MultiByteToWideChar(CP_UTF8, 0, path_buf, -1, pathW, sizeof(pathW) / sizeof(pathW[0]));
rdir->directory = FindFirstFileW(pathW, &rdir->entry);
#else
rdir->directory = FindFirstFile(path_buf, &rdir->entry);
#endif
#elif defined(VITA) || defined(PSP)
rdir->directory = sceIoDopen(name);
#elif defined(_3DS)
@ -78,7 +84,7 @@ int retro_readdir(struct RDIR *rdir)
{
#if defined(_WIN32)
if(rdir->next)
return (FindNextFileW(rdir->directory, &rdir->entry) != 0);
return (FindNextFile(rdir->directory, &rdir->entry) != 0);
else {
rdir->next = true;
return (rdir->directory != INVALID_HANDLE_VALUE);
@ -123,7 +129,7 @@ const char *retro_dirent_get_name(struct RDIR *rdir)
bool retro_dirent_is_dir(struct RDIR *rdir, const char *path)
{
#if defined(_WIN32)
const WIN32_FIND_DATAW *entry = (const WIN32_FIND_DATAW*)&rdir->entry;
const WIN32_FIND_DATA *entry = (const WIN32_FIND_DATA*)&rdir->entry;
return entry->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
#elif defined(PSP) || defined(VITA)
const SceIoDirent *entry = (const SceIoDirent*)&rdir->entry;

View File

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <encodings/win32.h>
#include <retro_miscellaneous.h>
#if defined(_WIN32)
@ -103,11 +104,13 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
#elif defined(_WIN32)
WIN32_FILE_ATTRIBUTE_DATA file_info;
GET_FILEEX_INFO_LEVELS fInfoLevelId = GetFileExInfoStandard;
wchar_t path_wide[PATH_MAX_LENGTH] = {0};
CHAR_TO_WCHAR_ALLOC(path, path_wide)
MultiByteToWideChar(CP_UTF8, 0, path, -1, path_wide, sizeof(path_wide) / sizeof(path_wide[0]));
DWORD ret = GetFileAttributesEx(path_wide, fInfoLevelId, &file_info);
if (path_wide)
free(path_wide);
DWORD ret = GetFileAttributesExW(path_wide, fInfoLevelId, &file_info);
if (ret == 0)
return false;
#else
@ -208,7 +211,7 @@ bool mkdir_norecurse(const char *dir)
#elif defined(PSP) || defined(_3DS)
if ((ret == -1) && path_is_directory(dir))
ret = 0;
#else
#else
if (ret < 0 && errno == EEXIST && path_is_directory(dir))
ret = 0;
#endif

View File

@ -44,20 +44,20 @@ extern "C" {
#ifdef UNICODE
#define CHAR_TO_WCHAR_ALLOC(s, ws) \
size_t ws##_size = (s[0] ? strlen(s) : 0) + 1; \
size_t ws##_size = (NULL != s && s[0] ? strlen(s) : 0) + 1; \
wchar_t *ws = (wchar_t*)calloc(ws##_size, 2); \
if (s[0]) \
if (NULL != s && s[0]) \
MultiByteToWideChar(CP_UTF8, 0, s, -1, ws, ws##_size / sizeof(wchar_t));
#define WCHAR_TO_CHAR_ALLOC(ws, s) \
size_t s##_size = ((ws[0] ? wcslen((const wchar_t*)ws) : 0) / 2) + 1; \
size_t s##_size = ((NULL != ws && ws[0] ? wcslen((const wchar_t*)ws) : 0) / 2) + 1; \
char *s = (char*)calloc(s##_size, 1); \
if (ws[0]) \
if (NULL != ws && ws[0]) \
utf16_to_char_string((const uint16_t*)ws, s, s##_size);
#else
#define CHAR_TO_WCHAR_ALLOC(s, ws) char *ws = strdup(s);
#define WCHAR_TO_CHAR_ALLOC(ws, s) char *s = strdup(ws);
#define CHAR_TO_WCHAR_ALLOC(s, ws) char *ws = (NULL != s && s[0] ? strdup(s) : NULL);
#define WCHAR_TO_CHAR_ALLOC(ws, s) char *s = (NULL != ws && ws[0] ? strdup(ws) : NULL);
#endif
#endif

View File

@ -156,20 +156,20 @@ static void shader_dlg_params_refresh(void)
bool checked =
(shader_info.data->parameters[i].current ==
shader_info.data->parameters[i].maximum);
SendMessageW(control->checkbox.hwnd, BM_SETCHECK, checked, 0);
SendMessage(control->checkbox.hwnd, BM_SETCHECK, checked, 0);
}
break;
case SHADER_PARAM_CTRL_TRACKBAR:
shader_dlg_refresh_trackbar_label(i);
SendMessageW(control->trackbar.hwnd,
SendMessage(control->trackbar.hwnd,
TBM_SETRANGEMIN, (WPARAM)TRUE, (LPARAM)0);
SendMessageW(control->trackbar.hwnd,
SendMessage(control->trackbar.hwnd,
TBM_SETRANGEMAX, (WPARAM)TRUE,
(LPARAM)((shader_info.data->parameters[i].maximum -
shader_info.data->parameters[i].minimum)
/ shader_info.data->parameters[i].step));
SendMessageW(control->trackbar.hwnd, TBM_SETPOS, (WPARAM)TRUE,
SendMessage(control->trackbar.hwnd, TBM_SETPOS, (WPARAM)TRUE,
(LPARAM)((shader_info.data->parameters[i].current -
shader_info.data->parameters[i].minimum) /
shader_info.data->parameters[i].step));
@ -251,12 +251,12 @@ void shader_dlg_params_reload(void)
}
control->type = SHADER_PARAM_CTRL_CHECKBOX;
control->checkbox.hwnd = CreateWindowExW(0, L"BUTTON",
control->checkbox.hwnd = CreateWindowEx(0, TEXT("BUTTON"),
param_desc_wide,
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, pos_x, pos_y,
SHADER_DLG_CTRL_WIDTH, SHADER_DLG_CHECKBOX_HEIGHT,
g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL);
SendMessageW(control->checkbox.hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SendMessage(control->checkbox.hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
pos_y += SHADER_DLG_CHECKBOX_HEIGHT + SHADER_DLG_CTRL_MARGIN;
}
else
@ -269,27 +269,27 @@ void shader_dlg_params_reload(void)
}
control->type = SHADER_PARAM_CTRL_TRACKBAR;
control->trackbar.label_title = CreateWindowExW(0, L"STATIC",
control->trackbar.label_title = CreateWindowEx(0, TEXT("STATIC"),
param_desc_wide,
WS_CHILD | WS_VISIBLE | SS_LEFT, pos_x, pos_y,
SHADER_DLG_CTRL_WIDTH, SHADER_DLG_LABEL_HEIGHT, g_shader_dlg.window.hwnd,
(HMENU)(size_t)i, NULL, NULL);
SendMessageW(control->trackbar.label_title, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SendMessage(control->trackbar.label_title, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
pos_y += SHADER_DLG_LABEL_HEIGHT;
control->trackbar.hwnd = CreateWindowExW(0, TRACKBAR_CLASS, L"",
control->trackbar.hwnd = CreateWindowEx(0, TRACKBAR_CLASS, TEXT(""),
WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_NOTICKS,
pos_x + SHADER_DLG_TRACKBAR_LABEL_WIDTH, pos_y,
SHADER_DLG_TRACKBAR_WIDTH, SHADER_DLG_TRACKBAR_HEIGHT,
g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL);
control->trackbar.label_val = CreateWindowExW(0, L"STATIC", L"",
control->trackbar.label_val = CreateWindowEx(0, TEXT("STATIC"), TEXT(""),
WS_CHILD | WS_VISIBLE | SS_LEFT, pos_x,
pos_y, SHADER_DLG_TRACKBAR_LABEL_WIDTH, SHADER_DLG_LABEL_HEIGHT,
g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL);
SendMessageW(control->trackbar.label_val, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SendMessage(control->trackbar.label_val, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SendMessageW(control->trackbar.hwnd, TBM_SETBUDDY, (WPARAM)TRUE,
SendMessage(control->trackbar.hwnd, TBM_SETBUDDY, (WPARAM)TRUE,
(LPARAM)control->trackbar.label_val);
pos_y += SHADER_DLG_TRACKBAR_HEIGHT + SHADER_DLG_CTRL_MARGIN;
@ -303,7 +303,7 @@ void shader_dlg_params_reload(void)
if (window && g_shader_dlg.separator.hwnd)
window->destroy(&g_shader_dlg.separator);
g_shader_dlg.separator.hwnd = CreateWindowExW(0, L"STATIC", L"",
g_shader_dlg.separator.hwnd = CreateWindowEx(0, TEXT("STATIC"), TEXT(""),
SS_ETCHEDHORZ | WS_VISIBLE | WS_CHILD, SHADER_DLG_CTRL_X,
g_shader_dlg.parameters_start_y - SHADER_DLG_CTRL_MARGIN - SHADER_DLG_SEPARATOR_HEIGHT / 2,
(pos_x - SHADER_DLG_CTRL_X) + SHADER_DLG_CTRL_WIDTH,
@ -393,7 +393,7 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message,
if (g_shader_dlg.controls[i].type != SHADER_PARAM_CTRL_CHECKBOX)
break;
if (SendMessageW(g_shader_dlg.controls[i].checkbox.hwnd,
if (SendMessage(g_shader_dlg.controls[i].checkbox.hwnd,
BM_GETCHECK, 0, 0) == BST_CHECKED)
shader_info.data->parameters[i].current =
shader_info.data->parameters[i].maximum;
@ -404,7 +404,7 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message,
break;
case WM_HSCROLL:
i = GetWindowLongW((HWND)lparam, GWL_ID);
i = GetWindowLong((HWND)lparam, GWL_ID);
if (i >= GFX_MAX_PARAMETERS)
break;
@ -412,7 +412,7 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message,
if (g_shader_dlg.controls[i].type != SHADER_PARAM_CTRL_TRACKBAR)
break;
pos = (int)SendMessageW(g_shader_dlg.controls[i].trackbar.hwnd, TBM_GETPOS, 0, 0);
pos = (int)SendMessage(g_shader_dlg.controls[i].trackbar.hwnd, TBM_GETPOS, 0, 0);
shader_info.data->parameters[i].current =
shader_info.data->parameters[i].minimum + pos * shader_info.data->parameters[i].step;
@ -421,24 +421,21 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message,
}
return DefWindowProcW(hwnd, message, wparam, lparam);
return DefWindowProc(hwnd, message, wparam, lparam);
}
bool win32_window_init(WNDCLASSEX *wndclass,
bool fullscreen, const char *class_name)
{
wchar_t class_name_wide[1024] = {0};
if (class_name)
MultiByteToWideChar(CP_UTF8, 0, class_name, -1, class_name_wide, sizeof(class_name_wide) / sizeof(class_name_wide[0]));
CHAR_TO_WCHAR_ALLOC(class_name, class_name_wide)
wndclass->cbSize = sizeof(WNDCLASSEX);
wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wndclass->hInstance = GetModuleHandleW(NULL);
wndclass->hCursor = LoadCursorW(NULL, IDC_ARROW);
wndclass->lpszClassName = (class_name != NULL) ? class_name_wide : L"RetroArch";
wndclass->hIcon = LoadIconW(GetModuleHandleW(NULL), MAKEINTRESOURCE(IDI_ICON));
wndclass->hIconSm = (HICON)LoadImageW(GetModuleHandleW(NULL),
wndclass->hInstance = GetModuleHandle(NULL);
wndclass->hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass->lpszClassName = (class_name_wide != NULL) ? class_name_wide : TEXT("RetroArch");
wndclass->hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON));
wndclass->hIconSm = (HICON)LoadImage(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0);
if (!fullscreen)
wndclass->hbrBackground = (HBRUSH)COLOR_WINDOW;
@ -446,7 +443,7 @@ bool win32_window_init(WNDCLASSEX *wndclass,
if (class_name != NULL)
wndclass->style |= CS_CLASSDC;
if (!RegisterClassExW(wndclass))
if (!RegisterClassEx(wndclass))
return false;
/* This is non-NULL when we want a window for shader dialogs,
@ -471,7 +468,7 @@ bool win32_shader_dlg_init(void)
if (!inited)
{
WNDCLASSEXW wc_shader_dlg = {0};
WNDCLASSEX wc_shader_dlg = {0};
INITCOMMONCONTROLSEX comm_ctrl_init = {0};
comm_ctrl_init.dwSize = sizeof(comm_ctrl_init);
@ -491,19 +488,19 @@ bool win32_shader_dlg_init(void)
hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
g_shader_dlg.window.hwnd = CreateWindowExW(0, L"Shader Dialog", L"Shader Parameters",
g_shader_dlg.window.hwnd = CreateWindowEx(0, TEXT("Shader Dialog"), TEXT("Shader Parameters"),
WS_POPUPWINDOW | WS_CAPTION, 100, 100,
SHADER_DLG_WIDTH, SHADER_DLG_MIN_HEIGHT, NULL, NULL, NULL, NULL);
pos_y = SHADER_DLG_CTRL_MARGIN;
g_shader_dlg.on_top_checkbox.hwnd = CreateWindowExW(0, L"BUTTON", L"Always on Top",
g_shader_dlg.on_top_checkbox.hwnd = CreateWindowEx(0, TEXT("BUTTON"), TEXT("Always on Top"),
BS_AUTOCHECKBOX | WS_VISIBLE | WS_CHILD,
SHADER_DLG_CTRL_X, pos_y, SHADER_DLG_CTRL_WIDTH,
SHADER_DLG_CHECKBOX_HEIGHT, g_shader_dlg.window.hwnd,
(HMENU)SHADER_DLG_CHECKBOX_ONTOP_ID, NULL, NULL);
pos_y += SHADER_DLG_CHECKBOX_HEIGHT + SHADER_DLG_CTRL_MARGIN;
SendMessageW(g_shader_dlg.on_top_checkbox.hwnd,
SendMessage(g_shader_dlg.on_top_checkbox.hwnd,
WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
pos_y += SHADER_DLG_SEPARATOR_HEIGHT + SHADER_DLG_CTRL_MARGIN;
@ -677,7 +674,7 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
command_event(cmd, NULL);
if (do_wm_close)
PostMessageW(owner, WM_CLOSE, 0, 0);
PostMessage(owner, WM_CLOSE, 0, 0);
return 0L;
}