From b50b9471ff522194c657fe4228da646eaa8e5698 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 30 Jul 2019 14:45:38 +0000 Subject: Use WCHAR in stead of TCHAR (almost) everywhere, since we now only support compiling Tcl in UNICODE mode anyway. --- win/tkWinButton.c | 8 ++++---- win/tkWinClipboard.c | 2 +- win/tkWinCursor.c | 2 +- win/tkWinDialog.c | 6 +++--- win/tkWinEmbed.c | 6 +++--- win/tkWinInit.c | 6 +++--- win/tkWinKey.c | 6 +++--- win/tkWinMenu.c | 14 +++++++------- win/tkWinPixmap.c | 6 +++--- win/tkWinScrlbr.c | 2 +- win/tkWinTest.c | 2 +- win/tkWinWm.c | 12 ++++++------ win/tkWinX.c | 8 ++++---- win/ttkWinMonitor.c | 4 ++-- 14 files changed, 42 insertions(+), 42 deletions(-) diff --git a/win/tkWinButton.c b/win/tkWinButton.c index e91857c..52b6e2a 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -131,7 +131,7 @@ InitBoxes(void) ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - hrsrc = FindResource(module, TEXT("buttons"), RT_BITMAP); + hrsrc = FindResource(module, L"buttons", RT_BITMAP); if (hrsrc == NULL) { Tcl_Panic("FindResource() failed for buttons bitmap resource, " "resources in tk_base.rc must be linked into Tk dll or static executable"); @@ -242,15 +242,15 @@ CreateProc( { Window window; HWND parent; - const TCHAR *class; + const WCHAR *class; WinButton *butPtr = (WinButton *)instanceData; parent = Tk_GetHWND(parentWin); if (butPtr->info.type == TYPE_LABEL) { - class = TEXT("STATIC"); + class = L"STATIC"; butPtr->style = SS_OWNERDRAW | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS; } else { - class = TEXT("BUTTON"); + class = L"BUTTON"; butPtr->style = BS_OWNERDRAW | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS; } butPtr->hwnd = CreateWindow(class, NULL, butPtr->style, diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 19874fb..06200d4 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -79,7 +79,7 @@ TkSelGetSelection( goto error; } data = GlobalLock(handle); - Tcl_WinTCharToUtf((TCHAR *)data, -1, &ds); + Tcl_WinTCharToUtf((WCHAR *)data, -1, &ds); GlobalUnlock(handle); } else if (IsClipboardFormatAvailable(CF_TEXT)) { /* diff --git a/win/tkWinCursor.c b/win/tkWinCursor.c index 622ba4d..6a9dc75 100644 --- a/win/tkWinCursor.c +++ b/win/tkWinCursor.c @@ -41,7 +41,7 @@ typedef struct { static struct CursorName { const char *name; - LPCTSTR id; + LPCWSTR id; } cursorNames[] = { {"starting", IDC_APPSTARTING}, {"arrow", IDC_ARROW}, diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index bbf49ca..26d11ed 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -790,7 +790,7 @@ Tk_ChooseColorObjCmd( chooseColor.Flags = CC_RGBINIT | CC_FULLOPEN | CC_ENABLEHOOK; chooseColor.lCustData = (LPARAM) NULL; chooseColor.lpfnHook = (LPOFNHOOKPROC) ColorDlgHookProc; - chooseColor.lpTemplateName = (LPTSTR) interp; + chooseColor.lpTemplateName = (LPWSTR) interp; for (i = 1; i < objc; i += 2) { int index; @@ -2491,7 +2491,7 @@ Tk_ChooseDirectoryObjCmd( if (ofnOpts.titleObj != NULL) { Tcl_WinUtfToTChar(Tcl_GetString(ofnOpts.titleObj), -1, &titleString); - bInfo.lpszTitle = (LPTSTR) Tcl_DStringValue(&titleString); + bInfo.lpszTitle = (LPWSTR) Tcl_DStringValue(&titleString); } else { bInfo.lpszTitle = L"Please choose a directory, then select OK."; } @@ -3151,7 +3151,7 @@ HookProc( Tcl_WinUtfToTChar(Tcl_GetString(phd->titleObj), -1, &title); if (Tcl_DStringLength(&title) > 0) { - SetWindowText(hwndDlg, (LPCTSTR) Tcl_DStringValue(&title)); + SetWindowText(hwndDlg, (LPCWSTR) Tcl_DStringValue(&title)); } Tcl_DStringFree(&title); } diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index 329fd6e..f33a275 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -303,10 +303,10 @@ TkpUseWindow( * order to avoid bug 1096074 in future. */ - TCHAR msg[256]; + WCHAR msg[256]; - wsprintf(msg, TEXT("Unable to get information of window \"%.40hs\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching."), string); - if (IDCANCEL == MessageBox(hwnd, msg, TEXT("Tk Warning"), + wsprintf(msg, L"Unable to get information of window \"%.40hs\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); + if (IDCANCEL == MessageBox(hwnd, msg, L"Tk Warning", MB_OKCANCEL | MB_ICONWARNING)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Operation has been canceled", -1)); diff --git a/win/tkWinInit.c b/win/tkWinInit.c index 977474c..690574e 100644 --- a/win/tkWinInit.c +++ b/win/tkWinInit.c @@ -178,14 +178,14 @@ Tcl_Obj* TkWin32ErrorObj( HRESULT hrError) { - LPTSTR lpBuffer = NULL, p = NULL; - TCHAR sBuffer[30]; + LPWSTR lpBuffer = NULL, p = NULL; + WCHAR sBuffer[30]; Tcl_Obj* errPtr = NULL; Tcl_DString ds; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, (DWORD)hrError, - LANG_NEUTRAL, (LPTSTR)&lpBuffer, 0, NULL); + LANG_NEUTRAL, (LPWSTR)&lpBuffer, 0, NULL); if (lpBuffer == NULL) { lpBuffer = sBuffer; diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 8db34af..c1f9891 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -186,7 +186,7 @@ KeycodeToKeysym( { BYTE keys[256]; int result, deadkey, shift; - TCHAR buf[4]; + WCHAR buf[4]; unsigned int scancode = MapVirtualKey(keycode, 0); /* @@ -572,7 +572,7 @@ TkpSetKeycodeAndState( } } if (keySym >= 0x20) { - result = VkKeyScan((TCHAR) keySym); + result = VkKeyScan((WCHAR) keySym); if (result != -1) { shift = result >> 8; if (shift & 1) @@ -625,7 +625,7 @@ XKeysymToKeycode( } } if (keysym >= 0x20) { - result = VkKeyScan((TCHAR) keysym); + result = VkKeyScan((WCHAR) keysym); if (result != -1) { return (KeyCode) (result & 0xff); } diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index ed2ce93..329c0af 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -19,8 +19,8 @@ * The class of the window for popup menus. */ -#define MENU_CLASS_NAME TEXT("MenuWindowClass") -#define EMBEDDED_MENU_CLASS_NAME TEXT("EmbeddedMenuWindowClass") +#define MENU_CLASS_NAME L"MenuWindowClass" +#define EMBEDDED_MENU_CLASS_NAME L"EmbeddedMenuWindowClass" /* * Used to align a windows bitmap inside a rectangle @@ -573,7 +573,7 @@ ReconfigureWindowsMenu( TkMenuEntry *mePtr; HMENU winMenuHdl = (HMENU) menuPtr->platformData; char *itemText = NULL; - const TCHAR *lpNewItem; + const WCHAR *lpNewItem; UINT flags; UINT itemID; int i, count, systemMenu = 0, base; @@ -610,10 +610,10 @@ ReconfigureWindowsMenu( if ((menuPtr->menuType == MENUBAR) || (menuPtr->menuFlags & MENU_SYSTEM_MENU)) { Tcl_WinUtfToTChar(itemText, -1, &translatedText); - lpNewItem = (const TCHAR *) Tcl_DStringValue(&translatedText); + lpNewItem = (const WCHAR *) Tcl_DStringValue(&translatedText); flags |= MF_STRING; } else { - lpNewItem = (LPCTSTR) mePtr; + lpNewItem = (LPCWSTR) mePtr; flags |= MF_OWNERDRAW; } @@ -3492,7 +3492,7 @@ TkpMenuThreadInit(void) ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - tsdPtr->menuHWND = CreateWindow(MENU_CLASS_NAME, TEXT("MenuWindow"), WS_POPUP, + tsdPtr->menuHWND = CreateWindow(MENU_CLASS_NAME, L"MenuWindow", WS_POPUP, 0, 0, 10, 10, NULL, NULL, Tk_GetHINSTANCE(), NULL); if (!tsdPtr->menuHWND) { @@ -3500,7 +3500,7 @@ TkpMenuThreadInit(void) } tsdPtr->embeddedMenuHWND = - CreateWindow(EMBEDDED_MENU_CLASS_NAME, TEXT("EmbeddedMenuWindow"), + CreateWindow(EMBEDDED_MENU_CLASS_NAME, L"EmbeddedMenuWindow", WS_POPUP, 0, 0, 10, 10, NULL, NULL, Tk_GetHINSTANCE(), NULL); if (!tsdPtr->embeddedMenuHWND) { diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c index aa1ebde..9850e26 100644 --- a/win/tkWinPixmap.c +++ b/win/tkWinPixmap.c @@ -104,9 +104,9 @@ Tk_GetPixmap( FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&lpMsgBuf, 0, NULL)) { - MessageBox(NULL, (LPTSTR) lpMsgBuf, - TEXT("Tk_GetPixmap: Error from CreateDIBSection"), + (LPWSTR)&lpMsgBuf, 0, NULL)) { + MessageBox(NULL, (LPWSTR) lpMsgBuf, + L"Tk_GetPixmap: Error from CreateDIBSection", MB_OK | MB_ICONINFORMATION); LocalFree(lpMsgBuf); } diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index 43a33ee..1edb1d8 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.c @@ -223,7 +223,7 @@ CreateProc( | SBS_HORZ; } - scrollPtr->hwnd = CreateWindow(TEXT("SCROLLBAR"), NULL, style, + scrollPtr->hwnd = CreateWindow(L"SCROLLBAR", NULL, style, Tk_X(tkwin), Tk_Y(tkwin), Tk_Width(tkwin), Tk_Height(tkwin), parent, NULL, Tk_GetHINSTANCE(), NULL); diff --git a/win/tkWinTest.c b/win/tkWinTest.c index e386605..b09fe1b 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -549,7 +549,7 @@ TestgetwindowinfoObjCmd( Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("id", 2), Tcl_NewWideIntObj(GetWindowLongPtr((HWND)(size_t)hwnd, GWL_ID))); - cch = GetWindowText((HWND)(size_t)hwnd, (LPTSTR)buf, cchBuf); + cch = GetWindowText((HWND)(size_t)hwnd, buf, cchBuf); Tcl_WinTCharToUtf(buf, cch * sizeof (WCHAR), &ds); textObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); diff --git a/win/tkWinWm.c b/win/tkWinWm.c index c0f60d8..e41e68d 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -883,7 +883,7 @@ InitWindowClass( class.lpszClassName = TK_WIN_TOPLEVEL_CLASS_NAME; class.lpfnWndProc = WmProc; if (titlebaricon == NULL) { - class.hIcon = LoadIcon(Tk_GetHINSTANCE(), TEXT("tk")); + class.hIcon = LoadIcon(Tk_GetHINSTANCE(), L"tk"); } else { class.hIcon = GetIcon(titlebaricon, ICON_BIG); if (class.hIcon == NULL) { @@ -1248,7 +1248,7 @@ ReadIconFromFile( } Tcl_WinUtfToTChar(file, -1, &ds2); Tcl_DStringFree(&ds); - res = (DWORD *)SHGetFileInfo((TCHAR *)Tcl_DStringValue(&ds2), 0, &sfiSM, + res = (DWORD *)SHGetFileInfo((WCHAR *)Tcl_DStringValue(&ds2), 0, &sfiSM, sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_ICON); if (res != 0) { @@ -1256,7 +1256,7 @@ ReadIconFromFile( unsigned size; Tcl_ResetResult(interp); - res = (DWORD *)SHGetFileInfo((TCHAR *)Tcl_DStringValue(&ds2), 0, &sfi, + res = (DWORD *)SHGetFileInfo((WCHAR *)Tcl_DStringValue(&ds2), 0, &sfi, sizeof(SHFILEINFO), SHGFI_ICON); /* @@ -2131,7 +2131,7 @@ UpdateWrapper( wmPtr->wrapper = CreateWindowEx(wmPtr->exStyle, TK_WIN_TOPLEVEL_CLASS_NAME, - (LPCTSTR) Tcl_DStringValue(&titleString), + (LPCWSTR) Tcl_DStringValue(&titleString), wmPtr->style, x, y, width, height, parentHWND, NULL, Tk_GetHINSTANCE(), NULL); Tcl_DStringFree(&titleString); @@ -5459,7 +5459,7 @@ WmTitleCmd( } if (objc == 3) { if (wrapper) { - TCHAR buf[256]; + WCHAR buf[256]; Tcl_DString titleString; int size = 256; @@ -5485,7 +5485,7 @@ WmTitleCmd( Tcl_DString titleString; Tcl_WinUtfToTChar(wmPtr->title, -1, &titleString); - SetWindowText(wrapper, (LPCTSTR) Tcl_DStringValue(&titleString)); + SetWindowText(wrapper, (LPCWSTR) Tcl_DStringValue(&titleString)); Tcl_DStringFree(&titleString); } } diff --git a/win/tkWinX.c b/win/tkWinX.c index 0cc7765..14075c4 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -127,7 +127,7 @@ TkGetServerInfo( OSVERSIONINFOW os; if (!buffer[0]) { - HANDLE handle = GetModuleHandle(TEXT("NTDLL")); + HANDLE handle = GetModuleHandle(L"NTDLL"); int(__stdcall *getversion)(void *) = (int(__stdcall *)(void *))GetProcAddress(handle, "RtlGetVersion"); os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); @@ -258,7 +258,7 @@ TkWinXInit( if (GetLocaleInfo(LANGIDFROMLCID(PTR2INT(GetKeyboardLayout(0))), LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, - (LPTSTR) &lpCP, sizeof(lpCP)/sizeof(TCHAR)) + (LPWSTR) &lpCP, sizeof(lpCP)/sizeof(WCHAR)) && TranslateCharsetInfo(INT2PTR(lpCP), &lpCs, TCI_SRCCODEPAGE)) { UpdateInputLanguage((int) lpCs.ciCharset); } @@ -346,8 +346,8 @@ TkWinGetPlatformTheme(void) if ((os.dwMajorVersion == 5 && os.dwMinorVersion == 1)) { HKEY hKey; - LPCTSTR szSubKey = TEXT("Control Panel\\Appearance"); - LPCTSTR szCurrent = TEXT("Current"); + LPCWSTR szSubKey = L"Control Panel\\Appearance"; + LPCWSTR szCurrent = L"Current"; DWORD dwSize = 200; char pBuffer[200]; diff --git a/win/ttkWinMonitor.c b/win/ttkWinMonitor.c index 5d9cf0a..e3608f3 100644 --- a/win/ttkWinMonitor.c +++ b/win/ttkWinMonitor.c @@ -72,8 +72,8 @@ CreateThemeMonitorWindow(HINSTANCE hinst, Tcl_Interp *interp) { WNDCLASSEX wc; HWND hwnd = NULL; - TCHAR title[32] = TEXT("TtkMonitorWindow"); - TCHAR name[32] = TEXT("TtkMonitorClass"); + WCHAR title[32] = L"TtkMonitorWindow"; + WCHAR name[32] = L"TtkMonitorClass"; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; -- cgit v0.12