Use right versions of Win32 functions, issue #261
This commit is contained in:
parent
2341b89fc5
commit
8c9c9e2267
4 changed files with 24 additions and 28 deletions
|
@ -45,32 +45,32 @@ bool CDummyWindow::init(HINSTANCE hInstance, WNDPROC winProc)
|
||||||
{
|
{
|
||||||
release();
|
release();
|
||||||
static const char *INVISIBLE_WINDOW_CLASS = "nl_invisible_wnd_class";
|
static const char *INVISIBLE_WINDOW_CLASS = "nl_invisible_wnd_class";
|
||||||
WNDCLASSEX wc;
|
WNDCLASSEXA wc;
|
||||||
wc.cbSize = sizeof(WNDCLASSEX);
|
wc.cbSize = sizeof(WNDCLASSEXA);
|
||||||
if (!GetClassInfoEx(hInstance, INVISIBLE_WINDOW_CLASS, &wc))
|
if (!GetClassInfoExA(hInstance, INVISIBLE_WINDOW_CLASS, &wc))
|
||||||
{
|
{
|
||||||
wc.cbSize = sizeof(WNDCLASSEX);
|
wc.cbSize = sizeof(WNDCLASSEXA);
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
|
||||||
wc.lpfnWndProc = nlDefaultWinProc;
|
wc.lpfnWndProc = nlDefaultWinProc;
|
||||||
wc.cbClsExtra = 0;
|
wc.cbClsExtra = 0;
|
||||||
wc.cbWndExtra = 0;
|
wc.cbWndExtra = 0;
|
||||||
wc.hInstance = hInstance;
|
wc.hInstance = hInstance;
|
||||||
wc.hIcon = 0;
|
wc.hIcon = NULL;
|
||||||
wc.hCursor = 0;
|
wc.hCursor = NULL;
|
||||||
wc.hbrBackground = 0;
|
wc.hbrBackground = NULL;
|
||||||
wc.lpszMenuName = 0;
|
wc.lpszMenuName = NULL;
|
||||||
wc.lpszClassName = INVISIBLE_WINDOW_CLASS;
|
wc.lpszClassName = INVISIBLE_WINDOW_CLASS;
|
||||||
wc.hIconSm = 0;
|
wc.hIconSm = NULL;
|
||||||
RegisterClassEx(&wc);
|
RegisterClassExA(&wc);
|
||||||
}
|
}
|
||||||
_HWnd = CreateWindow(INVISIBLE_WINDOW_CLASS, "", WS_POPUP,
|
_HWnd = CreateWindowA(INVISIBLE_WINDOW_CLASS, "", WS_POPUP,
|
||||||
CW_USEDEFAULT,CW_USEDEFAULT,
|
CW_USEDEFAULT,CW_USEDEFAULT,
|
||||||
CW_USEDEFAULT,CW_USEDEFAULT,
|
CW_USEDEFAULT,CW_USEDEFAULT,
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
hInstance, 0);
|
hInstance, 0);
|
||||||
if (_HWnd)
|
if (_HWnd)
|
||||||
{
|
{
|
||||||
if (winProc) SetWindowLongPtr(_HWnd, GWLP_WNDPROC, (LONG_PTR) winProc);
|
if (winProc) SetWindowLongPtrA(_HWnd, GWLP_WNDPROC, (LONG_PTR) winProc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1062,7 +1062,7 @@ uint64 CSystemInfo::availableHDSpace (const string &filename)
|
||||||
return (uint64)(stfs.f_bavail * stst.st_blksize);
|
return (uint64)(stfs.f_bavail * stst.st_blksize);
|
||||||
#else
|
#else
|
||||||
ULARGE_INTEGER freeSpace = {0};
|
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;
|
if (!bRes) return 0;
|
||||||
|
|
||||||
return (uint64)freeSpace.QuadPart;
|
return (uint64)freeSpace.QuadPart;
|
||||||
|
|
|
@ -149,10 +149,9 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
CWinDisplayer *cwd=(CWinDisplayer *)GetWindowLongPtr (hWnd, GWLP_USERDATA);
|
CWinDisplayer *cwd=(CWinDisplayer *)GetWindowLongPtr (hWnd, GWLP_USERDATA);
|
||||||
// get the text as unicode string
|
// get the text as unicode string
|
||||||
GetWindowTextW(cwd->_HInputEdit, wText, 20000);
|
GetWindowTextW(cwd->_HInputEdit, wText, 20000);
|
||||||
ucstring ucs((ucchar*)wText);
|
|
||||||
// and convert it to UTF-8 encoding.
|
// and convert it to UTF-8 encoding.
|
||||||
TextSend = ucs.toUtf8();
|
TextSend = wideToUtf8(wText);
|
||||||
SendMessage (cwd->_HInputEdit, WM_SETTEXT, (WPARAM)0, (LPARAM)"");
|
SendMessageA (cwd->_HInputEdit, WM_SETTEXT, (WPARAM)0, (LPARAM)"");
|
||||||
const char *pos2 = TextSend.c_str();
|
const char *pos2 = TextSend.c_str();
|
||||||
string str;
|
string str;
|
||||||
while (*pos2 != '\0')
|
while (*pos2 != '\0')
|
||||||
|
@ -193,14 +192,13 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
// get the text as unicode string
|
// get the text as unicode string
|
||||||
GetWindowTextW(cwd->_HInputEdit, wText, 20000);
|
GetWindowTextW(cwd->_HInputEdit, wText, 20000);
|
||||||
ucstring ucs((ucchar*)wText);
|
|
||||||
// and convert it to UTF-8 encoding
|
// and convert it to UTF-8 encoding
|
||||||
string str = ucs.toUtf8();
|
string str = wideToUtf8(wText);
|
||||||
nlassert (cwd->Log != NULL);
|
nlassert (cwd->Log != NULL);
|
||||||
ICommand::expand (str, *cwd->Log);
|
ICommand::expand (str, *cwd->Log);
|
||||||
SendMessageW (cwd->_HInputEdit, WM_SETTEXT, (WPARAM)0, (LPARAM)wText);
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -209,7 +207,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (pmf->wParam == VK_UP)
|
if (pmf->wParam == VK_UP)
|
||||||
{
|
{
|
||||||
CWinDisplayer *cwd=(CWinDisplayer *)GetWindowLongPtrW (hWnd, GWLP_USERDATA);
|
CWinDisplayer *cwd=(CWinDisplayer *)GetWindowLongPtrA (hWnd, GWLP_USERDATA);
|
||||||
|
|
||||||
if (cwd->_PosInHistory > 0)
|
if (cwd->_PosInHistory > 0)
|
||||||
cwd->_PosInHistory--;
|
cwd->_PosInHistory--;
|
||||||
|
@ -262,11 +260,11 @@ void CWinDisplayer::updateLabels ()
|
||||||
// create a button for command and label for variables
|
// create a button for command and label for variables
|
||||||
if (access.value()[i].Value[0] == '@')
|
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
|
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);
|
SendMessageA ((HWND)access.value()[i].Hwnd, WM_SETFONT, (WPARAM)_HFont, TRUE);
|
||||||
needResize = 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;
|
access.value()[i].NeedUpdate = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -604,7 +602,7 @@ void CWinDisplayer::display_main ()
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the string to the edit control
|
// add the string to the edit control
|
||||||
SendMessageW (_HEdit, EM_REPLACESEL, FALSE, (LPARAM) str.c_str());
|
SendMessageW(_HEdit, EM_REPLACESEL, FALSE, (LPARAM) str.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore old selection
|
// restore old selection
|
||||||
|
|
|
@ -266,8 +266,7 @@ void CSoundDriverXAudio2::getDevices(std::vector<std::string> &devices)
|
||||||
for (uint i = 0; i < deviceCount; ++i)
|
for (uint i = 0; i < deviceCount; ++i)
|
||||||
{
|
{
|
||||||
_XAudio2->GetDeviceDetails(i, &deviceDetails);
|
_XAudio2->GetDeviceDetails(i, &deviceDetails);
|
||||||
std::basic_string<WCHAR> deviceNameW = deviceDetails.DisplayName;
|
std::string deviceName = wideToUtf8(deviceDetails.DisplayName);
|
||||||
std::string deviceName = std::string(deviceNameW.begin(), deviceNameW.end());
|
|
||||||
nldebug("XA2: - %s", deviceName.c_str());
|
nldebug("XA2: - %s", deviceName.c_str());
|
||||||
devices.push_back(deviceName);
|
devices.push_back(deviceName);
|
||||||
}
|
}
|
||||||
|
@ -289,8 +288,7 @@ uint CSoundDriverXAudio2::getDeviceIndex(const std::string &device, XAUDIO2_DEVI
|
||||||
for (uint i = 0; i < deviceCount; ++i)
|
for (uint i = 0; i < deviceCount; ++i)
|
||||||
{
|
{
|
||||||
_XAudio2->GetDeviceDetails(i, deviceDetails);
|
_XAudio2->GetDeviceDetails(i, deviceDetails);
|
||||||
std::basic_string<WCHAR> deviceNameW = deviceDetails->DisplayName;
|
std::string deviceName = wideToUtf8(deviceDetails->DisplayName);
|
||||||
std::string deviceName = std::string(deviceNameW.begin(), deviceNameW.end());
|
|
||||||
if (deviceName == device)
|
if (deviceName == device)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue