Use right versions of Win32 functions, issue #261

This commit is contained in:
kervala 2016-02-20 18:52:57 +01:00
parent 50afa42d93
commit f076548844
4 changed files with 24 additions and 28 deletions

View file

@ -45,32 +45,32 @@ bool CDummyWindow::init(HINSTANCE hInstance, WNDPROC winProc)
{
release();
static const char *INVISIBLE_WINDOW_CLASS = "nl_invisible_wnd_class";
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
if (!GetClassInfoEx(hInstance, INVISIBLE_WINDOW_CLASS, &wc))
WNDCLASSEXA wc;
wc.cbSize = sizeof(WNDCLASSEXA);
if (!GetClassInfoExA(hInstance, INVISIBLE_WINDOW_CLASS, &wc))
{
wc.cbSize = sizeof(WNDCLASSEX);
wc.cbSize = sizeof(WNDCLASSEXA);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = nlDefaultWinProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = 0;
wc.lpszMenuName = 0;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = INVISIBLE_WINDOW_CLASS;
wc.hIconSm = 0;
RegisterClassEx(&wc);
wc.hIconSm = NULL;
RegisterClassExA(&wc);
}
_HWnd = CreateWindow(INVISIBLE_WINDOW_CLASS, "", WS_POPUP,
_HWnd = CreateWindowA(INVISIBLE_WINDOW_CLASS, "", WS_POPUP,
CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,
NULL, 0,
hInstance, 0);
if (_HWnd)
{
if (winProc) SetWindowLongPtr(_HWnd, GWLP_WNDPROC, (LONG_PTR) winProc);
if (winProc) SetWindowLongPtrA(_HWnd, GWLP_WNDPROC, (LONG_PTR) winProc);
return true;
}
return false;

View file

@ -1062,7 +1062,7 @@ uint64 CSystemInfo::availableHDSpace (const string &filename)
return (uint64)(stfs.f_bavail * stst.st_blksize);
#else
ULARGE_INTEGER freeSpace = {0};
BOOL bRes = ::GetDiskFreeSpaceExA(path.c_str(), &freeSpace, NULL, NULL);
BOOL bRes = ::GetDiskFreeSpaceExW(utf8ToWide(path), &freeSpace, NULL, NULL);
if (!bRes) return 0;
return (uint64)freeSpace.QuadPart;

View file

@ -149,10 +149,9 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
CWinDisplayer *cwd=(CWinDisplayer *)GetWindowLongPtr (hWnd, GWLP_USERDATA);
// get the text as unicode string
GetWindowTextW(cwd->_HInputEdit, wText, 20000);
ucstring ucs((ucchar*)wText);
// and convert it to UTF-8 encoding.
TextSend = ucs.toUtf8();
SendMessage (cwd->_HInputEdit, WM_SETTEXT, (WPARAM)0, (LPARAM)"");
TextSend = wideToUtf8(wText);
SendMessageA (cwd->_HInputEdit, WM_SETTEXT, (WPARAM)0, (LPARAM)"");
const char *pos2 = TextSend.c_str();
string str;
while (*pos2 != '\0')
@ -193,14 +192,13 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
// get the text as unicode string
GetWindowTextW(cwd->_HInputEdit, wText, 20000);
ucstring ucs((ucchar*)wText);
// and convert it to UTF-8 encoding
string str = ucs.toUtf8();
string str = wideToUtf8(wText);
nlassert (cwd->Log != NULL);
ICommand::expand (str, *cwd->Log);
SendMessageW (cwd->_HInputEdit, WM_SETTEXT, (WPARAM)0, (LPARAM)wText);
SendMessage (cwd->_HInputEdit, EM_SETSEL, str.size(), str.size());
SendMessageA (cwd->_HInputEdit, EM_SETSEL, wcslen(wText), wcslen(wText));
return 1;
}
@ -209,7 +207,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (pmf->wParam == VK_UP)
{
CWinDisplayer *cwd=(CWinDisplayer *)GetWindowLongPtrW (hWnd, GWLP_USERDATA);
CWinDisplayer *cwd=(CWinDisplayer *)GetWindowLongPtrA (hWnd, GWLP_USERDATA);
if (cwd->_PosInHistory > 0)
cwd->_PosInHistory--;
@ -262,11 +260,11 @@ void CWinDisplayer::updateLabels ()
// create a button for command and label for variables
if (access.value()[i].Value[0] == '@')
{
access.value()[i].Hwnd = CreateWindowW (L"BUTTON", L"", WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 0, 0, 0, 0, _HWnd, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(_HWnd, GWLP_HINSTANCE), NULL);
access.value()[i].Hwnd = CreateWindowA ("BUTTON", "", WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 0, 0, 0, 0, _HWnd, (HMENU) NULL, (HINSTANCE) GetWindowLongPtrA(_HWnd, GWLP_HINSTANCE), NULL);
}
else
{
access.value()[i].Hwnd = CreateWindowW (L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_SIMPLE, 0, 0, 0, 0, _HWnd, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(_HWnd, GWLP_HINSTANCE), NULL);
access.value()[i].Hwnd = CreateWindowA ("STATIC", "", WS_CHILD | WS_VISIBLE | SS_SIMPLE, 0, 0, 0, 0, _HWnd, (HMENU) NULL, (HINSTANCE) GetWindowLongPtrA(_HWnd, GWLP_HINSTANCE), NULL);
}
SendMessageA ((HWND)access.value()[i].Hwnd, WM_SETFONT, (WPARAM)_HFont, TRUE);
needResize = true;
@ -290,7 +288,7 @@ void CWinDisplayer::updateLabels ()
}
}
SendMessage ((HWND)access.value()[i].Hwnd, WM_SETTEXT, 0, (LPARAM) n.c_str());
SendMessageW ((HWND)access.value()[i].Hwnd, WM_SETTEXT, 0, (LPARAM) utf8ToWide(n));
access.value()[i].NeedUpdate = false;
}
}

View file

@ -266,8 +266,7 @@ void CSoundDriverXAudio2::getDevices(std::vector<std::string> &devices)
for (uint i = 0; i < deviceCount; ++i)
{
_XAudio2->GetDeviceDetails(i, &deviceDetails);
std::basic_string<WCHAR> deviceNameW = deviceDetails.DisplayName;
std::string deviceName = std::string(deviceNameW.begin(), deviceNameW.end());
std::string deviceName = wideToUtf8(deviceDetails.DisplayName);
nldebug("XA2: - %s", deviceName.c_str());
devices.push_back(deviceName);
}
@ -289,8 +288,7 @@ uint CSoundDriverXAudio2::getDeviceIndex(const std::string &device, XAUDIO2_DEVI
for (uint i = 0; i < deviceCount; ++i)
{
_XAudio2->GetDeviceDetails(i, deviceDetails);
std::basic_string<WCHAR> deviceNameW = deviceDetails->DisplayName;
std::string deviceName = std::string(deviceNameW.begin(), deviceNameW.end());
std::string deviceName = wideToUtf8(deviceDetails->DisplayName);
if (deviceName == device)
return i;
}