summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-09-20 07:25:01 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-09-20 07:25:01 (GMT)
commit120867f0051af9fe307813a5bdcdde9da658885b (patch)
tree64d493883e637a9cf2ea192c2e65e28408fb6b68
parentda495f0b97edc339cdaa287f42ab8abf49be8c43 (diff)
parent8d11cc8eacd0e8ba40c491c14435adce2a969075 (diff)
downloadtk-120867f0051af9fe307813a5bdcdde9da658885b.zip
tk-120867f0051af9fe307813a5bdcdde9da658885b.tar.gz
tk-120867f0051af9fe307813a5bdcdde9da658885b.tar.bz2
Merge trunk
-rw-r--r--generic/tkPanedWindow.c2
-rw-r--r--generic/tkWindow.c2
-rw-r--r--generic/ttk/ttkFrame.c2
-rw-r--r--generic/ttk/ttkTreeview.c7
-rw-r--r--unix/tkUnixFont.c63
-rw-r--r--unix/tkUnixSelect.c4
-rw-r--r--win/Makefile.in2
-rw-r--r--win/makefile.vc2
-rw-r--r--win/tkWinButton.c8
-rw-r--r--win/tkWinCursor.c4
-rw-r--r--win/tkWinDialog.c58
-rw-r--r--win/tkWinEmbed.c4
-rw-r--r--win/tkWinFont.c93
-rw-r--r--win/tkWinImage.c1
-rw-r--r--win/tkWinInit.c4
-rw-r--r--win/tkWinMenu.c22
-rw-r--r--win/tkWinPixmap.c4
-rw-r--r--win/tkWinScrlbr.c2
-rw-r--r--win/tkWinTest.c13
-rw-r--r--win/tkWinWindow.c4
-rw-r--r--win/tkWinWm.c31
-rw-r--r--win/tkWinX.c16
-rw-r--r--win/ttkWinMonitor.c14
-rw-r--r--win/ttkWinXPTheme.c2
24 files changed, 189 insertions, 175 deletions
diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c
index c605bf3..a34a372 100644
--- a/generic/tkPanedWindow.c
+++ b/generic/tkPanedWindow.c
@@ -304,7 +304,7 @@ static const Tk_OptionSpec optionSpecs[] = {
0, orientStrings, GEOMETRY},
{TK_OPTION_BORDER, "-proxybackground", "proxyBackground", "ProxyBackground",
0, -1, offsetof(PanedWindow, proxyBackground), TK_OPTION_NULL_OK,
- (ClientData) DEF_PANEDWINDOW_BG_MONO},
+ (ClientData) DEF_PANEDWINDOW_BG_MONO, 0},
{TK_OPTION_PIXELS, "-proxyborderwidth", "proxyBorderWidth", "ProxyBorderWidth",
DEF_PANEDWINDOW_PROXYBORDER, offsetof(PanedWindow, proxyBorderWidthPtr),
offsetof(PanedWindow, proxyBorderWidth), 0, 0, GEOMETRY},
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 631c6e7..242dd46 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -2862,7 +2862,7 @@ TkCygwinMainEx(
wcscpy(name+len, L".dll");
memcpy(name+len-8, L"libtk8", 6 * sizeof(WCHAR));
- tkcygwindll = LoadLibrary(name);
+ tkcygwindll = LoadLibraryW(name);
if (!tkcygwindll) {
/* dll is not present */
return 0;
diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c
index 794b184..bb3dd35 100644
--- a/generic/ttk/ttkFrame.c
+++ b/generic/ttk/ttkFrame.c
@@ -439,8 +439,10 @@ static void LabelframeDoLayout(void *recordPtr)
*/
switch (LabelAnchorSide(style.labelAnchor)) {
case TTK_SIDE_LEFT: borderParcel.x -= lw / 2;
+ /* FALLTHRU */
case TTK_SIDE_RIGHT: borderParcel.width += lw/2; break;
case TTK_SIDE_TOP: borderParcel.y -= lh / 2;
+ /* FALLTHRU */
case TTK_SIDE_BOTTOM: borderParcel.height += lh / 2; break;
}
}
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index 822a4a6..5e5c2f6 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -1230,9 +1230,10 @@ static int ConfigureColumn(
if (mask & GEOMETRY_CHANGED) {
if (!Tk_IsMapped(tv->core.tkwin)) {
TtkResizeWidget(&tv->core);
- }
- RecomputeSlack(tv);
- ResizeColumns(tv, TreeWidth(tv));
+ } else {
+ RecomputeSlack(tv);
+ ResizeColumns(tv, TreeWidth(tv));
+ }
}
TtkRedisplayWidget(&tv->core);
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index 908deeb..3c1ce65 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -35,10 +35,10 @@ static const char encodingList[][10] = {
* family": the foundry, face name, and charset.
*/
-#define FONTMAP_SHIFT 12
+#define FONTMAP_SHIFT 10
-#define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT))
#define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT)
+#define FONTMAP_PAGES (0x30000 / FONTMAP_BITSPERPAGE)
typedef struct FontFamily {
struct FontFamily *nextPtr; /* Next in list of all known font families. */
@@ -391,7 +391,7 @@ ControlUtfProc(
const char *srcStart, *srcEnd;
char *dstStart, *dstEnd;
int ch, result;
- static const char hexChars[] = "0123456789abcdef";
+ static const char hexChars[] = "0123456789ABCDEF";
static const char mapChars[] = {
0, 0, 0, 0, 0, 0, 0,
'a', 'b', 't', 'n', 'v', 'f', 'r'
@@ -412,15 +412,15 @@ ControlUtfProc(
}
src += TkUtfToUniChar(src, &ch);
dst[0] = '\\';
- if (((size_t) ch < sizeof(mapChars)) && (mapChars[ch] != 0)) {
+ if (((size_t)ch < sizeof(mapChars)) && (mapChars[ch] != 0)) {
dst[1] = mapChars[ch];
dst += 2;
- } else if (ch < 256) {
+ } else if ((size_t)ch < 256) {
dst[1] = 'x';
dst[2] = hexChars[(ch >> 4) & 0xf];
dst[3] = hexChars[ch & 0xf];
dst += 4;
- } else if (ch < 0x10000) {
+ } else if ((size_t)ch < 0x10000) {
dst[1] = 'u';
dst[2] = hexChars[(ch >> 12) & 0xf];
dst[3] = hexChars[(ch >> 8) & 0xf];
@@ -430,10 +430,10 @@ ControlUtfProc(
} else {
/* TODO we can do better here */
dst[1] = 'u';
- dst[2] = 'f';
- dst[3] = 'f';
- dst[4] = 'f';
- dst[5] = 'd';
+ dst[2] = 'F';
+ dst[3] = 'F';
+ dst[4] = 'F';
+ dst[5] = 'D';
dst += 6;
}
}
@@ -449,7 +449,6 @@ ControlUtfProc(
* Ucs2beToUtfProc --
*
* Convert from UCS-2BE (big-endian 16-bit Unicode) to UTF-8.
- * This is only defined on LE machines.
*
* Results:
* Returns TCL_OK if conversion was successful.
@@ -498,6 +497,11 @@ Ucs2beToUtfProc(
result = TCL_CONVERT_MULTIBYTE;
srcLen--;
}
+ /* If last code point is a high surrogate, we cannot handle that yet */
+ if ((srcLen >= 2) && ((src[srcLen - 2] & 0xFC) == 0xD8)) {
+ result = TCL_CONVERT_MULTIBYTE;
+ srcLen -= 2;
+ }
srcStart = src;
srcEnd = src + srcLen;
@@ -572,7 +576,11 @@ UtfToUcs2beProc(
{
const char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd;
int result, numChars;
- Tcl_UniChar ch;
+ Tcl_UniChar *chPtr = (Tcl_UniChar *)statePtr;
+
+ if (flags & TCL_ENCODING_START) {
+ *statePtr = 0;
+ }
srcStart = src;
srcEnd = src + srcLen;
@@ -591,15 +599,14 @@ UtfToUcs2beProc(
* If there is more string to follow, this will ensure that the
* last UTF-8 character in the source buffer hasn't been cut off.
*/
-
result = TCL_CONVERT_MULTIBYTE;
break;
}
if (dst > dstEnd) {
result = TCL_CONVERT_NOSPACE;
break;
- }
- src += Tcl_UtfToUniChar(src, &ch);
+ }
+ src += Tcl_UtfToUniChar(src, chPtr);
/*
* Ensure big-endianness (store big bits first).
@@ -607,8 +614,9 @@ UtfToUcs2beProc(
* sure to work in char* for Tcl_UtfToUniChar alignment. [Bug 1122671]
*/
- *dst++ = (ch >> 8);
- *dst++ = (ch & 0xFF);
+
+ *dst++ = (char)(*chPtr >> 8);
+ *dst++ = (char)*chPtr;
}
*srcReadPtr = src - srcStart;
*dstWrotePtr = dst - dstStart;
@@ -1967,11 +1975,11 @@ FindSubFontForChar(
SubFont *subFontPtr;
Tcl_DString ds;
- if (FontMapLookup(&fontPtr->subFontArray[0], ch)) {
- return &fontPtr->subFontArray[0];
+ if (ch < 0 || ch > 0x30000) {
+ ch = 0xfffd;
}
- for (i = 1; i < fontPtr->numSubFonts; i++) {
+ for (i = 0; i < fontPtr->numSubFonts; i++) {
if (FontMapLookup(&fontPtr->subFontArray[i], ch)) {
return &fontPtr->subFontArray[i];
}
@@ -2121,6 +2129,9 @@ FontMapLookup(
{
int row, bitOffset;
+ if (ch < 0 || ch >= 0x30000) {
+ return 0;
+ }
row = ch >> FONTMAP_SHIFT;
if (subFontPtr->fontMap[row] == NULL) {
FontMapLoadPage(subFontPtr, row);
@@ -2161,12 +2172,14 @@ FontMapInsert(
{
int row, bitOffset;
- row = ch >> FONTMAP_SHIFT;
- if (subFontPtr->fontMap[row] == NULL) {
- FontMapLoadPage(subFontPtr, row);
+ if (ch >= 0 && ch < 0x30000) {
+ row = ch >> FONTMAP_SHIFT;
+ if (subFontPtr->fontMap[row] == NULL) {
+ FontMapLoadPage(subFontPtr, row);
+ }
+ bitOffset = ch & (FONTMAP_BITSPERPAGE - 1);
+ subFontPtr->fontMap[row][bitOffset >> 3] |= 1 << (bitOffset & 7);
}
- bitOffset = ch & (FONTMAP_BITSPERPAGE - 1);
- subFontPtr->fontMap[row][bitOffset >> 3] |= 1 << (bitOffset & 7);
}
/*
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c
index b6e980e..11161b7 100644
--- a/unix/tkUnixSelect.c
+++ b/unix/tkUnixSelect.c
@@ -21,7 +21,7 @@ typedef struct ConvertInfo {
* offset of the next chunk of data to
* transfer. */
Tcl_EncodingState state; /* The encoding state needed across chunks. */
- char buffer[4]; /* A buffer to hold part of a UTF character
+ char buffer[4]; /* A buffer to hold part of a UTF character
* that is split across chunks.*/
} ConvertInfo;
@@ -446,7 +446,7 @@ TkSelPropProc(
* Preserve any left-over bytes.
*/
- if (srcLen > 4) {
+ if (srcLen > 3) {
Tcl_Panic("selection conversion left too many bytes unconverted");
}
memcpy(incrPtr->converts[i].buffer, src, srcLen + 1);
diff --git a/win/Makefile.in b/win/Makefile.in
index 1020495..db61eae 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -168,7 +168,7 @@ LDFLAGS_OPTIMIZE = @LDFLAGS_OPTIMIZE@
#CFLAGS = $(CFLAGS_DEBUG)
#CFLAGS = $(CFLAGS_OPTIMIZE)
#CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE)
-CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -DUNICODE -D_UNICODE -D_ATL_XP_TARGETING -DTCL_UTF_MAX=3
+CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -DUNICODE -D_UNICODE -D_ATL_XP_TARGETING
# Special compiler flags to use when building man2tcl on Windows.
MAN2TCLFLAGS = @MAN2TCLFLAGS@
diff --git a/win/makefile.vc b/win/makefile.vc
index 3256dc5..c6eef5c 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -326,7 +326,7 @@ CONFIG_DEFS =-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 \
-DTK_NO_DEPRECATED=1
!endif
-PRJ_DEFINES = -DBUILD_ttk $(CONFIG_DEFS) -Dinline=__inline -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DTCL_UTF_MAX=3
+PRJ_DEFINES = -DBUILD_ttk $(CONFIG_DEFS) -Dinline=__inline -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE
# Additional Link libraries needed beyond those in rules.vc
PRJ_LIBS = netapi32.lib gdi32.lib user32.lib userenv.lib
diff --git a/win/tkWinButton.c b/win/tkWinButton.c
index 48f9109..c471cd2 100644
--- a/win/tkWinButton.c
+++ b/win/tkWinButton.c
@@ -131,9 +131,9 @@ InitBoxes(void)
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- hrsrc = FindResource(module, L"buttons", RT_BITMAP);
+ hrsrc = FindResourceW(module, L"buttons", RT_BITMAP);
if (hrsrc == NULL) {
- Tcl_Panic("FindResource() failed for buttons bitmap resource, "
+ Tcl_Panic("FindResourceW() failed for buttons bitmap resource, "
"resources in tk_base.rc must be linked into Tk dll or static executable");
} else {
hblk = LoadResource(module, hrsrc);
@@ -253,7 +253,7 @@ CreateProc(
class = L"BUTTON";
butPtr->style = BS_OWNERDRAW | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
}
- butPtr->hwnd = CreateWindow(class, NULL, butPtr->style,
+ butPtr->hwnd = CreateWindowW(class, NULL, butPtr->style,
Tk_X(tkwin), Tk_Y(tkwin), Tk_Width(tkwin), Tk_Height(tkwin),
parent, NULL, Tk_GetHINSTANCE(), NULL);
SetWindowPos(butPtr->hwnd, HWND_TOP, 0, 0, 0, 0,
@@ -1300,7 +1300,7 @@ ButtonProc(
return 0;
}
}
-
+ /* FALLTHRU */
default:
if (Tk_TranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
return result;
diff --git a/win/tkWinCursor.c b/win/tkWinCursor.c
index 6a9dc75..3fe9899 100644
--- a/win/tkWinCursor.c
+++ b/win/tkWinCursor.c
@@ -145,7 +145,7 @@ TkGetCursorByName(
for (namePtr = cursorNames; namePtr->name != NULL; namePtr++) {
if (strcmp(namePtr->name, argv[0]) == 0) {
- cursorPtr->winCursor = LoadCursor(NULL, namePtr->id);
+ cursorPtr->winCursor = LoadCursorW(NULL, namePtr->id);
break;
}
}
@@ -253,7 +253,7 @@ TkpSetCursor(
TkWinCursor *winCursor = (TkWinCursor *) cursor;
if (winCursor == NULL || winCursor->winCursor == NULL) {
- hcursor = LoadCursor(NULL, TK_DEFAULT_CURSOR);
+ hcursor = LoadCursorW(NULL, TK_DEFAULT_CURSOR);
} else {
hcursor = winCursor->winCursor;
}
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index fbb5729..dbbca28 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -637,7 +637,7 @@ static void LoadShellProcs()
if (shell32_handle != NULL)
return; /* We have already been through here. */
- shell32_handle = GetModuleHandle(L"shell32.dll");
+ shell32_handle = GetModuleHandleW(L"shell32.dll");
if (shell32_handle == NULL) /* Should never happen but check anyways. */
return;
@@ -754,7 +754,7 @@ Tk_ChooseColorObjCmd(
Tk_Window tkwin = clientData, parent;
HWND hWnd;
int i, oldMode, winCode, result;
- CHOOSECOLOR chooseColor;
+ CHOOSECOLORW chooseColor;
static int inited = 0;
static COLORREF dwCustColors[16];
static long oldColor; /* the color selected last time */
@@ -842,7 +842,7 @@ Tk_ChooseColorObjCmd(
chooseColor.hwndOwner = hWnd;
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
- winCode = ChooseColor(&chooseColor);
+ winCode = ChooseColorW(&chooseColor);
(void) Tcl_SetServiceMode(oldMode);
/*
@@ -923,7 +923,7 @@ ColorDlgHookProc(
Tcl_DString ds;
Tcl_DStringInit(&ds);
- SetWindowText(hDlg, Tcl_UtfToWCharDString(title, -1, &ds));
+ SetWindowTextW(hDlg, Tcl_UtfToWCharDString(title, -1, &ds));
Tcl_DStringFree(&ds);
}
if (tsdPtr->debugFlag) {
@@ -1569,7 +1569,7 @@ vamoose: /* (hr != 0) => error */
*/
static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper)
{
- OPENFILENAME ofn;
+ OPENFILENAMEW ofn;
OFNData ofnData;
int cdlgerr;
int filterIndex = 0, result = TCL_ERROR, winCode, oldMode;
@@ -1678,9 +1678,9 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
if (oper != OFN_FILE_SAVE) {
- winCode = GetOpenFileName(&ofn);
+ winCode = GetOpenFileNameW(&ofn);
} else {
- winCode = GetSaveFileName(&ofn);
+ winCode = GetSaveFileNameW(&ofn);
}
Tcl_SetServiceMode(oldMode);
EatSpuriousMessageBugFix();
@@ -2437,7 +2437,7 @@ Tk_ChooseDirectoryObjCmd(
WCHAR path[MAX_PATH];
int oldMode, result;
LPCITEMIDLIST pidl; /* Returned by browser */
- BROWSEINFO bInfo; /* Used by browser */
+ BROWSEINFOW bInfo; /* Used by browser */
ChooseDir cdCBData; /* Structure to pass back and forth */
LPMALLOC pMalloc; /* Used by shell */
HWND hWnd;
@@ -2478,7 +2478,7 @@ Tk_ChooseDirectoryObjCmd(
/* Convert possible relative path to full path to keep dialog happy. */
- GetFullPathName(uniStr, MAX_PATH, saveDir, NULL);
+ GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL);
wcsncpy(cdCBData.initDir, saveDir, MAX_PATH);
}
@@ -2499,7 +2499,7 @@ Tk_ChooseDirectoryObjCmd(
bInfo.pszDisplayName = path;
bInfo.pidlRoot = NULL;
if (wcslen(cdCBData.initDir) == 0) {
- GetCurrentDirectory(MAX_PATH, cdCBData.initDir);
+ GetCurrentDirectoryW(MAX_PATH, cdCBData.initDir);
}
bInfo.lParam = (LPARAM) &cdCBData;
@@ -2541,13 +2541,13 @@ Tk_ChooseDirectoryObjCmd(
*/
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
- GetCurrentDirectory(MAX_PATH, saveDir);
+ GetCurrentDirectoryW(MAX_PATH, saveDir);
if (SHGetMalloc(&pMalloc) == NOERROR) {
/*
* XXX - MSDN says CoInitialize must have been called before
* SHBrowseForFolder can be used but don't see that called anywhere.
*/
- pidl = SHBrowseForFolder(&bInfo);
+ pidl = SHBrowseForFolderW(&bInfo);
/*
* This is a fix for Windows 2000, which seems to modify the folder
@@ -2562,7 +2562,7 @@ Tk_ChooseDirectoryObjCmd(
*/
if (pidl != NULL) {
- if (!SHGetPathFromIDList(pidl, path)) {
+ if (!SHGetPathFromIDListW(pidl, path)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"error: not a file system folder", -1));
Tcl_SetErrorCode(interp, "TK", "DIRDIALOG", "PSEUDO", NULL);
@@ -2573,7 +2573,7 @@ Tk_ChooseDirectoryObjCmd(
}
pMalloc->lpVtbl->Release(pMalloc);
}
- SetCurrentDirectory(saveDir);
+ SetCurrentDirectoryW(saveDir);
Tcl_SetServiceMode(oldMode);
/*
@@ -2669,7 +2669,7 @@ ChooseDirectoryValidateProc(
MAX_PATH);
Tcl_DStringFree(&initDirString);
- if (SetCurrentDirectory(string) == 0) {
+ if (SetCurrentDirectoryW(string) == 0) {
/*
* Get the full path name to the user entry, at this point it does
@@ -2677,17 +2677,17 @@ ChooseDirectoryValidateProc(
* it.
*/
- GetFullPathName(string, MAX_PATH,
+ GetFullPathNameW(string, MAX_PATH,
chooseDirSharedData->retDir, NULL);
if (chooseDirSharedData->mustExist) {
/*
* User HAS to select a valid directory.
*/
- wsprintf(selDir, L"Directory '%s' does not exist,\n"
+ wsprintfW(selDir, L"Directory '%s' does not exist,\n"
L"please select or enter an existing directory.",
chooseDirSharedData->retDir);
- MessageBox(NULL, selDir, NULL, MB_ICONEXCLAMATION|MB_OK);
+ MessageBoxW(NULL, selDir, NULL, MB_ICONEXCLAMATION|MB_OK);
chooseDirSharedData->retDir[0] = '\0';
return 1;
}
@@ -2697,7 +2697,7 @@ ChooseDirectoryValidateProc(
* directory in utfRetDir.
*/
- GetCurrentDirectory(MAX_PATH, chooseDirSharedData->retDir);
+ GetCurrentDirectoryW(MAX_PATH, chooseDirSharedData->retDir);
return 0;
}
return 0;
@@ -2712,7 +2712,7 @@ ChooseDirectoryValidateProc(
* Not called when user changes edit box directly.
*/
- if (SHGetPathFromIDList((LPITEMIDLIST) lParam, selDir)) {
+ if (SHGetPathFromIDListW((LPITEMIDLIST) lParam, selDir)) {
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM) selDir);
// enable the OK button
SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
@@ -2731,7 +2731,7 @@ ChooseDirectoryValidateProc(
WCHAR *initDir = chooseDirSharedData->initDir;
- SetCurrentDirectory(initDir);
+ SetCurrentDirectoryW(initDir);
if (*initDir == '\\') {
/*
@@ -2953,7 +2953,7 @@ Tk_MessageBoxObjCmd(
titlePtr = L"";
Tcl_DStringInit(&titleBuf);
}
- winCode = MessageBox(hWnd, tmpPtr, titlePtr, flags);
+ winCode = MessageBoxW(hWnd, tmpPtr, titlePtr, flags);
Tcl_DStringFree(&titleBuf);
Tcl_DStringFree(&tmpBuf);
UnhookWindowsHookEx(tsdPtr->hMsgBoxHook);
@@ -3076,7 +3076,7 @@ ConvertExternalFilename(
static Tcl_Obj *
GetFontObj(
HDC hdc,
- LOGFONT *plf)
+ LOGFONTW *plf)
{
Tcl_DString ds;
Tcl_Obj *resObj;
@@ -3113,7 +3113,7 @@ ApplyLogfont(
Tcl_Interp *interp,
Tcl_Obj *cmdObj,
HDC hdc,
- LOGFONT *logfontPtr)
+ LOGFONTW *logfontPtr)
{
int objc;
Tcl_Obj **objv, **tmpv;
@@ -3173,7 +3173,7 @@ HookProc(
Tcl_DStringInit(&title);
Tcl_UtfToWCharDString(Tcl_GetString(phd->titleObj), -1, &title);
if (Tcl_DStringLength(&title) > 0) {
- SetWindowText(hwndDlg, (LPCWSTR) Tcl_DStringValue(&title));
+ SetWindowTextW(hwndDlg, (LPCWSTR) Tcl_DStringValue(&title));
}
Tcl_DStringFree(&title);
}
@@ -3206,7 +3206,7 @@ HookProc(
*/
if (WM_COMMAND == msg && LOWORD(wParam) == 1026) {
- LOGFONT lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0}};
+ LOGFONTW lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0}};
HDC hdc = GetDC(hwndDlg);
SendMessage(hwndDlg, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM) &lf);
@@ -3445,8 +3445,8 @@ FontchooserShowCmd(
{
Tcl_DString ds;
Tk_Window tkwin = clientData, parent;
- CHOOSEFONT cf;
- LOGFONT lf;
+ CHOOSEFONTW cf;
+ LOGFONTW lf;
HDC hdc;
HookData *hdPtr;
int r = TCL_OK, oldMode = 0;
@@ -3522,7 +3522,7 @@ FontchooserShowCmd(
if (TCL_OK == r) {
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
- if (ChooseFont(&cf)) {
+ if (ChooseFontW(&cf)) {
if (hdPtr->cmdObj) {
ApplyLogfont(hdPtr->interp, hdPtr->cmdObj, hdc, &lf);
}
diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c
index f33a275..62e3462 100644
--- a/win/tkWinEmbed.c
+++ b/win/tkWinEmbed.c
@@ -305,8 +305,8 @@ TkpUseWindow(
WCHAR msg[256];
- 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",
+ wsprintfW(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 == MessageBoxW(hwnd, msg, L"Tk Warning",
MB_OKCANCEL | MB_ICONWARNING)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"Operation has been canceled", -1));
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 6cdce05..a0c16b5 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -26,10 +26,10 @@
* Under Windows, a "font family" is uniquely identified by its face name.
*/
-#define FONTMAP_SHIFT 12
+#define FONTMAP_SHIFT 10
-#define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT))
#define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT)
+#define FONTMAP_PAGES (0x30000 / FONTMAP_BITSPERPAGE)
typedef struct FontFamily {
struct FontFamily *nextPtr; /* Next in list of all known font families. */
@@ -213,7 +213,7 @@ static inline void InitSubFont(HDC hdc, HFONT hFont, int base,
SubFont *subFontPtr);
static int CreateNamedSystemLogFont(Tcl_Interp *interp,
Tk_Window tkwin, const char* name,
- LOGFONT* logFontPtr);
+ LOGFONTW* logFontPtr);
static int CreateNamedSystemFont(Tcl_Interp *interp,
Tk_Window tkwin, const char* name, HFONT hFont);
static int LoadFontRanges(HDC hdc, HFONT hFont,
@@ -229,13 +229,13 @@ static inline HFONT SelectFont(HDC hdc, WinFont *fontPtr,
SubFont *subFontPtr, double angle);
static inline void SwapLong(PULONG p);
static inline void SwapShort(USHORT *p);
-static int CALLBACK WinFontCanUseProc(ENUMLOGFONT *lfPtr,
+static int CALLBACK WinFontCanUseProc(ENUMLOGFONTW *lfPtr,
NEWTEXTMETRIC *tmPtr, int fontType,
LPARAM lParam);
-static int CALLBACK WinFontExistProc(ENUMLOGFONT *lfPtr,
+static int CALLBACK WinFontExistProc(ENUMLOGFONTW *lfPtr,
NEWTEXTMETRIC *tmPtr, int fontType,
LPARAM lParam);
-static int CALLBACK WinFontFamilyEnumProc(ENUMLOGFONT *lfPtr,
+static int CALLBACK WinFontFamilyEnumProc(ENUMLOGFONTW *lfPtr,
NEWTEXTMETRIC *tmPtr, int fontType,
LPARAM lParam);
@@ -331,12 +331,12 @@ CreateNamedSystemLogFont(
Tcl_Interp *interp,
Tk_Window tkwin,
const char* name,
- LOGFONT* logFontPtr)
+ LOGFONTW* logFontPtr)
{
HFONT hFont;
int r;
- hFont = CreateFontIndirect(logFontPtr);
+ hFont = CreateFontIndirectW(logFontPtr);
r = CreateNamedSystemFont(interp, tkwin, name, hFont);
DeleteObject((HGDIOBJ)hFont);
return r;
@@ -392,8 +392,8 @@ TkWinSetupSystemFonts(
Tcl_Interp *interp;
Tk_Window tkwin;
const TkStateMap *mapPtr;
- NONCLIENTMETRICS ncMetrics;
- ICONMETRICS iconMetrics;
+ NONCLIENTMETRICSW ncMetrics;
+ ICONMETRICSW iconMetrics;
HFONT hFont;
interp = (Tcl_Interp *) mainPtr->interp;
@@ -444,7 +444,7 @@ TkWinSetupSystemFonts(
*/
{
- LOGFONT lfFixed = {
+ LOGFONTW lfFixed = {
0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L""
};
@@ -651,7 +651,7 @@ TkpGetFontFamilies(
* because it only exists under NT.
*/
- EnumFontFamilies(hdc, NULL, (FONTENUMPROC) WinFontFamilyEnumProc,
+ EnumFontFamiliesW(hdc, NULL, (FONTENUMPROCW) WinFontFamilyEnumProc,
(LPARAM) resultObj);
ReleaseDC(hwnd, hdc);
Tcl_SetObjResult(interp, resultObj);
@@ -659,7 +659,7 @@ TkpGetFontFamilies(
static int CALLBACK
WinFontFamilyEnumProc(
- ENUMLOGFONT *lfPtr, /* Logical-font data. */
+ ENUMLOGFONTW *lfPtr, /* Logical-font data. */
NEWTEXTMETRIC *tmPtr, /* Physical-font data (not used). */
int fontType, /* Type of font (not used). */
LPARAM lParam) /* Result object to hold result. */
@@ -1575,22 +1575,7 @@ InitFont(
GetTextMetrics(hdc, &tm);
- /*
- * On any version NT, there may fonts with international names. Use the
- * NT-only Unicode version of GetTextFace to get the font's name. If we
- * used the ANSI version on a non-internationalized version of NT, we
- * would get a font name with '?' replacing all the international
- * characters.
- *
- * On a non-internationalized verson of 95, fonts with international names
- * are not allowed, so the ANSI version of GetTextFace will work. On an
- * internationalized version of 95, there may be fonts with international
- * names; the ANSI version will work, fetching the name in the
- * international system code page. Can't use the Unicode version of
- * GetTextFace because it only exists under NT.
- */
-
- GetTextFace(hdc, LF_FACESIZE, buf);
+ GetTextFaceW(hdc, LF_FACESIZE, buf);
Tcl_DStringInit(&faceString);
Tcl_WCharToUtfDString(buf, wcslen(buf), &faceString);
@@ -1768,7 +1753,7 @@ AllocFontFamily(
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
hFont = SelectObject(hdc, hFont);
- GetTextFace(hdc, LF_FACESIZE, buf);
+ GetTextFaceW(hdc, LF_FACESIZE, buf);
Tcl_DStringInit(&faceString);
Tcl_WCharToUtfDString(buf, wcslen(buf), &faceString);
faceName = Tk_GetUid(Tcl_DStringValue(&faceString));
@@ -1946,7 +1931,7 @@ FindSubFontForChar(
SubFont *subFontPtr;
Tcl_DString ds;
- if (ch < BASE_CHARS) {
+ if ((ch < BASE_CHARS) || (ch >= 0x30000)) {
return &fontPtr->subFontArray[0];
}
@@ -2031,7 +2016,7 @@ FindSubFontForChar(
canUse.ch = ch;
canUse.subFontPtr = NULL;
canUse.subFontPtrPtr = subFontPtrPtr;
- EnumFontFamilies(hdc, NULL, (FONTENUMPROC) WinFontCanUseProc,
+ EnumFontFamiliesW(hdc, NULL, (FONTENUMPROCW) WinFontCanUseProc,
(LPARAM) &canUse);
subFontPtr = canUse.subFontPtr;
@@ -2053,7 +2038,7 @@ FindSubFontForChar(
static int CALLBACK
WinFontCanUseProc(
- ENUMLOGFONT *lfPtr, /* Logical-font data. */
+ ENUMLOGFONTW *lfPtr, /* Logical-font data. */
NEWTEXTMETRIC *tmPtr, /* Physical-font data (not used). */
int fontType, /* Type of font (not used). */
LPARAM lParam) /* Result object to hold result. */
@@ -2119,6 +2104,10 @@ FontMapLookup(
{
int row, bitOffset;
+ if (ch < 0 || ch >= 0x30000) {
+ return 0;
+ }
+
row = ch >> FONTMAP_SHIFT;
if (subFontPtr->fontMap[row] == NULL) {
FontMapLoadPage(subFontPtr, row);
@@ -2159,12 +2148,14 @@ FontMapInsert(
{
int row, bitOffset;
- row = ch >> FONTMAP_SHIFT;
- if (subFontPtr->fontMap[row] == NULL) {
- FontMapLoadPage(subFontPtr, row);
+ if (ch >= 0 && ch < 0x30000) {
+ row = ch >> FONTMAP_SHIFT;
+ if (subFontPtr->fontMap[row] == NULL) {
+ FontMapLoadPage(subFontPtr, row);
+ }
+ bitOffset = ch & (FONTMAP_BITSPERPAGE - 1);
+ subFontPtr->fontMap[row][bitOffset >> 3] |= 1 << (bitOffset & 7);
}
- bitOffset = ch & (FONTMAP_BITSPERPAGE - 1);
- subFontPtr->fontMap[row][bitOffset >> 3] |= 1 << (bitOffset & 7);
}
/*
@@ -2480,7 +2471,7 @@ GetScreenFont(
{
Tcl_DString ds;
HFONT hFont;
- LOGFONT lf;
+ LOGFONTW lf;
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -pixelSize;
@@ -2501,7 +2492,7 @@ GetScreenFont(
wcsncpy(lf.lfFaceName, (WCHAR *)Tcl_DStringValue(&ds), LF_FACESIZE-1);
Tcl_DStringFree(&ds);
lf.lfFaceName[LF_FACESIZE-1] = 0;
- hFont = CreateFontIndirect(&lf);
+ hFont = CreateFontIndirectW(&lf);
return hFont;
}
@@ -2532,6 +2523,22 @@ FamilyExists(
int result;
Tcl_DString faceString;
+ /*
+ * Just immediately rule out the following fonts, because they look so
+ * ugly on windows. The caller's fallback mechanism will cause the
+ * corresponding appropriate TrueType fonts to be selected.
+ */
+
+ if (strcasecmp(faceName, "Courier") == 0) {
+ return 0;
+ }
+ if (strcasecmp(faceName, "Times") == 0) {
+ return 0;
+ }
+ if (strcasecmp(faceName, "Helvetica") == 0) {
+ return 0;
+ }
+
Tcl_UtfToExternalDString(systemEncoding, faceName, -1, &faceString);
/*
@@ -2541,8 +2548,8 @@ FamilyExists(
* non-zero value.
*/
- result = EnumFontFamilies(hdc, (WCHAR*) Tcl_DStringValue(&faceString),
- (FONTENUMPROC) WinFontExistProc, 0);
+ result = EnumFontFamiliesW(hdc, (WCHAR*) Tcl_DStringValue(&faceString),
+ (FONTENUMPROCW) WinFontExistProc, 0);
Tcl_DStringFree(&faceString);
return (result == 0);
}
@@ -2571,7 +2578,7 @@ FamilyOrAliasExists(
static int CALLBACK
WinFontExistProc(
- ENUMLOGFONT *lfPtr, /* Logical-font data. */
+ ENUMLOGFONTW *lfPtr, /* Logical-font data. */
NEWTEXTMETRIC *tmPtr, /* Physical-font data (not used). */
int fontType, /* Type of font (not used). */
LPARAM lParam) /* EnumFontData to hold result. */
diff --git a/win/tkWinImage.c b/win/tkWinImage.c
index 0a8ef73..e1660a9 100644
--- a/win/tkWinImage.c
+++ b/win/tkWinImage.c
@@ -126,6 +126,7 @@ PutPixel(
*/
destPtr[3] = 0;
+ /* FALLTHRU */
case 24:
/*
* Pixel is triplet: 0xBBGGRR.
diff --git a/win/tkWinInit.c b/win/tkWinInit.c
index 45250d7..8f4ac5d 100644
--- a/win/tkWinInit.c
+++ b/win/tkWinInit.c
@@ -183,13 +183,13 @@ TkWin32ErrorObj(
Tcl_Obj* errPtr = NULL;
Tcl_DString ds;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
+ FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS, NULL, (DWORD)hrError,
LANG_NEUTRAL, (LPWSTR)&lpBuffer, 0, NULL);
if (lpBuffer == NULL) {
lpBuffer = sBuffer;
- wsprintf(sBuffer, L"Error Code: %08lX", hrError);
+ wsprintfW(sBuffer, L"Error Code: %08lX", hrError);
}
if ((p = wcsrchr(lpBuffer, '\r')) != NULL) {
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index 013d04c..01a7d37 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.c
@@ -717,7 +717,7 @@ ReconfigureWindowsMenu(
}
}
if (!systemMenu) {
- InsertMenu(winMenuHdl, 0xFFFFFFFF, flags, itemID, lpNewItem);
+ InsertMenuW(winMenuHdl, 0xFFFFFFFF, flags, itemID, lpNewItem);
}
Tcl_DStringFree(&translatedText);
if (itemText != NULL) {
@@ -1101,7 +1101,7 @@ TkWinEmbeddedMenuProc(
if (lResult || (GetCapture() != hwnd)) {
break;
}
-
+ /* FALLTHRU */
default:
lResult = DefWindowProc(hwnd, message, wParam, lParam);
break;
@@ -3230,8 +3230,8 @@ static void
MenuExitHandler(
ClientData clientData) /* Not used */
{
- UnregisterClass(MENU_CLASS_NAME, Tk_GetHINSTANCE());
- UnregisterClass(EMBEDDED_MENU_CLASS_NAME, Tk_GetHINSTANCE());
+ UnregisterClassW(MENU_CLASS_NAME, Tk_GetHINSTANCE());
+ UnregisterClassW(EMBEDDED_MENU_CLASS_NAME, Tk_GetHINSTANCE());
}
/*
@@ -3335,7 +3335,7 @@ SetDefaults(
int pointSize;
HFONT menuFont;
/* See: [Bug #3239768] tk8.4.19 (and later) WIN32 menu font support */
- NONCLIENTMETRICS metrics;
+ NONCLIENTMETRICSW metrics;
OSVERSIONINFOW os;
/*
@@ -3364,7 +3364,7 @@ SetDefaults(
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize,
&metrics, 0);
- menuFont = CreateFontIndirect(&metrics.lfMenuFont);
+ menuFont = CreateFontIndirectW(&metrics.lfMenuFont);
SelectObject(scratchDC, menuFont);
GetTextMetrics(scratchDC, &tm);
GetTextFaceA(scratchDC, LF_FACESIZE, faceName);
@@ -3445,7 +3445,7 @@ SetDefaults(
void
TkpMenuInit(void)
{
- WNDCLASS wndClass;
+ WNDCLASSW wndClass;
wndClass.style = CS_OWNDC;
wndClass.lpfnWndProc = TkWinMenuProc;
@@ -3457,13 +3457,13 @@ TkpMenuInit(void)
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = MENU_CLASS_NAME;
- if (!RegisterClass(&wndClass)) {
+ if (!RegisterClassW(&wndClass)) {
Tcl_Panic("Failed to register menu window class");
}
wndClass.lpfnWndProc = TkWinEmbeddedMenuProc;
wndClass.lpszClassName = EMBEDDED_MENU_CLASS_NAME;
- if (!RegisterClass(&wndClass)) {
+ if (!RegisterClassW(&wndClass)) {
Tcl_Panic("Failed to register embedded menu window class");
}
@@ -3494,7 +3494,7 @@ TkpMenuThreadInit(void)
ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- tsdPtr->menuHWND = CreateWindow(MENU_CLASS_NAME, L"MenuWindow", WS_POPUP,
+ tsdPtr->menuHWND = CreateWindowW(MENU_CLASS_NAME, L"MenuWindow", WS_POPUP,
0, 0, 10, 10, NULL, NULL, Tk_GetHINSTANCE(), NULL);
if (!tsdPtr->menuHWND) {
@@ -3502,7 +3502,7 @@ TkpMenuThreadInit(void)
}
tsdPtr->embeddedMenuHWND =
- CreateWindow(EMBEDDED_MENU_CLASS_NAME, L"EmbeddedMenuWindow",
+ CreateWindowW(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 c5abf1d..c1ee9a6 100644
--- a/win/tkWinPixmap.c
+++ b/win/tkWinPixmap.c
@@ -100,12 +100,12 @@ Tk_GetPixmap(
LPVOID lpMsgBuf;
repeatError = 1;
- if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&lpMsgBuf, 0, NULL)) {
- MessageBox(NULL, (LPWSTR) lpMsgBuf,
+ MessageBoxW(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 f511a2c..363e4bb 100644
--- a/win/tkWinScrlbr.c
+++ b/win/tkWinScrlbr.c
@@ -223,7 +223,7 @@ CreateProc(
| SBS_HORZ;
}
- scrollPtr->hwnd = CreateWindow(L"SCROLLBAR", NULL, style,
+ scrollPtr->hwnd = CreateWindowW(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 7bd84fd..c82bf86 100644
--- a/win/tkWinTest.c
+++ b/win/tkWinTest.c
@@ -147,7 +147,7 @@ AppendSystemError(
if (Tcl_IsShared(resultPtr)) {
resultPtr = Tcl_DuplicateObj(resultPtr);
}
- length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
+ length = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS
| FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *) wMsgPtrPtr,
@@ -466,15 +466,12 @@ TestfindwindowObjCmd(
}
if (title[0] == 0)
title = NULL;
-#if 0
- hwnd = FindWindow(class, title);
-#else
/* We want find a window the belongs to us and not some other process */
hwnd = NULL;
myPid = GetCurrentProcessId();
while (1) {
DWORD pid, tid;
- hwnd = FindWindowEx(NULL, hwnd, class, title);
+ hwnd = FindWindowExW(NULL, hwnd, class, title);
if (hwnd == NULL)
break;
tid = GetWindowThreadProcessId(hwnd, &pid);
@@ -487,8 +484,6 @@ TestfindwindowObjCmd(
break; /* Found it */
}
-#endif
-
if (hwnd == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to find window: ", -1));
AppendSystemError(interp, GetLastError());
@@ -536,7 +531,7 @@ TestgetwindowinfoObjCmd(
if (Tcl_GetWideIntFromObj(interp, objv[1], &hwnd) != TCL_OK)
return TCL_ERROR;
- cch = GetClassName((HWND)(size_t)hwnd, buf, cchBuf);
+ cch = GetClassNameW(INT2PTR(hwnd), buf, cchBuf);
if (cch == 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to get class name: ", -1));
AppendSystemError(interp, GetLastError());
@@ -553,7 +548,7 @@ TestgetwindowinfoObjCmd(
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("id", 2),
Tcl_NewWideIntObj(GetWindowLongPtr((HWND)(size_t)hwnd, GWL_ID)));
- cch = GetWindowText(INT2PTR(hwnd), (LPWSTR)buf, cchBuf);
+ cch = GetWindowTextW(INT2PTR(hwnd), (LPWSTR)buf, cchBuf);
Tcl_DStringInit(&ds);
Tcl_WCharToUtfDString(buf, cch, &ds);
textObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c
index 0b883b1..e9b86c3 100644
--- a/win/tkWinWindow.c
+++ b/win/tkWinWindow.c
@@ -277,7 +277,7 @@ TkpMakeWindow(
* order.
*/
- hwnd = CreateWindowEx(WS_EX_NOPARENTNOTIFY, TK_WIN_CHILD_CLASS_NAME, NULL,
+ hwnd = CreateWindowExW(WS_EX_NOPARENTNOTIFY, TK_WIN_CHILD_CLASS_NAME, NULL,
(DWORD) style, Tk_X(winPtr), Tk_Y(winPtr), Tk_Width(winPtr),
Tk_Height(winPtr), parentWin, NULL, Tk_GetHINSTANCE(), NULL);
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
@@ -926,7 +926,7 @@ TkpMakeTransparentWindowExist(
int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
DWORD exStyle = WS_EX_TRANSPARENT | WS_EX_TOPMOST;
- hWnd = CreateWindowEx(exStyle, TK_WIN_CHILD_CLASS_NAME, NULL, style,
+ hWnd = CreateWindowExW(exStyle, TK_WIN_CHILD_CLASS_NAME, NULL, style,
Tk_X(tkwin), Tk_Y(tkwin), Tk_Width(tkwin), Tk_Height(tkwin),
hParent, NULL, Tk_GetHINSTANCE(), NULL);
winPtr->window = Tk_AttachHWND(tkwin, hWnd);
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 11497b9..1df5512 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -867,23 +867,18 @@ InitWindowClass(
if (!initialized) {
Tcl_MutexLock(&winWmMutex);
if (!initialized) {
- WNDCLASS class;
+ WNDCLASSW class;
initialized = 1;
- /*
- * The only difference between WNDCLASSW and WNDCLASSA are in
- * pointers, so we can use the generic structure WNDCLASS.
- */
-
- ZeroMemory(&class, sizeof(WNDCLASS));
+ ZeroMemory(&class, sizeof(WNDCLASSW));
class.style = CS_HREDRAW | CS_VREDRAW;
class.hInstance = Tk_GetHINSTANCE();
class.lpszClassName = TK_WIN_TOPLEVEL_CLASS_NAME;
class.lpfnWndProc = WmProc;
if (titlebaricon == NULL) {
- class.hIcon = LoadIcon(Tk_GetHINSTANCE(), L"tk");
+ class.hIcon = LoadIconW(Tk_GetHINSTANCE(), L"tk");
} else {
class.hIcon = GetIcon(titlebaricon, ICON_BIG);
if (class.hIcon == NULL) {
@@ -897,9 +892,9 @@ InitWindowClass(
tsdPtr->iconPtr = titlebaricon;
}
- class.hCursor = LoadCursor(NULL, IDC_ARROW);
+ class.hCursor = LoadCursorW(NULL, IDC_ARROW);
- if (!RegisterClass(&class)) {
+ if (!RegisterClassW(&class)) {
Tcl_Panic("Unable to register TkTopLevel class");
}
}
@@ -1237,7 +1232,7 @@ ReadIconFromFile(
*/
if (lpIR == NULL) {
- SHFILEINFO sfiSM;
+ SHFILEINFOW sfiSM;
Tcl_DString ds, ds2;
DWORD *res;
const char *file;
@@ -1249,15 +1244,15 @@ ReadIconFromFile(
Tcl_DStringInit(&ds2);
Tcl_UtfToWCharDString(file, -1, &ds2);
Tcl_DStringFree(&ds);
- res = (DWORD *)SHGetFileInfo((WCHAR *)Tcl_DStringValue(&ds2), 0, &sfiSM,
+ res = (DWORD *)SHGetFileInfoW((WCHAR *)Tcl_DStringValue(&ds2), 0, &sfiSM,
sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_ICON);
if (res != 0) {
- SHFILEINFO sfi;
+ SHFILEINFOW sfi;
unsigned size;
Tcl_ResetResult(interp);
- res = (DWORD *)SHGetFileInfo((WCHAR *)Tcl_DStringValue(&ds2), 0, &sfi,
+ res = (DWORD *)SHGetFileInfoW((WCHAR *)Tcl_DStringValue(&ds2), 0, &sfi,
sizeof(SHFILEINFO), SHGFI_ICON);
/*
@@ -1887,7 +1882,7 @@ TkWinWmCleanup(
}
tsdPtr->initialized = 0;
- UnregisterClass(TK_WIN_TOPLEVEL_CLASS_NAME, hInstance);
+ UnregisterClassW(TK_WIN_TOPLEVEL_CLASS_NAME, hInstance);
}
/*
@@ -2131,7 +2126,7 @@ UpdateWrapper(
Tcl_UtfToWCharDString(((wmPtr->title != NULL) ?
wmPtr->title : winPtr->nameUid), -1, &titleString);
- wmPtr->wrapper = CreateWindowEx(wmPtr->exStyle,
+ wmPtr->wrapper = CreateWindowExW(wmPtr->exStyle,
TK_WIN_TOPLEVEL_CLASS_NAME,
(LPCWSTR) Tcl_DStringValue(&titleString),
wmPtr->style, x, y, width, height,
@@ -5465,7 +5460,7 @@ WmTitleCmd(
Tcl_DString titleString;
int size = 256;
- GetWindowText(wrapper, buf, size);
+ GetWindowTextW(wrapper, buf, size);
Tcl_DStringInit(&titleString);
Tcl_WCharToUtfDString(buf, wcslen(buf), &titleString);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
@@ -5489,7 +5484,7 @@ WmTitleCmd(
Tcl_DStringInit(&titleString);
Tcl_UtfToWCharDString(wmPtr->title, -1, &titleString);
- SetWindowText(wrapper, (LPCWSTR) Tcl_DStringValue(&titleString));
+ SetWindowTextW(wrapper, (LPCWSTR) Tcl_DStringValue(&titleString));
Tcl_DStringFree(&titleString);
}
}
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 76aca39..94a1432 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -59,7 +59,7 @@
static const char winScreenName[] = ":0"; /* Default name of windows display. */
static HINSTANCE tkInstance = NULL; /* Application instance handle. */
static int childClassInitialized; /* Registered child class? */
-static WNDCLASS childClass; /* Window class for child windows. */
+static WNDCLASSW childClass; /* Window class for child windows. */
static int tkWinTheme = 0; /* See TkWinGetPlatformTheme */
static Tcl_Encoding keyInputEncoding = NULL;
/* The current character encoding for
@@ -127,7 +127,7 @@ TkGetServerInfo(
OSVERSIONINFOW os;
if (!buffer[0]) {
- HANDLE handle = GetModuleHandle(L"NTDLL");
+ HANDLE handle = GetModuleHandleW(L"NTDLL");
int(__stdcall *getversion)(void *) =
(int(__stdcall *)(void *))GetProcAddress(handle, "RtlGetVersion");
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
@@ -168,7 +168,7 @@ HINSTANCE
Tk_GetHINSTANCE(void)
{
if (tkInstance == NULL) {
- tkInstance = GetModuleHandle(NULL);
+ tkInstance = GetModuleHandleW(NULL);
}
return tkInstance;
}
@@ -248,7 +248,7 @@ TkWinXInit(
childClass.hIcon = NULL;
childClass.hCursor = NULL;
- if (!RegisterClass(&childClass)) {
+ if (!RegisterClassW(&childClass)) {
Tcl_Panic("Unable to register TkChild class");
}
@@ -256,7 +256,7 @@ TkWinXInit(
* Initialize input language info
*/
- if (GetLocaleInfo(LANGIDFROMLCID(PTR2INT(GetKeyboardLayout(0))),
+ if (GetLocaleInfoW(LANGIDFROMLCID(PTR2INT(GetKeyboardLayout(0))),
LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
(LPWSTR) &lpCP, sizeof(lpCP)/sizeof(WCHAR))
&& TranslateCharsetInfo(INT2PTR(lpCP), &lpCs, TCI_SRCCODEPAGE)) {
@@ -298,7 +298,7 @@ TkWinXCleanup(
if (childClassInitialized) {
childClassInitialized = 0;
- UnregisterClass(TK_WIN_CHILD_CLASS_NAME, hInstance);
+ UnregisterClassW(TK_WIN_CHILD_CLASS_NAME, hInstance);
}
if (unicodeEncoding != NULL) {
@@ -352,11 +352,11 @@ TkWinGetPlatformTheme(void)
char pBuffer[200];
memset(pBuffer, 0, dwSize);
- if (RegOpenKeyEx(HKEY_CURRENT_USER, szSubKey, 0L,
+ if (RegOpenKeyExW(HKEY_CURRENT_USER, szSubKey, 0L,
KEY_READ, &hKey) != ERROR_SUCCESS) {
tkWinTheme = TK_THEME_WIN_XP;
} else {
- RegQueryValueEx(hKey, szCurrent, NULL, NULL, (LPBYTE) pBuffer, &dwSize);
+ RegQueryValueExW(hKey, szCurrent, NULL, NULL, (LPBYTE) pBuffer, &dwSize);
RegCloseKey(hKey);
if (strcmp(pBuffer, "Windows Standard") == 0) {
tkWinTheme = TK_THEME_WIN_CLASSIC;
diff --git a/win/ttkWinMonitor.c b/win/ttkWinMonitor.c
index e3608f3..bbacd99 100644
--- a/win/ttkWinMonitor.c
+++ b/win/ttkWinMonitor.c
@@ -70,26 +70,26 @@ static void RegisterSystemColors(Tcl_Interp *interp)
static HWND
CreateThemeMonitorWindow(HINSTANCE hinst, Tcl_Interp *interp)
{
- WNDCLASSEX wc;
+ WNDCLASSEXW wc;
HWND hwnd = NULL;
WCHAR title[32] = L"TtkMonitorWindow";
WCHAR name[32] = L"TtkMonitorClass";
- wc.cbSize = sizeof(WNDCLASSEX);
+ wc.cbSize = sizeof(WNDCLASSEXW);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hinst;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hIcon = LoadIconW(NULL, IDI_APPLICATION);
+ wc.hIconSm = LoadIconW(NULL, IDI_APPLICATION);
+ wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszMenuName = name;
wc.lpszClassName = name;
- if (RegisterClassEx(&wc)) {
- hwnd = CreateWindow( name, title, WS_OVERLAPPEDWINDOW,
+ if (RegisterClassExW(&wc)) {
+ hwnd = CreateWindowW( name, title, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hinst, NULL );
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) interp);
diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c
index 647b180..d500c7e 100644
--- a/win/ttkWinXPTheme.c
+++ b/win/ttkWinXPTheme.c
@@ -95,7 +95,7 @@ LoadXPThemeProcs(HINSTANCE *phlib)
* if we are running at least on Windows XP.
*/
HINSTANCE handle;
- *phlib = handle = LoadLibrary(L"uxtheme.dll");
+ *phlib = handle = LoadLibraryW(L"uxtheme.dll");
if (handle != 0)
{
/*