tkWinDialog.c
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:75k
- /*
- * tkWinDialog.c --
- *
- * Contains the Windows implementation of the common dialog boxes.
- *
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tkWinDialog.c,v 1.30.2.5 2005/10/05 03:51:09 hobbs Exp $
- *
- */
- #include "tkWinInt.h"
- #include "tkFileFilter.h"
- #include <commdlg.h> /* includes common dialog functionality */
- #include <dlgs.h> /* includes common dialog template defines */
- #include <cderr.h> /* includes the common dialog error codes */
- /*
- * This controls the use of the new style tk_chooseDirectory dialog.
- */
- #define USE_NEW_CHOOSEDIR 1
- #ifdef USE_NEW_CHOOSEDIR
- #include <shlobj.h> /* includes SHBrowseForFolder */
- /* These needed for compilation with VC++ 5.2 */
- #ifndef BIF_EDITBOX
- #define BIF_EDITBOX 0x10
- #endif
- #ifndef BIF_VALIDATE
- #define BIF_VALIDATE 0x0020
- #endif
- #ifndef BFFM_VALIDATEFAILED
- #ifdef UNICODE
- #define BFFM_VALIDATEFAILED 4
- #else
- #define BFFM_VALIDATEFAILED 3
- #endif
- #endif
- /*
- * The following structure is used by the new Tk_ChooseDirectoryObjCmd
- * to pass data between it and its callback. Unqiue to Winodws platform.
- */
- typedef struct ChooseDirData {
- TCHAR utfInitDir[MAX_PATH]; /* Initial folder to use */
- TCHAR utfRetDir[MAX_PATH]; /* Returned folder to use */
- Tcl_Interp *interp;
- int mustExist; /* true if file must exist to return from
- * callback */
- } CHOOSEDIRDATA;
- #endif
- typedef struct ThreadSpecificData {
- int debugFlag; /* Flags whether we should output debugging
- * information while displaying a builtin
- * dialog. */
- Tcl_Interp *debugInterp; /* Interpreter to used for debugging. */
- UINT WM_LBSELCHANGED; /* Holds a registered windows event used for
- * communicating between the Directory
- * Chooser dialog and its hook proc. */
- HHOOK hMsgBoxHook; /* Hook proc for tk_messageBox and the */
- HICON hSmallIcon; /* icons used by a parent to be used in */
- HICON hBigIcon; /* the message box */
- } ThreadSpecificData;
- static Tcl_ThreadDataKey dataKey;
- /*
- * The following structures are used by Tk_MessageBoxCmd() to parse
- * arguments and return results.
- */
- static const TkStateMap iconMap[] = {
- {MB_ICONERROR, "error"},
- {MB_ICONINFORMATION, "info"},
- {MB_ICONQUESTION, "question"},
- {MB_ICONWARNING, "warning"},
- {-1, NULL}
- };
-
- static const TkStateMap typeMap[] = {
- {MB_ABORTRETRYIGNORE, "abortretryignore"},
- {MB_OK, "ok"},
- {MB_OKCANCEL, "okcancel"},
- {MB_RETRYCANCEL, "retrycancel"},
- {MB_YESNO, "yesno"},
- {MB_YESNOCANCEL, "yesnocancel"},
- {-1, NULL}
- };
- static const TkStateMap buttonMap[] = {
- {IDABORT, "abort"},
- {IDRETRY, "retry"},
- {IDIGNORE, "ignore"},
- {IDOK, "ok"},
- {IDCANCEL, "cancel"},
- {IDNO, "no"},
- {IDYES, "yes"},
- {-1, NULL}
- };
- static const int buttonFlagMap[] = {
- MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON3, MB_DEFBUTTON4
- };
- static const struct {int type; int btnIds[3];} allowedTypes[] = {
- {MB_ABORTRETRYIGNORE, {IDABORT, IDRETRY, IDIGNORE}},
- {MB_OK, {IDOK, -1, -1 }},
- {MB_OKCANCEL, {IDOK, IDCANCEL, -1 }},
- {MB_RETRYCANCEL, {IDRETRY, IDCANCEL, -1 }},
- {MB_YESNO, {IDYES, IDNO, -1 }},
- {MB_YESNOCANCEL, {IDYES, IDNO, IDCANCEL}}
- };
- #define NUM_TYPES (sizeof(allowedTypes) / sizeof(allowedTypes[0]))
- /*
- * The value of TK_MULTI_MAX_PATH dictactes how many files can
- * be retrieved with tk_get*File -multiple 1. It must be allocated
- * on the stack, so make it large enough but not too large. -- hobbs
- * The data is stored as <dir>