Use ANSI versions of Win32 functions when not using Unicode text, issue #261

This commit is contained in:
kervala 2016-02-20 18:38:17 +01:00
parent 56f7abe54b
commit 2341b89fc5
14 changed files with 79 additions and 80 deletions

View file

@ -1243,23 +1243,23 @@ bool CDriverD3D::init (uintptr_t windowIcon, emptyProc exitFunc)
createCursors(); createCursors();
_WindowClass = "NLD3D" + toString(windowIcon);
// Register a window class // Register a window class
WNDCLASSW wc; WNDCLASSA wc;
memset(&wc,0,sizeof(wc)); memset(&wc,0,sizeof(wc));
wc.style = 0; // CS_HREDRAW | CS_VREDRAW ;//| CS_DBLCLKS; wc.style = 0; // CS_HREDRAW | CS_VREDRAW ;//| CS_DBLCLKS;
wc.lpfnWndProc = (WNDPROC)WndProc; wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
wc.cbWndExtra = 0; wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandleW(NULL); wc.hInstance = GetModuleHandleA(NULL);
wc.hIcon = (HICON)windowIcon; wc.hIcon = (HICON)windowIcon;
wc.hCursor = _DefaultCursor; wc.hCursor = _DefaultCursor;
wc.hbrBackground = WHITE_BRUSH; wc.hbrBackground = WHITE_BRUSH;
_WindowClass = "NLD3D" + toString(windowIcon); wc.lpszClassName = _WindowClass.c_str();
ucstring us = _WindowClass;
wc.lpszClassName = (LPCWSTR)us.c_str();
wc.lpszMenuName = NULL; wc.lpszMenuName = NULL;
if (!RegisterClassW(&wc)) if (!RegisterClassA(&wc))
{ {
DWORD error = GetLastError(); DWORD error = GetLastError();
if (error != ERROR_CLASS_ALREADY_EXISTS) if (error != ERROR_CLASS_ALREADY_EXISTS)
@ -2327,13 +2327,13 @@ void CDriverD3D::setWindowIcon(const std::vector<NLMISC::CBitmap> &bitmaps)
if (winIconBig) if (winIconBig)
{ {
SendMessage(_HWnd, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)winIconSmall); SendMessageA(_HWnd, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)winIconSmall);
SendMessage(_HWnd, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)winIconBig); SendMessageA(_HWnd, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)winIconBig);
} }
else else
{ {
SendMessage(_HWnd, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)winIconSmall); SendMessageA(_HWnd, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)winIconSmall);
SendMessage(_HWnd, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)winIconSmall); SendMessageA(_HWnd, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)winIconSmall);
} }
} }

View file

@ -2527,7 +2527,7 @@ void CDriverGL::retrieveATIDriverVersion()
// get from the registry // get from the registry
HKEY parentKey; HKEY parentKey;
// open key about current video card // open key about current video card
LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}", 0, KEY_READ, &parentKey); LONG result = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}", 0, KEY_READ, &parentKey);
if (result == ERROR_SUCCESS) if (result == ERROR_SUCCESS)
{ {
// find last config // find last config
@ -2541,7 +2541,7 @@ void CDriverGL::retrieveATIDriverVersion()
for(;;) for(;;)
{ {
nameBufferSize = sizeof(subKeyName) / sizeof(subKeyName[0]); nameBufferSize = sizeof(subKeyName) / sizeof(subKeyName[0]);
result = RegEnumKeyEx(parentKey, keyIndex, subKeyName, &nameBufferSize, NULL, NULL, NULL, &lastWriteTime); result = RegEnumKeyExA(parentKey, keyIndex, subKeyName, &nameBufferSize, NULL, NULL, NULL, &lastWriteTime);
if (result == ERROR_NO_MORE_ITEMS) break; if (result == ERROR_NO_MORE_ITEMS) break;
if (result == ERROR_SUCCESS) if (result == ERROR_SUCCESS)
{ {
@ -2577,14 +2577,14 @@ void CDriverGL::retrieveATIDriverVersion()
if (configFound) if (configFound)
{ {
HKEY subKey; HKEY subKey;
result = RegOpenKeyEx(parentKey, latestSubKeyName, 0, KEY_READ, &subKey); result = RegOpenKeyExA(parentKey, latestSubKeyName, 0, KEY_READ, &subKey);
if (result == ERROR_SUCCESS) if (result == ERROR_SUCCESS)
{ {
// see if it is a radeon card // see if it is a radeon card
DWORD valueType; DWORD valueType;
char driverDesc[256]; char driverDesc[256];
DWORD driverDescBufSize = sizeof(driverDesc) / sizeof(driverDesc[0]); DWORD driverDescBufSize = sizeof(driverDesc) / sizeof(driverDesc[0]);
result = RegQueryValueEx(subKey, "DriverDesc", NULL, &valueType, (unsigned char *) driverDesc, &driverDescBufSize); result = RegQueryValueExA(subKey, "DriverDesc", NULL, &valueType, (unsigned char *) driverDesc, &driverDescBufSize);
if (result == ERROR_SUCCESS && valueType == REG_SZ) if (result == ERROR_SUCCESS && valueType == REG_SZ)
{ {
toLower(driverDesc); toLower(driverDesc);
@ -2592,7 +2592,7 @@ void CDriverGL::retrieveATIDriverVersion()
{ {
char driverVersion[256]; char driverVersion[256];
DWORD driverVersionBufSize = sizeof(driverVersion) / sizeof(driverVersion[0]); DWORD driverVersionBufSize = sizeof(driverVersion) / sizeof(driverVersion[0]);
result = RegQueryValueEx(subKey, "DriverVersion", NULL, &valueType, (unsigned char *) driverVersion, &driverVersionBufSize); result = RegQueryValueExA(subKey, "DriverVersion", NULL, &valueType, (unsigned char *) driverVersion, &driverVersionBufSize);
if (result == ERROR_SUCCESS && valueType == REG_SZ) if (result == ERROR_SUCCESS && valueType == REG_SZ)
{ {
int subVersionNumber[4]; int subVersionNumber[4];

View file

@ -326,7 +326,7 @@ bool CDriverGL::init (uintptr_t windowIcon, emptyProc exitFunc)
} }
// Backup monitor color parameters // Backup monitor color parameters
HDC dc = CreateDC ("DISPLAY", NULL, NULL, NULL); HDC dc = CreateDCA ("DISPLAY", NULL, NULL, NULL);
if (dc) if (dc)
{ {
_NeedToRestoreGammaRamp = GetDeviceGammaRamp (dc, _GammaRampBackuped) != FALSE; _NeedToRestoreGammaRamp = GetDeviceGammaRamp (dc, _GammaRampBackuped) != FALSE;
@ -468,7 +468,7 @@ bool CDriverGL::unInit()
// Restore monitor color parameters // Restore monitor color parameters
if (_NeedToRestoreGammaRamp) if (_NeedToRestoreGammaRamp)
{ {
HDC dc = CreateDC ("DISPLAY", NULL, NULL, NULL); HDC dc = CreateDCA ("DISPLAY", NULL, NULL, NULL);
if (dc) if (dc)
{ {
if (!SetDeviceGammaRamp (dc, _GammaRampBackuped)) if (!SetDeviceGammaRamp (dc, _GammaRampBackuped))
@ -558,13 +558,13 @@ void CDriverGL::setWindowIcon(const std::vector<NLMISC::CBitmap> &bitmaps)
if (winIconBig) if (winIconBig)
{ {
SendMessage(_win, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)winIconSmall); SendMessageA(_win, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)winIconSmall);
SendMessage(_win, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)winIconBig); SendMessageA(_win, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)winIconBig);
} }
else else
{ {
SendMessage(_win, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)winIconSmall); SendMessageA(_win, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)winIconSmall);
SendMessage(_win, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)winIconSmall); SendMessageA(_win, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)winIconSmall);
} }
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)
@ -2847,7 +2847,7 @@ bool CDriverGL::setMonitorColorProperties (const CMonitorColorProperties &proper
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
// Get a DC // Get a DC
HDC dc = CreateDC ("DISPLAY", NULL, NULL, NULL); HDC dc = CreateDCA ("DISPLAY", NULL, NULL, NULL);
if (dc) if (dc)
{ {
// The ramp // The ramp

View file

@ -1171,12 +1171,12 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog)
// Use an environment variable to share the value among the EXE and its child DLLs // Use an environment variable to share the value among the EXE and its child DLLs
// (otherwise there would be one distinct bool by module, and the last // (otherwise there would be one distinct bool by module, and the last
// _set_se_translator would overwrite the previous ones) // _set_se_translator would overwrite the previous ones)
const TCHAR *SE_TRANSLATOR_IN_MAIN_MODULE = _T("NEL_SE_TRANS"); const char *SE_TRANSLATOR_IN_MAIN_MODULE = "NEL_SE_TRANS";
TCHAR envBuf [2]; char envBuf [2];
if ( GetEnvironmentVariable( SE_TRANSLATOR_IN_MAIN_MODULE, envBuf, 2 ) == 0) if ( GetEnvironmentVariableA( SE_TRANSLATOR_IN_MAIN_MODULE, envBuf, 2 ) == 0)
{ {
_set_se_translator(exceptionTranslator); _set_se_translator(exceptionTranslator);
SetEnvironmentVariable( SE_TRANSLATOR_IN_MAIN_MODULE, _T("1") ); SetEnvironmentVariableA( SE_TRANSLATOR_IN_MAIN_MODULE, "1" );
} }
} }
# endif // NL_OS_WINDOWS # endif // NL_OS_WINDOWS

View file

@ -216,7 +216,7 @@ void CStdDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mess
static bool consoleModeTest = false; static bool consoleModeTest = false;
if (!consoleModeTest) if (!consoleModeTest)
{ {
HANDLE handle = CreateFile ("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); HANDLE handle = CreateFileA ("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
consoleMode = handle != INVALID_HANDLE_VALUE; consoleMode = handle != INVALID_HANDLE_VALUE;
if (consoleMode) if (consoleMode)
CloseHandle (handle); CloseHandle (handle);

View file

@ -96,7 +96,7 @@ namespace NLMISC
nlassert(_Id == 0); // init done twice nlassert(_Id == 0); // init done twice
release(); release();
// create a system wide mutex // create a system wide mutex
_SharedMemMutex = CreateMutex(NULL, FALSE, toString("NL_MUTEX_%d", (int) id).c_str()); _SharedMemMutex = CreateMutexA(NULL, FALSE, toString("NL_MUTEX_%d", (int) id).c_str());
if (!_SharedMemMutex) return false; if (!_SharedMemMutex) return false;
_Id = id; _Id = id;
return true; return true;
@ -197,7 +197,7 @@ namespace NLMISC
cds.lpData = (PVOID) msgOut.buffer(); cds.lpData = (PVOID) msgOut.buffer();
for(;;) for(;;)
{ {
LRESULT result = ::SendMessage(targetWindow, WM_COPYDATA, (WPARAM) _Parent->_LocalWindow.getWnd(), (LPARAM) &cds); LRESULT result = ::SendMessageA(targetWindow, WM_COPYDATA, (WPARAM) _Parent->_LocalWindow.getWnd(), (LPARAM) &cds);
if (result) break; if (result) break;
// retry ... // retry ...
Sleep(30); Sleep(30);

View file

@ -165,10 +165,9 @@ static DWORD __stdcall GetModuleBase(HANDLE hProcess, DWORD dwReturnAddress)
DWORD cch = 0; DWORD cch = 0;
char szFile[MAX_PATH] = { 0 }; char szFile[MAX_PATH] = { 0 };
cch = GetModuleFileNameA((HINSTANCE)memoryBasicInfo.AllocationBase, cch = GetModuleFileNameA((HINSTANCE)memoryBasicInfo.AllocationBase, szFile, MAX_PATH);
szFile, MAX_PATH);
if (cch && (lstrcmp(szFile, "DBFN")== 0)) if (cch && (lstrcmpA(szFile, "DBFN")== 0))
{ {
char mn[] = { 'M', 'N', 0x00 }; char mn[] = { 'M', 'N', 0x00 };
#ifdef NL_OS_WIN64 #ifdef NL_OS_WIN64

View file

@ -159,7 +159,7 @@ bool CSharedMutex::createByName( const char *objectName )
#ifdef NL_DEBUG #ifdef NL_DEBUG
nlassert( _Mutex == NULL ); nlassert( _Mutex == NULL );
#endif #endif
_Mutex = (void *) CreateMutex( NULL, FALSE, objectName ); _Mutex = (void *) CreateMutexA( NULL, FALSE, objectName );
//nldebug( "Creating mutex %s: handle %p", objectName, _Mutex ); //nldebug( "Creating mutex %s: handle %p", objectName, _Mutex );
return ( _Mutex != NULL ); return ( _Mutex != NULL );
} }

View file

@ -51,7 +51,7 @@ void *CSharedMemory::createSharedMemory( TSharedMemId sharedMemId, uint32 size
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
// Create a file mapping backed by the virtual memory swap file (not a data file) // Create a file mapping backed by the virtual memory swap file (not a data file)
HANDLE hMapFile = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, sharedMemId ); HANDLE hMapFile = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, sharedMemId );
if ( (hMapFile == NULL) || (GetLastError() == ERROR_ALREADY_EXISTS) ) if ( (hMapFile == NULL) || (GetLastError() == ERROR_ALREADY_EXISTS) )
{ {
nlwarning( "SHDMEM: Cannot create file mapping for smid %s: error %u%s, mapFile %p", sharedMemId, GetLastError(), (GetLastError()==ERROR_ALREADY_EXISTS) ? " (already exists) ": "", hMapFile ); nlwarning( "SHDMEM: Cannot create file mapping for smid %s: error %u%s, mapFile %p", sharedMemId, GetLastError(), (GetLastError()==ERROR_ALREADY_EXISTS) ? " (already exists) ": "", hMapFile );
@ -97,7 +97,7 @@ void *CSharedMemory::accessSharedMemory( TSharedMemId sharedMemId )
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
// Open the existing file mapping by name // Open the existing file mapping by name
HANDLE hMapFile = OpenFileMapping( FILE_MAP_ALL_ACCESS, false, sharedMemId ); HANDLE hMapFile = OpenFileMappingA( FILE_MAP_ALL_ACCESS, false, sharedMemId );
if ( hMapFile == NULL ) if ( hMapFile == NULL )
return NULL; return NULL;
//nldebug( "SHDMEM: Opening smid %s --> mapFile %p", sharedMemId, hMapFile ); //nldebug( "SHDMEM: Opening smid %s --> mapFile %p", sharedMemId, hMapFile );

View file

@ -638,7 +638,7 @@ string CSystemInfo::getOS()
else // Test for specific product on Windows NT 4.0 SP5 and earlier else // Test for specific product on Windows NT 4.0 SP5 and earlier
{ {
HKEY hKey; HKEY hKey;
TCHAR szProductType[BUFSIZE]; char szProductType[BUFSIZE];
DWORD dwBufLen=BUFSIZE; DWORD dwBufLen=BUFSIZE;
LONG lRet; LONG lRet;
@ -652,18 +652,18 @@ string CSystemInfo::getOS()
RegCloseKey( hKey ); RegCloseKey( hKey );
if ( lstrcmpi( _T("WINNT"), szProductType) == 0 ) if ( lstrcmpiA( "WINNT", szProductType) == 0 )
OSString += " Workstation"; OSString += " Workstation";
if ( lstrcmpi( _T("LANMANNT"), szProductType) == 0 ) if ( lstrcmpiA( "LANMANNT", szProductType) == 0 )
OSString += " Server"; OSString += " Server";
if ( lstrcmpi( _T("SERVERNT"), szProductType) == 0 ) if ( lstrcmpiA( "SERVERNT", szProductType) == 0 )
OSString += " Advanced Server"; OSString += " Advanced Server";
} }
} }
std::string servicePack; std::string servicePack;
if( osvi.dwMajorVersion == 4 && lstrcmpi( osvi.szCSDVersion, _T("Service Pack 6") ) == 0 ) if (osvi.dwMajorVersion == 4 && lstrcmpiA(osvi.szCSDVersion, "Service Pack 6") == 0 )
{ {
HKEY hKey; HKEY hKey;
LONG lRet; LONG lRet;
@ -768,7 +768,7 @@ string CSystemInfo::getProc ()
{ {
// get processor name // get processor name
valueSize = 1024; valueSize = 1024;
result = ::RegQueryValueEx (hKey, _T("ProcessorNameString"), NULL, NULL, (LPBYTE)value, &valueSize); result = ::RegQueryValueExA (hKey, "ProcessorNameString", NULL, NULL, (LPBYTE)value, &valueSize);
if (result == ERROR_SUCCESS) if (result == ERROR_SUCCESS)
ProcString = value; ProcString = value;
else else
@ -778,7 +778,7 @@ string CSystemInfo::getProc ()
// get processor identifier // get processor identifier
valueSize = 1024; valueSize = 1024;
result = ::RegQueryValueEx (hKey, _T("Identifier"), NULL, NULL, (LPBYTE)value, &valueSize); result = ::RegQueryValueExA (hKey, "Identifier", NULL, NULL, (LPBYTE)value, &valueSize);
if (result == ERROR_SUCCESS) if (result == ERROR_SUCCESS)
ProcString += value; ProcString += value;
else else
@ -788,7 +788,7 @@ string CSystemInfo::getProc ()
// get processor vendor // get processor vendor
valueSize = 1024; valueSize = 1024;
result = ::RegQueryValueEx (hKey, _T("VendorIdentifier"), NULL, NULL, (LPBYTE)value, &valueSize); result = ::RegQueryValueExA (hKey, "VendorIdentifier", NULL, NULL, (LPBYTE)value, &valueSize);
if (result == ERROR_SUCCESS) if (result == ERROR_SUCCESS)
ProcString += value; ProcString += value;
else else
@ -797,7 +797,7 @@ string CSystemInfo::getProc ()
ProcString += " / "; ProcString += " / ";
// get processor frequency // get processor frequency
result = ::RegQueryValueEx (hKey, _T("~MHz"), NULL, NULL, (LPBYTE)value, &valueSize); result = ::RegQueryValueExA (hKey, "~MHz", NULL, NULL, (LPBYTE)value, &valueSize);
if (result == ERROR_SUCCESS) if (result == ERROR_SUCCESS)
{ {
uint32 freq = *(int *)value; uint32 freq = *(int *)value;
@ -1387,12 +1387,12 @@ bool CSystemInfo::getVideoInfo (std::string &deviceName, uint64 &driverVersion)
} }
// Version dll link // Version dll link
HMODULE hmVersion = LoadLibrary (_T("version")); HMODULE hmVersion = LoadLibraryA ("version.dll");
if (hmVersion) if (hmVersion)
{ {
BOOL (WINAPI* _GetFileVersionInfo)(LPTSTR, DWORD, DWORD, LPVOID) = NULL; BOOL (WINAPI* _GetFileVersionInfo)(LPSTR, DWORD, DWORD, LPVOID) = NULL;
DWORD (WINAPI* _GetFileVersionInfoSize)(LPTSTR, LPDWORD) = NULL; DWORD (WINAPI* _GetFileVersionInfoSize)(LPSTR, LPDWORD) = NULL;
BOOL (WINAPI* _VerQueryValue)(const LPVOID, LPTSTR, LPVOID*, PUINT) = NULL; BOOL (WINAPI* _VerQueryValue)(const LPVOID, LPSTR, LPVOID*, PUINT) = NULL;
*(FARPROC*)&_GetFileVersionInfo = GetProcAddress(hmVersion, "GetFileVersionInfoA"); *(FARPROC*)&_GetFileVersionInfo = GetProcAddress(hmVersion, "GetFileVersionInfoA");
*(FARPROC*)&_GetFileVersionInfoSize = GetProcAddress(hmVersion, "GetFileVersionInfoSizeA"); *(FARPROC*)&_GetFileVersionInfoSize = GetProcAddress(hmVersion, "GetFileVersionInfoSizeA");
*(FARPROC*)&_VerQueryValue = GetProcAddress(hmVersion, "VerQueryValueA"); *(FARPROC*)&_VerQueryValue = GetProcAddress(hmVersion, "VerQueryValueA");

View file

@ -273,14 +273,14 @@ bool CSystemUtils::isScreensaverEnabled()
// SystemParametersInfoA(SPI_GETSCREENSAVEACTIVE, 0, &bRetValue, 0); // SystemParametersInfoA(SPI_GETSCREENSAVEACTIVE, 0, &bRetValue, 0);
// res = (bRetValue == TRUE); // res = (bRetValue == TRUE);
HKEY hKeyScreenSaver = NULL; HKEY hKeyScreenSaver = NULL;
LSTATUS lReturn = RegOpenKeyExA(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &hKeyScreenSaver); LSTATUS lReturn = RegOpenKeyExA(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_QUERY_VALUE, &hKeyScreenSaver);
if (lReturn == ERROR_SUCCESS) if (lReturn == ERROR_SUCCESS)
{ {
DWORD dwType = 0L; DWORD dwType = 0L;
DWORD dwSize = KeyMaxLength; DWORD dwSize = KeyMaxLength;
unsigned char Buffer[KeyMaxLength] = {0}; unsigned char Buffer[KeyMaxLength] = {0};
lReturn = RegQueryValueExA(hKeyScreenSaver, TEXT("SCRNSAVE.EXE"), NULL, &dwType, NULL, &dwSize); lReturn = RegQueryValueExA(hKeyScreenSaver, "SCRNSAVE.EXE", NULL, &dwType, NULL, &dwSize);
// if SCRNSAVE.EXE is present, check also if it's empty // if SCRNSAVE.EXE is present, check also if it's empty
if (lReturn == ERROR_SUCCESS) if (lReturn == ERROR_SUCCESS)
res = (Buffer[0] != '\0'); res = (Buffer[0] != '\0');

View file

@ -40,7 +40,7 @@ using namespace std;
namespace NLMISC { namespace NLMISC {
static CHARFORMAT2 CharFormat; static CHARFORMAT2A CharFormat;
CWinDisplayer::CWinDisplayer(const char *displayerName) : CWindowDisplayer(displayerName), Exit(false) CWinDisplayer::CWinDisplayer(const char *displayerName) : CWindowDisplayer(displayerName), Exit(false)
{ {
@ -221,7 +221,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
ucs.fromUtf8(cwd->_History[cwd->_PosInHistory]); ucs.fromUtf8(cwd->_History[cwd->_PosInHistory]);
// set the text as unicode string // set the text as unicode string
SetWindowTextW(cwd->_HInputEdit, (LPCWSTR)ucs.c_str()); SetWindowTextW(cwd->_HInputEdit, (LPCWSTR)ucs.c_str());
SendMessage (cwd->_HInputEdit, EM_SETSEL, (WPARAM)ucs.size(), (LPARAM)ucs.size()); SendMessageA (cwd->_HInputEdit, EM_SETSEL, (WPARAM)ucs.size(), (LPARAM)ucs.size());
} }
} }
else if (pmf->wParam == VK_DOWN) else if (pmf->wParam == VK_DOWN)
@ -238,7 +238,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
ucs.fromUtf8(cwd->_History[cwd->_PosInHistory]); ucs.fromUtf8(cwd->_History[cwd->_PosInHistory]);
// set the text as unicode string // set the text as unicode string
SetWindowTextW(cwd->_HInputEdit, (LPCWSTR)ucs.c_str()); SetWindowTextW(cwd->_HInputEdit, (LPCWSTR)ucs.c_str());
SendMessage (cwd->_HInputEdit, EM_SETSEL, (WPARAM)ucs.size(), (LPARAM)ucs.size()); SendMessageA (cwd->_HInputEdit, EM_SETSEL, (WPARAM)ucs.size(), (LPARAM)ucs.size());
} }
} }
} }
@ -268,7 +268,7 @@ void CWinDisplayer::updateLabels ()
{ {
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 = CreateWindowW (L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_SIMPLE, 0, 0, 0, 0, _HWnd, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(_HWnd, GWLP_HINSTANCE), NULL);
} }
SendMessage ((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;
} }
@ -427,14 +427,14 @@ void CWinDisplayer::open (string titleBar, bool iconified, sint x, sint y, sint
dwStyle |= WS_HSCROLL; dwStyle |= WS_HSCROLL;
_HEdit = CreateWindowExW(WS_EX_OVERLAPPEDWINDOW, RICHEDIT_CLASSW, L"", dwStyle, 0, _ToolBarHeight, w, h-_ToolBarHeight-_InputEditHeight, _HWnd, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(_HWnd, GWLP_HINSTANCE), NULL); _HEdit = CreateWindowExW(WS_EX_OVERLAPPEDWINDOW, RICHEDIT_CLASSW, L"", dwStyle, 0, _ToolBarHeight, w, h-_ToolBarHeight-_InputEditHeight, _HWnd, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(_HWnd, GWLP_HINSTANCE), NULL);
SendMessage (_HEdit, WM_SETFONT, (WPARAM)_HFont, TRUE); SendMessageA (_HEdit, WM_SETFONT, (WPARAM)_HFont, TRUE);
// set the edit text limit to lot of :) // set the edit text limit to lot of :)
SendMessage (_HEdit, EM_LIMITTEXT, -1, 0); SendMessageA (_HEdit, EM_LIMITTEXT, -1, 0);
CharFormat.cbSize = sizeof(CharFormat); CharFormat.cbSize = sizeof(CharFormat);
CharFormat.dwMask = CFM_COLOR; CharFormat.dwMask = CFM_COLOR;
SendMessage(_HEdit,EM_GETCHARFORMAT,(WPARAM)0,(LPARAM)&CharFormat); SendMessageA(_HEdit,EM_GETCHARFORMAT,(WPARAM)0,(LPARAM)&CharFormat);
CharFormat.dwEffects &= ~CFE_AUTOCOLOR; CharFormat.dwEffects &= ~CFE_AUTOCOLOR;
// create the input edit control // create the input edit control
@ -445,7 +445,7 @@ void CWinDisplayer::open (string titleBar, bool iconified, sint x, sint y, sint
LRESULT dwEvent = SendMessageW(_HInputEdit, EM_GETEVENTMASK, (WPARAM)0, (LPARAM)0); LRESULT dwEvent = SendMessageW(_HInputEdit, EM_GETEVENTMASK, (WPARAM)0, (LPARAM)0);
dwEvent |= ENM_MOUSEEVENTS | ENM_KEYEVENTS | ENM_CHANGE; dwEvent |= ENM_MOUSEEVENTS | ENM_KEYEVENTS | ENM_CHANGE;
SendMessage(_HInputEdit, EM_SETEVENTMASK, (WPARAM)0, (LPARAM)dwEvent); SendMessageA(_HInputEdit, EM_SETEVENTMASK, (WPARAM)0, (LPARAM)dwEvent);
// resize the window // resize the window
RECT rc; RECT rc;
@ -477,8 +477,8 @@ void CWinDisplayer::clear ()
bool focus = (GetFocus() == _HEdit); bool focus = (GetFocus() == _HEdit);
if (focus) if (focus)
{ {
SendMessage(_HEdit,EM_SETOPTIONS,ECOOP_AND,(LPARAM)~ECO_AUTOVSCROLL); SendMessageA(_HEdit,EM_SETOPTIONS,ECOOP_AND,(LPARAM)~ECO_AUTOVSCROLL);
SendMessage(_HEdit,EM_SETOPTIONS,ECOOP_AND,(LPARAM)~ECO_AUTOHSCROLL); SendMessageA(_HEdit,EM_SETOPTIONS,ECOOP_AND,(LPARAM)~ECO_AUTOHSCROLL);
} }
// get number of line // get number of line
@ -534,13 +534,13 @@ void CWinDisplayer::display_main ()
bool focus = (GetFocus() == _HEdit); bool focus = (GetFocus() == _HEdit);
if (focus) if (focus)
{ {
SendMessage(_HEdit,EM_SETOPTIONS,ECOOP_AND,(LPARAM)~ECO_AUTOVSCROLL); SendMessageA(_HEdit,EM_SETOPTIONS,ECOOP_AND,(LPARAM)~ECO_AUTOVSCROLL);
SendMessage(_HEdit,EM_SETOPTIONS,ECOOP_AND,(LPARAM)~ECO_AUTOHSCROLL); SendMessageA(_HEdit,EM_SETOPTIONS,ECOOP_AND,(LPARAM)~ECO_AUTOHSCROLL);
} }
// store old selection // store old selection
DWORD startSel, endSel; DWORD startSel, endSel;
SendMessage (_HEdit, EM_GETSEL, (WPARAM)&startSel, (LPARAM)&endSel); SendMessageA (_HEdit, EM_GETSEL, (WPARAM)&startSel, (LPARAM)&endSel);
// find how many lines we have to remove in the current output to add new lines // find how many lines we have to remove in the current output to add new lines
@ -554,7 +554,7 @@ void CWinDisplayer::display_main ()
if (nblineremove == _HistorySize) if (nblineremove == _HistorySize)
{ {
SendMessage (_HEdit, WM_SETTEXT, 0, (LPARAM) ""); SendMessageA (_HEdit, WM_SETTEXT, 0, (LPARAM) "");
startSel = endSel = -1; startSel = endSel = -1;
} }
else else
@ -594,13 +594,13 @@ void CWinDisplayer::display_main ()
str += ucstring::makeFromUtf8((*it).second); str += ucstring::makeFromUtf8((*it).second);
} }
SendMessage (_HEdit, EM_SETSEL, -1, -1); SendMessageA(_HEdit, EM_SETSEL, -1, -1);
if ((col>>24) == 0) if ((col>>24) == 0)
{ {
// there s a specific color // there s a specific color
CharFormat.crTextColor = RGB ((col>>16)&0xFF, (col>>8)&0xFF, col&0xFF); CharFormat.crTextColor = RGB ((col>>16)&0xFF, (col>>8)&0xFF, col&0xFF);
SendMessage((HWND) _HEdit, EM_SETCHARFORMAT, (WPARAM) SCF_SELECTION, (LPARAM) &CharFormat); SendMessageA(_HEdit, EM_SETCHARFORMAT, (WPARAM) SCF_SELECTION, (LPARAM) &CharFormat);
} }
// add the string to the edit control // add the string to the edit control
@ -608,17 +608,17 @@ void CWinDisplayer::display_main ()
} }
// restore old selection // restore old selection
SendMessage (_HEdit, EM_SETSEL, startSel, endSel); SendMessageA(_HEdit, EM_SETSEL, startSel, endSel);
SendMessage(_HEdit,EM_SETMODIFY,(WPARAM)TRUE,(LPARAM)0); SendMessageA(_HEdit,EM_SETMODIFY,(WPARAM)TRUE,(LPARAM)0);
if (bottom) if (bottom)
SendMessage(_HEdit,WM_VSCROLL,(WPARAM)SB_BOTTOM,(LPARAM)0L); SendMessageA(_HEdit,WM_VSCROLL,(WPARAM)SB_BOTTOM,(LPARAM)0L);
if (focus) if (focus)
{ {
SendMessage(_HEdit,EM_SETOPTIONS,ECOOP_OR,(LPARAM)ECO_AUTOVSCROLL); SendMessageA(_HEdit,EM_SETOPTIONS,ECOOP_OR,(LPARAM)ECO_AUTOVSCROLL);
SendMessage(_HEdit,EM_SETOPTIONS,ECOOP_OR,(LPARAM)ECO_AUTOHSCROLL); SendMessageA(_HEdit,EM_SETOPTIONS,ECOOP_OR,(LPARAM)ECO_AUTOHSCROLL);
} }
} }

View file

@ -373,7 +373,7 @@ bool CPSAPILib::init()
if (_LoadFailed) return false; if (_LoadFailed) return false;
if (!_PSAPILibHandle) if (!_PSAPILibHandle)
{ {
_PSAPILibHandle = LoadLibrary("psapi.dll"); _PSAPILibHandle = LoadLibraryA("psapi.dll");
if (!_PSAPILibHandle) if (!_PSAPILibHandle)
{ {
nlwarning("couldn't load psapi.dll, possibly not supported by os"); nlwarning("couldn't load psapi.dll, possibly not supported by os");

View file

@ -271,7 +271,7 @@ static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARA
GetWindowRect (GetDesktopWindow (), &rectDesktop); GetWindowRect (GetDesktopWindow (), &rectDesktop);
SetWindowPos (hwndDlg, HWND_TOPMOST, (rectDesktop.right-rectDesktop.left-rect.right+rect.left)/2, (rectDesktop.bottom-rectDesktop.top-rect.bottom+rect.top)/2, 0, 0, SWP_NOSIZE); SetWindowPos (hwndDlg, HWND_TOPMOST, (rectDesktop.right-rectDesktop.left-rect.right+rect.left)/2, (rectDesktop.bottom-rectDesktop.top-rect.bottom+rect.top)/2, 0, 0, SWP_NOSIZE);
HICON exitClientDlgIcon = LoadIcon(HInstance, MAKEINTRESOURCE(IDI_MAIN_ICON)); HICON exitClientDlgIcon = LoadIcon(HInstance, MAKEINTRESOURCE(IDI_MAIN_ICON));
::SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) exitClientDlgIcon); ::SendMessageA(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) exitClientDlgIcon);
} }
break; break;
case WM_COMMAND: case WM_COMMAND: