From 38f3f6ea63f51c5d80a215f5bf71fd23ac5117f2 Mon Sep 17 00:00:00 2001 From: hobbs Date: Fri, 21 Sep 2001 22:13:52 +0000 Subject: * win/tkWinWindow.c (TkpPrintWindowId, TkpScanWindowId): fixed to work on Win64 with 64bit XIDs. --- win/tkWinWindow.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index e2fa95b..b1484c7 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinWindow.c,v 1.6 2000/07/06 03:17:45 mo Exp $ + * RCS: @(#) $Id: tkWinWindow.c,v 1.7 2001/09/21 22:13:52 hobbs Exp $ */ #include "tkWinInt.h" @@ -173,7 +173,11 @@ TkpPrintWindowId(buf, window) Window window; /* Window to be printed into buffer. */ { HWND hwnd = (window) ? Tk_GetHWND(window) : 0; - sprintf(buf, "0x%x", (unsigned int) hwnd); + /* + * Use pointer representation, because Win64 is P64 (*not* LP64). + * Windows doesn't print the 0x for %p, so we do it. + */ + sprintf(buf, "0x%p", hwnd); } /* @@ -203,14 +207,23 @@ TkpScanWindowId(interp, string, idPtr) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ char *string; /* String containing a (possibly signed) * integer in a form acceptable to strtol. */ - int *idPtr; /* Place to store converted result. */ + Window *idPtr; /* Place to store converted result. */ { - int number; Tk_Window tkwin; + Window number; - if (Tcl_GetInt(interp, string, &number) != TCL_OK) { + /* + * We want sscanf for the 64-bit check, but if that doesn't work, + * then Tcl_GetInt manages the error correctly. + */ + if ( +#ifdef _WIN64 + (sscanf(string, "0x%p", &number) != 1) && +#endif + Tcl_GetInt(interp, string, (int *)&number) != TCL_OK) { return TCL_ERROR; } + tkwin = Tk_HWNDToWindow((HWND)number); if (tkwin) { *idPtr = Tk_WindowId(tkwin); -- cgit v0.12