Import Tk 8.6.10
This commit is contained in:
@@ -40,15 +40,11 @@
|
||||
#define BIF_NEWDIALOGSTYLE 0x0040
|
||||
#endif
|
||||
|
||||
#ifndef BFFM_VALIDATEFAILED
|
||||
#ifdef UNICODE
|
||||
#define BFFM_VALIDATEFAILED 4
|
||||
#else
|
||||
#define BFFM_VALIDATEFAILED 3
|
||||
#endif
|
||||
#endif /* BFFM_VALIDATEFAILED */
|
||||
#ifndef BFFM_VALIDATEFAILEDW
|
||||
#define BFFM_VALIDATEFAILEDW 4
|
||||
#endif /* BFFM_VALIDATEFAILEDW */
|
||||
|
||||
typedef struct ThreadSpecificData {
|
||||
typedef struct {
|
||||
int debugFlag; /* Flags whether we should output debugging
|
||||
* information while displaying a builtin
|
||||
* dialog. */
|
||||
@@ -120,11 +116,11 @@ static const struct {int type; int btnIds[3];} allowedTypes[] = {
|
||||
*/
|
||||
|
||||
#define TkWinGetHInstance(from) \
|
||||
((HINSTANCE) GetWindowLongPtr((from), GWLP_HINSTANCE))
|
||||
((HINSTANCE) GetWindowLongPtrW((from), GWLP_HINSTANCE))
|
||||
#define TkWinGetUserData(from) \
|
||||
GetWindowLongPtr((from), GWLP_USERDATA)
|
||||
GetWindowLongPtrW((from), GWLP_USERDATA)
|
||||
#define TkWinSetUserData(to,what) \
|
||||
SetWindowLongPtr((to), GWLP_USERDATA, (LPARAM)(what))
|
||||
SetWindowLongPtrW((to), GWLP_USERDATA, (LPARAM)(what))
|
||||
|
||||
/*
|
||||
* The value of TK_MULTI_MAX_PATH dictates how many files can be retrieved
|
||||
@@ -143,8 +139,8 @@ static const struct {int type; int btnIds[3];} allowedTypes[] = {
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
TCHAR initDir[MAX_PATH]; /* Initial folder to use */
|
||||
TCHAR retDir[MAX_PATH]; /* Returned folder to use */
|
||||
WCHAR initDir[MAX_PATH]; /* Initial folder to use */
|
||||
WCHAR retDir[MAX_PATH]; /* Returned folder to use */
|
||||
Tcl_Interp *interp;
|
||||
int mustExist; /* True if file must exist to return from
|
||||
* callback */
|
||||
@@ -161,7 +157,7 @@ typedef struct OFNData {
|
||||
int dynFileBufferSize; /* Dynamic filename buffer size, stored to
|
||||
* avoid shrinking and expanding the buffer
|
||||
* when selection changes */
|
||||
TCHAR *dynFileBuffer; /* Dynamic filename buffer */
|
||||
WCHAR *dynFileBuffer; /* Dynamic filename buffer */
|
||||
} OFNData;
|
||||
|
||||
/*
|
||||
@@ -180,12 +176,9 @@ typedef struct OFNOpts {
|
||||
int confirmOverwrite; /* Confirm before overwriting */
|
||||
int mustExist; /* Used only for */
|
||||
int forceXPStyle; /* XXX - Force XP style even on newer systems */
|
||||
TCHAR file[TK_MULTI_MAX_PATH]; /* File name
|
||||
WCHAR file[TK_MULTI_MAX_PATH]; /* File name
|
||||
XXX - fixed size because it was so
|
||||
historically. Why not malloc'ed ?
|
||||
XXX - also, TCHAR should really be WCHAR
|
||||
because TkWinGetUnicodeEncoding is always
|
||||
UCS2.
|
||||
*/
|
||||
} OFNOpts;
|
||||
|
||||
@@ -596,7 +589,7 @@ static UINT APIENTRY OFNHookProc(HWND hdlg, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
static LRESULT CALLBACK MsgBoxCBTProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
static void SetTkDialog(ClientData clientData);
|
||||
static const char *ConvertExternalFilename(TCHAR *filename,
|
||||
static const char *ConvertExternalFilename(WCHAR *filename,
|
||||
Tcl_DString *dsPtr);
|
||||
static void LoadShellProcs(void);
|
||||
|
||||
@@ -644,7 +637,7 @@ static void LoadShellProcs()
|
||||
if (shell32_handle != NULL)
|
||||
return; /* We have already been through here. */
|
||||
|
||||
shell32_handle = GetModuleHandle(TEXT("shell32.dll"));
|
||||
shell32_handle = GetModuleHandleW(L"shell32.dll");
|
||||
if (shell32_handle == NULL) /* Should never happen but check anyways. */
|
||||
return;
|
||||
|
||||
@@ -699,7 +692,7 @@ EatSpuriousMessageBugFix(void)
|
||||
DWORD nTime = GetTickCount() + 250;
|
||||
|
||||
while (GetTickCount() < nTime) {
|
||||
PeekMessage(&msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE);
|
||||
PeekMessageW(&msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,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 */
|
||||
@@ -797,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;
|
||||
@@ -849,7 +842,7 @@ Tk_ChooseColorObjCmd(
|
||||
chooseColor.hwndOwner = hWnd;
|
||||
|
||||
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
|
||||
winCode = ChooseColor(&chooseColor);
|
||||
winCode = ChooseColorW(&chooseColor);
|
||||
(void) Tcl_SetServiceMode(oldMode);
|
||||
|
||||
/*
|
||||
@@ -929,7 +922,7 @@ ColorDlgHookProc(
|
||||
if ((title != NULL) && (title[0] != '\0')) {
|
||||
Tcl_DString ds;
|
||||
|
||||
SetWindowText(hDlg, Tcl_WinUtfToTChar(title,-1,&ds));
|
||||
SetWindowTextW(hDlg, (LPCWSTR)Tcl_WinUtfToTChar(title,-1,&ds));
|
||||
Tcl_DStringFree(&ds);
|
||||
}
|
||||
if (tsdPtr->debugFlag) {
|
||||
@@ -1412,7 +1405,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
|
||||
normPath = Tcl_FSGetNormalizedPath(interp, iniDirPath);
|
||||
/* XXX - Note on failures do not raise error, simply ignore ini dir */
|
||||
if (normPath) {
|
||||
const WCHAR *nativePath;
|
||||
LPCWSTR nativePath;
|
||||
Tcl_IncrRefCount(normPath);
|
||||
nativePath = Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/
|
||||
if (nativePath) {
|
||||
@@ -1445,7 +1438,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
|
||||
|
||||
/*
|
||||
* Clear interp result since it might have been set during the modal loop.
|
||||
* http://core.tcl.tk/tk/tktview/4a0451f5291b3c9168cc560747dae9264e1d2ef6
|
||||
* https://core.tcl-lang.org/tk/tktview/4a0451f5291b3c9168cc560747dae9264e1d2ef6
|
||||
*/
|
||||
Tcl_ResetResult(interp);
|
||||
|
||||
@@ -1518,7 +1511,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
|
||||
Tcl_DString ftds;
|
||||
Tcl_Obj *ftobj;
|
||||
|
||||
Tcl_WinTCharToUtf(filterPtr[ftix-1].pszName, -1, &ftds);
|
||||
Tcl_WinTCharToUtf((LPCTSTR)filterPtr[ftix-1].pszName, -1, &ftds);
|
||||
ftobj = Tcl_NewStringObj(Tcl_DStringValue(&ftds),
|
||||
Tcl_DStringLength(&ftds));
|
||||
Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL,
|
||||
@@ -1572,7 +1565,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;
|
||||
@@ -1625,7 +1618,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
|
||||
*/
|
||||
|
||||
ofnData.dynFileBufferSize = 512;
|
||||
ofnData.dynFileBuffer = ckalloc(512 * sizeof(TCHAR));
|
||||
ofnData.dynFileBuffer = ckalloc(512 * sizeof(WCHAR));
|
||||
}
|
||||
|
||||
if (optsPtr->extObj != NULL) {
|
||||
@@ -1633,12 +1626,12 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
|
||||
if (str[0] == '.')
|
||||
++str;
|
||||
Tcl_WinUtfToTChar(str, -1, &extString);
|
||||
ofn.lpstrDefExt = (TCHAR *) Tcl_DStringValue(&extString);
|
||||
ofn.lpstrDefExt = (WCHAR *) Tcl_DStringValue(&extString);
|
||||
}
|
||||
|
||||
Tcl_WinUtfToTChar(Tcl_DStringValue(&utfFilterString),
|
||||
Tcl_DStringLength(&utfFilterString), &filterString);
|
||||
ofn.lpstrFilter = (TCHAR *) Tcl_DStringValue(&filterString);
|
||||
ofn.lpstrFilter = (WCHAR *) Tcl_DStringValue(&filterString);
|
||||
ofn.nFilterIndex = filterIndex;
|
||||
|
||||
if (Tcl_DStringValue(&optsPtr->utfDirString)[0] != '\0') {
|
||||
@@ -1663,11 +1656,11 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
|
||||
}
|
||||
Tcl_DStringFree(&cwd);
|
||||
}
|
||||
ofn.lpstrInitialDir = (TCHAR *) Tcl_DStringValue(&dirString);
|
||||
ofn.lpstrInitialDir = (WCHAR *) Tcl_DStringValue(&dirString);
|
||||
|
||||
if (optsPtr->titleObj != NULL) {
|
||||
Tcl_WinUtfToTChar(Tcl_GetString(optsPtr->titleObj), -1, &titleString);
|
||||
ofn.lpstrTitle = (TCHAR *) Tcl_DStringValue(&titleString);
|
||||
ofn.lpstrTitle = (WCHAR *) Tcl_DStringValue(&titleString);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1676,9 +1669,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();
|
||||
@@ -1714,7 +1707,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
|
||||
/*
|
||||
* We now allow FNERR_BUFFERTOOSMALL when multiselection is enabled. The
|
||||
* filename buffer has been dynamically allocated by the OFN dialog
|
||||
* procedure to accomodate all selected files.
|
||||
* procedure to accommodate all selected files.
|
||||
*/
|
||||
|
||||
if ((winCode != 0)
|
||||
@@ -1732,7 +1725,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
|
||||
* first element is the directory path.
|
||||
*/
|
||||
|
||||
TCHAR *files = ofnData.dynFileBuffer;
|
||||
WCHAR *files = ofnData.dynFileBuffer;
|
||||
Tcl_Obj *returnList = Tcl_NewObj();
|
||||
int count = 0;
|
||||
|
||||
@@ -1944,7 +1937,7 @@ OFNHookProc(
|
||||
if (notifyPtr->hdr.code == CDN_FILEOK ||
|
||||
notifyPtr->hdr.code == CDN_SELCHANGE) {
|
||||
int dirsize, selsize;
|
||||
TCHAR *buffer;
|
||||
WCHAR *buffer;
|
||||
int buffersize;
|
||||
|
||||
/*
|
||||
@@ -1957,8 +1950,8 @@ OFNHookProc(
|
||||
buffer = ofnData->dynFileBuffer;
|
||||
hdlg = GetParent(hdlg);
|
||||
|
||||
selsize = (int) SendMessage(hdlg, CDM_GETSPEC, 0, 0);
|
||||
dirsize = (int) SendMessage(hdlg, CDM_GETFOLDERPATH, 0, 0);
|
||||
selsize = (int) SendMessageW(hdlg, CDM_GETSPEC, 0, 0);
|
||||
dirsize = (int) SendMessageW(hdlg, CDM_GETFOLDERPATH, 0, 0);
|
||||
buffersize = (selsize + dirsize + 1);
|
||||
|
||||
/*
|
||||
@@ -1968,15 +1961,15 @@ OFNHookProc(
|
||||
|
||||
if ((selsize > 1) && (dirsize > 0)) {
|
||||
if (ofnData->dynFileBufferSize < buffersize) {
|
||||
buffer = ckrealloc(buffer, buffersize * sizeof(TCHAR));
|
||||
buffer = ckrealloc(buffer, buffersize * sizeof(WCHAR));
|
||||
ofnData->dynFileBufferSize = buffersize;
|
||||
ofnData->dynFileBuffer = buffer;
|
||||
}
|
||||
|
||||
SendMessage(hdlg, CDM_GETFOLDERPATH, dirsize, (LPARAM) buffer);
|
||||
SendMessageW(hdlg, CDM_GETFOLDERPATH, dirsize, (LPARAM) buffer);
|
||||
buffer += dirsize;
|
||||
|
||||
SendMessage(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer);
|
||||
SendMessageW(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer);
|
||||
|
||||
/*
|
||||
* If there are multiple files, delete the quotes and change
|
||||
@@ -1985,7 +1978,7 @@ OFNHookProc(
|
||||
|
||||
if (buffer[0] == '"') {
|
||||
BOOL findquote = TRUE;
|
||||
TCHAR *tmp = buffer;
|
||||
WCHAR *tmp = buffer;
|
||||
|
||||
while (*buffer != '\0') {
|
||||
if (findquote) {
|
||||
@@ -2014,8 +2007,8 @@ OFNHookProc(
|
||||
if (TCL_PATH_ABSOLUTE ==
|
||||
Tcl_GetPathType(Tcl_DStringValue(&tmpfile))) {
|
||||
/* re-get the full path to the start of the buffer */
|
||||
buffer = (TCHAR *) ofnData->dynFileBuffer;
|
||||
SendMessage(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer);
|
||||
buffer = (WCHAR *) ofnData->dynFileBuffer;
|
||||
SendMessageW(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer);
|
||||
} else {
|
||||
*(buffer-1) = '\\';
|
||||
}
|
||||
@@ -2295,54 +2288,56 @@ static int MakeFilterVista(
|
||||
for (i = 0, filterPtr = flist.filters;
|
||||
filterPtr;
|
||||
filterPtr = filterPtr->next, ++i) {
|
||||
const char *sep;
|
||||
FileFilterClause *clausePtr;
|
||||
int nbytes;
|
||||
const char *sep;
|
||||
FileFilterClause *clausePtr;
|
||||
int nbytes;
|
||||
|
||||
/* Check if this entry should be shown as the default */
|
||||
if (initial && strcmp(initial, filterPtr->name) == 0)
|
||||
/* Check if this entry should be shown as the default */
|
||||
if (initial && strcmp(initial, filterPtr->name) == 0)
|
||||
initialIndex = i+1; /* Windows filter indices are 1-based */
|
||||
|
||||
/* First stash away the text description of the pattern */
|
||||
/* First stash away the text description of the pattern */
|
||||
Tcl_WinUtfToTChar(filterPtr->name, -1, &ds);
|
||||
nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
|
||||
nbytes += sizeof(WCHAR); /* Terminating \0 */
|
||||
dlgFilterPtr[i].pszName = ckalloc(nbytes);
|
||||
memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes);
|
||||
Tcl_DStringFree(&ds);
|
||||
nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
|
||||
nbytes += sizeof(WCHAR); /* Terminating \0 */
|
||||
dlgFilterPtr[i].pszName = ckalloc(nbytes);
|
||||
memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes);
|
||||
Tcl_DStringFree(&ds);
|
||||
|
||||
/*
|
||||
* Loop through and join patterns with a ";" Each "clause"
|
||||
* corresponds to a single textual description (called typename)
|
||||
* in the tk_getOpenFile docs. Each such typename may occur
|
||||
* multiple times and all these form a single filter entry
|
||||
* with one clause per occurence. Further each clause may specify
|
||||
* multiple patterns. Hence the nested loop here.
|
||||
*/
|
||||
sep = "";
|
||||
for (clausePtr=filterPtr->clauses ; clausePtr;
|
||||
clausePtr=clausePtr->next) {
|
||||
GlobPattern *globPtr;
|
||||
for (globPtr = clausePtr->patterns; globPtr;
|
||||
globPtr = globPtr->next) {
|
||||
Tcl_DStringAppend(&patterns, sep, -1);
|
||||
Tcl_DStringAppend(&patterns, globPtr->pattern, -1);
|
||||
sep = ";";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Loop through and join patterns with a ";" Each "clause"
|
||||
* corresponds to a single textual description (called typename)
|
||||
* in the tk_getOpenFile docs. Each such typename may occur
|
||||
* multiple times and all these form a single filter entry
|
||||
* with one clause per occurence. Further each clause may specify
|
||||
* multiple patterns. Hence the nested loop here.
|
||||
*/
|
||||
sep = "";
|
||||
for (clausePtr=filterPtr->clauses ; clausePtr;
|
||||
clausePtr=clausePtr->next) {
|
||||
GlobPattern *globPtr;
|
||||
for (globPtr = clausePtr->patterns; globPtr;
|
||||
globPtr = globPtr->next) {
|
||||
Tcl_DStringAppend(&patterns, sep, -1);
|
||||
Tcl_DStringAppend(&patterns, globPtr->pattern, -1);
|
||||
sep = ";";
|
||||
}
|
||||
}
|
||||
|
||||
/* Again we need a Unicode form of the string */
|
||||
/* Again we need a Unicode form of the string */
|
||||
Tcl_WinUtfToTChar(Tcl_DStringValue(&patterns), -1, &ds);
|
||||
nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
|
||||
nbytes += sizeof(WCHAR); /* Terminating \0 */
|
||||
dlgFilterPtr[i].pszSpec = ckalloc(nbytes);
|
||||
memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes);
|
||||
Tcl_DStringFree(&ds);
|
||||
Tcl_DStringFree(&patterns);
|
||||
nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
|
||||
nbytes += sizeof(WCHAR); /* Terminating \0 */
|
||||
dlgFilterPtr[i].pszSpec = ckalloc(nbytes);
|
||||
memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes);
|
||||
Tcl_DStringFree(&ds);
|
||||
Tcl_DStringSetLength(&patterns, 0);
|
||||
}
|
||||
Tcl_DStringFree(&patterns);
|
||||
|
||||
if (initialIndex == 0)
|
||||
initialIndex = 1; /* If no default, show first entry */
|
||||
if (initialIndex == 0) {
|
||||
initialIndex = 1; /* If no default, show first entry */
|
||||
}
|
||||
*initialIndexPtr = initialIndex;
|
||||
*dlgFilterPtrPtr = dlgFilterPtr;
|
||||
*countPtr = flist.numFilters;
|
||||
@@ -2429,14 +2424,14 @@ Tk_ChooseDirectoryObjCmd(
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const objv[]) /* Argument objects. */
|
||||
{
|
||||
TCHAR path[MAX_PATH];
|
||||
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;
|
||||
TCHAR saveDir[MAX_PATH];
|
||||
WCHAR saveDir[MAX_PATH];
|
||||
Tcl_DString titleString; /* Title */
|
||||
Tcl_DString tempString; /* temporary */
|
||||
Tcl_Obj *objPtr;
|
||||
@@ -2464,16 +2459,16 @@ Tk_ChooseDirectoryObjCmd(
|
||||
|
||||
utfDir = Tcl_DStringValue(&ofnOpts.utfDirString);
|
||||
if (utfDir[0] != '\0') {
|
||||
const TCHAR *uniStr;
|
||||
LPCWSTR uniStr;
|
||||
|
||||
Tcl_WinUtfToTChar(Tcl_DStringValue(&ofnOpts.utfDirString), -1,
|
||||
&tempString);
|
||||
uniStr = (TCHAR *) Tcl_DStringValue(&tempString);
|
||||
uniStr = (WCHAR *) Tcl_DStringValue(&tempString);
|
||||
|
||||
/* Convert possible relative path to full path to keep dialog happy. */
|
||||
|
||||
GetFullPathName(uniStr, MAX_PATH, saveDir, NULL);
|
||||
_tcsncpy(cdCBData.initDir, saveDir, MAX_PATH);
|
||||
GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL);
|
||||
wcsncpy(cdCBData.initDir, saveDir, MAX_PATH);
|
||||
}
|
||||
|
||||
/* XXX - rest of this (original) code has no error checks at all. */
|
||||
@@ -2492,16 +2487,16 @@ Tk_ChooseDirectoryObjCmd(
|
||||
bInfo.hwndOwner = hWnd;
|
||||
bInfo.pszDisplayName = path;
|
||||
bInfo.pidlRoot = NULL;
|
||||
if (_tcslen(cdCBData.initDir) == 0) {
|
||||
GetCurrentDirectory(MAX_PATH, cdCBData.initDir);
|
||||
if (wcslen(cdCBData.initDir) == 0) {
|
||||
GetCurrentDirectoryW(MAX_PATH, cdCBData.initDir);
|
||||
}
|
||||
bInfo.lParam = (LPARAM) &cdCBData;
|
||||
|
||||
if (ofnOpts.titleObj != NULL) {
|
||||
Tcl_WinUtfToTChar(Tcl_GetString(ofnOpts.titleObj), -1, &titleString);
|
||||
bInfo.lpszTitle = (LPTSTR) Tcl_DStringValue(&titleString);
|
||||
bInfo.lpszTitle = (LPCWSTR)Tcl_WinUtfToTChar(
|
||||
Tcl_GetString(ofnOpts.titleObj), -1, &titleString);
|
||||
} else {
|
||||
bInfo.lpszTitle = TEXT("Please choose a directory, then select OK.");
|
||||
bInfo.lpszTitle = L"Please choose a directory, then select OK.";
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2534,13 +2529,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
|
||||
@@ -2555,18 +2550,18 @@ 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);
|
||||
}
|
||||
pMalloc->lpVtbl->Free(pMalloc, (void *) pidl);
|
||||
} else if (_tcslen(cdCBData.retDir) > 0) {
|
||||
_tcscpy(path, cdCBData.retDir);
|
||||
} else if (wcslen(cdCBData.retDir) > 0) {
|
||||
wcscpy(path, cdCBData.retDir);
|
||||
}
|
||||
pMalloc->lpVtbl->Release(pMalloc);
|
||||
}
|
||||
SetCurrentDirectory(saveDir);
|
||||
SetCurrentDirectoryW(saveDir);
|
||||
Tcl_SetServiceMode(oldMode);
|
||||
|
||||
/*
|
||||
@@ -2618,11 +2613,11 @@ ChooseDirectoryValidateProc(
|
||||
LPARAM lParam,
|
||||
LPARAM lpData)
|
||||
{
|
||||
TCHAR selDir[MAX_PATH];
|
||||
WCHAR selDir[MAX_PATH];
|
||||
ChooseDir *chooseDirSharedData = (ChooseDir *) lpData;
|
||||
Tcl_DString tempString;
|
||||
Tcl_DString initDirString;
|
||||
TCHAR string[MAX_PATH];
|
||||
WCHAR string[MAX_PATH];
|
||||
ThreadSpecificData *tsdPtr =
|
||||
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
|
||||
|
||||
@@ -2632,7 +2627,7 @@ ChooseDirectoryValidateProc(
|
||||
}
|
||||
chooseDirSharedData->retDir[0] = '\0';
|
||||
switch (message) {
|
||||
case BFFM_VALIDATEFAILED:
|
||||
case BFFM_VALIDATEFAILEDW:
|
||||
/*
|
||||
* First save and check to see if it is a valid path name, if so then
|
||||
* make that path the one shown in the window. Otherwise, it failed
|
||||
@@ -2642,7 +2637,7 @@ ChooseDirectoryValidateProc(
|
||||
* like ~ are converted correctly.
|
||||
*/
|
||||
|
||||
Tcl_WinTCharToUtf((TCHAR *) lParam, -1, &initDirString);
|
||||
Tcl_WinTCharToUtf((LPCTSTR) lParam, -1, &initDirString);
|
||||
if (Tcl_TranslateFileName(chooseDirSharedData->interp,
|
||||
Tcl_DStringValue(&initDirString), &tempString) == NULL) {
|
||||
/*
|
||||
@@ -2656,11 +2651,11 @@ ChooseDirectoryValidateProc(
|
||||
Tcl_DStringFree(&initDirString);
|
||||
Tcl_WinUtfToTChar(Tcl_DStringValue(&tempString), -1, &initDirString);
|
||||
Tcl_DStringFree(&tempString);
|
||||
_tcsncpy(string, (TCHAR *) Tcl_DStringValue(&initDirString),
|
||||
wcsncpy(string, (WCHAR *) Tcl_DStringValue(&initDirString),
|
||||
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
|
||||
@@ -2668,17 +2663,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, TEXT("Directory '%s' does not exist,\n")
|
||||
TEXT("please select or enter an existing directory."),
|
||||
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;
|
||||
}
|
||||
@@ -2688,7 +2683,7 @@ ChooseDirectoryValidateProc(
|
||||
* directory in utfRetDir.
|
||||
*/
|
||||
|
||||
GetCurrentDirectory(MAX_PATH, chooseDirSharedData->retDir);
|
||||
GetCurrentDirectoryW(MAX_PATH, chooseDirSharedData->retDir);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
@@ -2703,30 +2698,30 @@ ChooseDirectoryValidateProc(
|
||||
* Not called when user changes edit box directly.
|
||||
*/
|
||||
|
||||
if (SHGetPathFromIDList((LPITEMIDLIST) lParam, selDir)) {
|
||||
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM) selDir);
|
||||
if (SHGetPathFromIDListW((LPITEMIDLIST) lParam, selDir)) {
|
||||
SendMessageW(hwnd, BFFM_SETSTATUSTEXTW, 0, (LPARAM) selDir);
|
||||
// enable the OK button
|
||||
SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
|
||||
SendMessageW(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
|
||||
} else {
|
||||
// disable the OK button
|
||||
SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 0);
|
||||
SendMessageW(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 0);
|
||||
}
|
||||
UpdateWindow(hwnd);
|
||||
return 1;
|
||||
|
||||
case BFFM_INITIALIZED: {
|
||||
/*
|
||||
* Directory browser intializing - tell it where to start from, user
|
||||
* Directory browser initializing - tell it where to start from, user
|
||||
* specified parameter.
|
||||
*/
|
||||
|
||||
TCHAR *initDir = chooseDirSharedData->initDir;
|
||||
WCHAR *initDir = chooseDirSharedData->initDir;
|
||||
|
||||
SetCurrentDirectory(initDir);
|
||||
SetCurrentDirectoryW(initDir);
|
||||
|
||||
if (*initDir == '\\') {
|
||||
/*
|
||||
* BFFM_SETSELECTION only understands UNC paths as pidls, so
|
||||
* BFFM_SETSELECTIONW only understands UNC paths as pidls, so
|
||||
* convert path to pidl using IShellFolder interface.
|
||||
*/
|
||||
|
||||
@@ -2739,10 +2734,10 @@ ChooseDirectoryValidateProc(
|
||||
ULONG ulCount, ulAttr;
|
||||
|
||||
if (SUCCEEDED(psfFolder->lpVtbl->ParseDisplayName(
|
||||
psfFolder, hwnd, NULL, (TCHAR *)
|
||||
psfFolder, hwnd, NULL, (WCHAR *)
|
||||
initDir, &ulCount,&pidlMain,&ulAttr))
|
||||
&& (pidlMain != NULL)) {
|
||||
SendMessage(hwnd, BFFM_SETSELECTION, FALSE,
|
||||
SendMessageW(hwnd, BFFM_SETSELECTIONW, FALSE,
|
||||
(LPARAM) pidlMain);
|
||||
pMalloc->lpVtbl->Free(pMalloc, pidlMain);
|
||||
}
|
||||
@@ -2751,9 +2746,9 @@ ChooseDirectoryValidateProc(
|
||||
pMalloc->lpVtbl->Release(pMalloc);
|
||||
}
|
||||
} else {
|
||||
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM) initDir);
|
||||
SendMessageW(hwnd, BFFM_SETSELECTIONW, TRUE, (LPARAM) initDir);
|
||||
}
|
||||
SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
|
||||
SendMessageW(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2803,7 +2798,7 @@ Tk_MessageBoxObjCmd(
|
||||
ThreadSpecificData *tsdPtr =
|
||||
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
|
||||
Tcl_DString titleBuf, tmpBuf;
|
||||
const WCHAR *titlePtr, *tmpPtr;
|
||||
LPCWSTR titlePtr, tmpPtr;
|
||||
const char *src;
|
||||
|
||||
defaultBtn = -1;
|
||||
@@ -2911,13 +2906,10 @@ Tk_MessageBoxObjCmd(
|
||||
|
||||
flags |= icon | type | MB_TASKMODAL | MB_SETFOREGROUND;
|
||||
|
||||
tmpObj = messageObj ? Tcl_DuplicateObj(messageObj)
|
||||
: Tcl_NewUnicodeObj(NULL, 0);
|
||||
tmpObj = messageObj ? Tcl_DuplicateObj(messageObj) : Tcl_NewObj();
|
||||
Tcl_IncrRefCount(tmpObj);
|
||||
if (detailObj) {
|
||||
const Tcl_UniChar twoNL[] = { '\n', '\n' };
|
||||
|
||||
Tcl_AppendUnicodeToObj(tmpObj, twoNL, 2);
|
||||
Tcl_AppendStringsToObj(tmpObj, "\n\n", NULL);
|
||||
Tcl_AppendObjToObj(tmpObj, detailObj);
|
||||
}
|
||||
|
||||
@@ -2934,18 +2926,18 @@ Tk_MessageBoxObjCmd(
|
||||
|
||||
tsdPtr->hSmallIcon = TkWinGetIcon(parent, ICON_SMALL);
|
||||
tsdPtr->hBigIcon = TkWinGetIcon(parent, ICON_BIG);
|
||||
tsdPtr->hMsgBoxHook = SetWindowsHookEx(WH_CBT, MsgBoxCBTProc, NULL,
|
||||
tsdPtr->hMsgBoxHook = SetWindowsHookExW(WH_CBT, MsgBoxCBTProc, NULL,
|
||||
GetCurrentThreadId());
|
||||
src = Tcl_GetString(tmpObj);
|
||||
tmpPtr = Tcl_WinUtfToTChar(src, tmpObj->length, &tmpBuf);
|
||||
tmpPtr = (LPCWSTR)Tcl_WinUtfToTChar(src, tmpObj->length, &tmpBuf);
|
||||
if (titleObj != NULL) {
|
||||
src = Tcl_GetString(titleObj);
|
||||
titlePtr = Tcl_WinUtfToTChar(src, titleObj->length, &titleBuf);
|
||||
titlePtr = (LPCWSTR)Tcl_WinUtfToTChar(src, titleObj->length, &titleBuf);
|
||||
} else {
|
||||
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);
|
||||
@@ -2988,9 +2980,9 @@ MsgBoxCBTProc(
|
||||
if (WC_DIALOG == lpcbtcreate->lpcs->lpszClass) {
|
||||
HWND hwnd = (HWND) wParam;
|
||||
|
||||
SendMessage(hwnd, WM_SETICON, ICON_SMALL,
|
||||
SendMessageW(hwnd, WM_SETICON, ICON_SMALL,
|
||||
(LPARAM) tsdPtr->hSmallIcon);
|
||||
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM) tsdPtr->hBigIcon);
|
||||
SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM) tsdPtr->hBigIcon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3022,7 +3014,7 @@ SetTkDialog(
|
||||
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
|
||||
char buf[32];
|
||||
|
||||
sprintf(buf, "0x%p", (HWND) clientData);
|
||||
sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)clientData);
|
||||
Tcl_SetVar2(tsdPtr->debugInterp, "tk_dialog", NULL, buf, TCL_GLOBAL_ONLY);
|
||||
}
|
||||
|
||||
@@ -3032,12 +3024,12 @@ SetTkDialog(
|
||||
|
||||
static const char *
|
||||
ConvertExternalFilename(
|
||||
TCHAR *filename,
|
||||
WCHAR *filename,
|
||||
Tcl_DString *dsPtr)
|
||||
{
|
||||
char *p;
|
||||
|
||||
Tcl_WinTCharToUtf(filename, -1, dsPtr);
|
||||
Tcl_WinTCharToUtf((LPCTSTR)filename, -1, dsPtr);
|
||||
for (p = Tcl_DStringValue(dsPtr); *p != '\0'; p++) {
|
||||
/*
|
||||
* Change the pathname to the Tcl "normalized" pathname, where back
|
||||
@@ -3067,14 +3059,14 @@ ConvertExternalFilename(
|
||||
static Tcl_Obj *
|
||||
GetFontObj(
|
||||
HDC hdc,
|
||||
LOGFONT *plf)
|
||||
LOGFONTW *plf)
|
||||
{
|
||||
Tcl_DString ds;
|
||||
Tcl_Obj *resObj;
|
||||
int pt = 0;
|
||||
|
||||
resObj = Tcl_NewListObj(0, NULL);
|
||||
Tcl_WinTCharToUtf(plf->lfFaceName, -1, &ds);
|
||||
Tcl_WinTCharToUtf((LPCTSTR)plf->lfFaceName, -1, &ds);
|
||||
Tcl_ListObjAppendElement(NULL, resObj,
|
||||
Tcl_NewStringObj(Tcl_DStringValue(&ds), -1));
|
||||
Tcl_DStringFree(&ds);
|
||||
@@ -3103,7 +3095,7 @@ ApplyLogfont(
|
||||
Tcl_Interp *interp,
|
||||
Tcl_Obj *cmdObj,
|
||||
HDC hdc,
|
||||
LOGFONT *logfontPtr)
|
||||
LOGFONTW *logfontPtr)
|
||||
{
|
||||
int objc;
|
||||
Tcl_Obj **objv, **tmpv;
|
||||
@@ -3162,7 +3154,7 @@ HookProc(
|
||||
|
||||
Tcl_WinUtfToTChar(Tcl_GetString(phd->titleObj), -1, &title);
|
||||
if (Tcl_DStringLength(&title) > 0) {
|
||||
SetWindowText(hwndDlg, (LPCTSTR) Tcl_DStringValue(&title));
|
||||
SetWindowTextW(hwndDlg, (LPCWSTR) Tcl_DStringValue(&title));
|
||||
}
|
||||
Tcl_DStringFree(&title);
|
||||
}
|
||||
@@ -3195,10 +3187,10 @@ 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);
|
||||
SendMessageW(hwndDlg, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM) &lf);
|
||||
if (phd && phd->cmdObj) {
|
||||
ApplyLogfont(phd->interp, phd->cmdObj, hdc, &lf);
|
||||
}
|
||||
@@ -3351,7 +3343,7 @@ FontchooserConfigureCmd(
|
||||
Tk_Window parent = Tk_NameToWindow(interp,
|
||||
Tcl_GetString(objv[i+1]), tkwin);
|
||||
|
||||
if (parent == None) {
|
||||
if (parent == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (hdPtr->parentObj) {
|
||||
@@ -3434,8 +3426,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;
|
||||
@@ -3446,7 +3438,7 @@ FontchooserShowCmd(
|
||||
if (hdPtr->parentObj) {
|
||||
parent = Tk_NameToWindow(interp, Tcl_GetString(hdPtr->parentObj),
|
||||
tkwin);
|
||||
if (parent == None) {
|
||||
if (parent == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -3478,7 +3470,7 @@ FontchooserShowCmd(
|
||||
fontPtr = (TkFont *) f;
|
||||
cf.Flags |= CF_INITTOLOGFONTSTRUCT;
|
||||
Tcl_WinUtfToTChar(fontPtr->fa.family, -1, &ds);
|
||||
_tcsncpy(lf.lfFaceName, (TCHAR *)Tcl_DStringValue(&ds),
|
||||
wcsncpy(lf.lfFaceName, (WCHAR *)Tcl_DStringValue(&ds),
|
||||
LF_FACESIZE-1);
|
||||
Tcl_DStringFree(&ds);
|
||||
lf.lfFaceName[LF_FACESIZE-1] = 0;
|
||||
@@ -3510,7 +3502,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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user