Tk Source Code

Check-in [106651bb]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix symbol conflict when compiling with latest (??) MinGW-w64.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | apn-win-filedialogs
Files: files | file ages | folders
SHA1: 106651bb3adb996fd59fbc1c7d1d70916dad8ffd
User & Date: jan.nijtmans 2014-10-17 14:24:09
Context
2014-10-17
14:49
Previous commit probably broke higher VS versions (>2012) compilation. Fix that. Closed-Leaf check-in: 29504df7 user: jan.nijtmans tags: apn-win-filedialogs
14:24
Fix symbol conflict when compiling with latest (??) MinGW-w64. check-in: 106651bb user: jan.nijtmans tags: apn-win-filedialogs
2014-10-16
16:36
Make tkWinDialog.c buildable with gcc 4.8.1, vc6, vs2012. Passes all tests check-in: 6d268313 user: ashok tags: apn-win-filedialogs
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to win/tkWinDialog.c.

281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
...
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
...
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
...
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
...
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
....
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
....
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
....
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
typedef struct IPropertyDescriptionList IPropertyDescriptionList;
typedef struct IFileOperationProgressSink IFileOperationProgressSink;
typedef enum FDAP {
    FDAP_BOTTOM	= 0,
    FDAP_TOP	= 1
} FDAP;

typedef struct _COMDLG_FILTERSPEC {
    LPCWSTR pszName;
    LPCWSTR pszSpec;
} COMDLG_FILTERSPEC;

enum _FILEOPENDIALOGOPTIONS {
    FOS_OVERWRITEPROMPT	= 0x2,
    FOS_STRICTFILETYPES	= 0x4,
    FOS_NOCHANGEDIR	= 0x8,
    FOS_PICKFOLDERS	= 0x20,
    FOS_FORCEFILESYSTEM	= 0x40,
................................................................................
        
    HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
         IFileDialog * this, REFIID riid, void **ppvObject);
    ULONG ( STDMETHODCALLTYPE *AddRef )( IFileDialog * this);
    ULONG ( STDMETHODCALLTYPE *Release )( IFileDialog * this);
    HRESULT ( STDMETHODCALLTYPE *Show )( IFileDialog * this, HWND hwndOwner);
    HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileDialog * this,
        UINT cFileTypes, const COMDLG_FILTERSPEC *rgFilterSpec);
    HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )(IFileDialog * this, UINT);
    HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )(IFileDialog * this, UINT *);
    /* XXX - Actually pfde is IFileDialogEvents* but we do not use
       this call and do not want to define IFileDialogEvents as that
       pulls in a whole bunch of other stuff. */
    HRESULT ( STDMETHODCALLTYPE *Advise )( 
        IFileDialog * this, void *pfde, DWORD *pdwCookie);
................................................................................
    HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
        IFileSaveDialog * this, REFIID riid, void **ppvObject);
    ULONG ( STDMETHODCALLTYPE *AddRef )( IFileSaveDialog * this);
    ULONG ( STDMETHODCALLTYPE *Release )( IFileSaveDialog * this);
    HRESULT ( STDMETHODCALLTYPE *Show )( 
        IFileSaveDialog * this, HWND hwndOwner);
    HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog * this,
        UINT cFileTypes, const COMDLG_FILTERSPEC *rgFilterSpec);
    HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )(
        IFileSaveDialog * this, UINT iFileType);
    HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )( 
         IFileSaveDialog * this, UINT *piFileType);
    /* Actually pfde is IFileSaveDialogEvents* */
    HRESULT ( STDMETHODCALLTYPE *Advise )( 
         IFileSaveDialog * this, void *pfde, DWORD *pdwCookie);
................................................................................
        
    HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
        IFileOpenDialog * this, REFIID riid, void **ppvObject);
    ULONG ( STDMETHODCALLTYPE *AddRef )( IFileOpenDialog * this);
    ULONG ( STDMETHODCALLTYPE *Release )( IFileOpenDialog * this);
    HRESULT ( STDMETHODCALLTYPE *Show )( IFileOpenDialog * this, HWND);
    HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileOpenDialog * this,
        UINT cFileTypes, const COMDLG_FILTERSPEC *rgFilterSpec);
    HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )( 
        IFileOpenDialog * this, UINT iFileType);
    HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )( 
        IFileOpenDialog * this, UINT *piFileType);
    /* Actually pfde is IFileDialogEvents* */
    HRESULT ( STDMETHODCALLTYPE *Advise )( 
        IFileOpenDialog * this, void *pfde, DWORD *pdwCookie);
................................................................................
                         enum OFNOper oper);
static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, 
                            enum OFNOper oper);
static int 		GetFileName(ClientData clientData,
                                    Tcl_Interp *interp, int objc,
                                    Tcl_Obj *const objv[], enum OFNOper oper);
static int MakeFilterVista(Tcl_Interp *interp, OFNOpts *optsPtr,
               DWORD *countPtr, COMDLG_FILTERSPEC **dlgFilterPtrPtr,
               DWORD *defaultFilterIndexPtr);
static void FreeFilterVista(DWORD count, COMDLG_FILTERSPEC *dlgFilterPtr);
static int 		MakeFilter(Tcl_Interp *interp, Tcl_Obj *valuePtr,
			    Tcl_DString *dsPtr, Tcl_Obj *initialPtr,
			    int *indexPtr);
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 int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
                            enum OFNOper oper)
{
    HRESULT hr;
    HWND hWnd;
    DWORD flags, nfilters, defaultFilterIndex;
    COMDLG_FILTERSPEC *filterPtr = NULL;
    IFileDialog *fdlgIf = NULL;
    IShellItem *dirIf = NULL;
    LPWSTR wstr;
    Tcl_Obj *resultObj = NULL;
    ThreadSpecificData *tsdPtr =
	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
    int oldMode;
................................................................................
 *----------------------------------------------------------------------
 *
 * FreeFilterVista
 *
 *      Frees storage previously allocated by MakeFilterVista.
 *      count is the number of elements in dlgFilterPtr[]
 */
static void FreeFilterVista(DWORD count, COMDLG_FILTERSPEC *dlgFilterPtr)
{
    if (dlgFilterPtr != NULL) {
        DWORD dw;
        for (dw = 0; dw < count; ++dw) {
            if (dlgFilterPtr[dw].pszName != NULL)
                ckfree(dlgFilterPtr[dw].pszName);
            if (dlgFilterPtr[dw].pszSpec != NULL)
................................................................................
 *      described in the comments below.
 *----------------------------------------------------------------------
 */
static int MakeFilterVista(
    Tcl_Interp *interp,		/* Current interpreter. */
    OFNOpts *optsPtr,           /* Caller specified options */
    DWORD *countPtr,            /* Will hold number of filters */
    COMDLG_FILTERSPEC **dlgFilterPtrPtr, /* Will hold pointer to filter array.
                                         Set to NULL if no filters specified.
                                         Must be freed by calling
                                         FreeFilterVista */
    DWORD *initialIndexPtr)     /* Will hold index of default type */
{
    COMDLG_FILTERSPEC *dlgFilterPtr;
    const char *initial = NULL;
    FileFilterList flist;
    FileFilter *filterPtr;
    DWORD initialIndex = 0;
    Tcl_DString ds, patterns;
    int       i;







|


|







 







|







 







|







 







|







 







|

|







 







|







 







|







 







|





|







281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
...
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
...
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
...
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
...
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
....
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
....
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
....
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
typedef struct IPropertyDescriptionList IPropertyDescriptionList;
typedef struct IFileOperationProgressSink IFileOperationProgressSink;
typedef enum FDAP {
    FDAP_BOTTOM	= 0,
    FDAP_TOP	= 1
} FDAP;

typedef struct {
    LPCWSTR pszName;
    LPCWSTR pszSpec;
} TCLCOMDLG_FILTERSPEC;

enum _FILEOPENDIALOGOPTIONS {
    FOS_OVERWRITEPROMPT	= 0x2,
    FOS_STRICTFILETYPES	= 0x4,
    FOS_NOCHANGEDIR	= 0x8,
    FOS_PICKFOLDERS	= 0x20,
    FOS_FORCEFILESYSTEM	= 0x40,
................................................................................
        
    HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
         IFileDialog * this, REFIID riid, void **ppvObject);
    ULONG ( STDMETHODCALLTYPE *AddRef )( IFileDialog * this);
    ULONG ( STDMETHODCALLTYPE *Release )( IFileDialog * this);
    HRESULT ( STDMETHODCALLTYPE *Show )( IFileDialog * this, HWND hwndOwner);
    HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileDialog * this,
        UINT cFileTypes, const TCLCOMDLG_FILTERSPEC *rgFilterSpec);
    HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )(IFileDialog * this, UINT);
    HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )(IFileDialog * this, UINT *);
    /* XXX - Actually pfde is IFileDialogEvents* but we do not use
       this call and do not want to define IFileDialogEvents as that
       pulls in a whole bunch of other stuff. */
    HRESULT ( STDMETHODCALLTYPE *Advise )( 
        IFileDialog * this, void *pfde, DWORD *pdwCookie);
................................................................................
    HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
        IFileSaveDialog * this, REFIID riid, void **ppvObject);
    ULONG ( STDMETHODCALLTYPE *AddRef )( IFileSaveDialog * this);
    ULONG ( STDMETHODCALLTYPE *Release )( IFileSaveDialog * this);
    HRESULT ( STDMETHODCALLTYPE *Show )( 
        IFileSaveDialog * this, HWND hwndOwner);
    HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog * this,
        UINT cFileTypes, const TCLCOMDLG_FILTERSPEC *rgFilterSpec);
    HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )(
        IFileSaveDialog * this, UINT iFileType);
    HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )( 
         IFileSaveDialog * this, UINT *piFileType);
    /* Actually pfde is IFileSaveDialogEvents* */
    HRESULT ( STDMETHODCALLTYPE *Advise )( 
         IFileSaveDialog * this, void *pfde, DWORD *pdwCookie);
................................................................................
        
    HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
        IFileOpenDialog * this, REFIID riid, void **ppvObject);
    ULONG ( STDMETHODCALLTYPE *AddRef )( IFileOpenDialog * this);
    ULONG ( STDMETHODCALLTYPE *Release )( IFileOpenDialog * this);
    HRESULT ( STDMETHODCALLTYPE *Show )( IFileOpenDialog * this, HWND);
    HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileOpenDialog * this,
        UINT cFileTypes, const TCLCOMDLG_FILTERSPEC *rgFilterSpec);
    HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )( 
        IFileOpenDialog * this, UINT iFileType);
    HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )( 
        IFileOpenDialog * this, UINT *piFileType);
    /* Actually pfde is IFileDialogEvents* */
    HRESULT ( STDMETHODCALLTYPE *Advise )( 
        IFileOpenDialog * this, void *pfde, DWORD *pdwCookie);
................................................................................
                         enum OFNOper oper);
static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, 
                            enum OFNOper oper);
static int 		GetFileName(ClientData clientData,
                                    Tcl_Interp *interp, int objc,
                                    Tcl_Obj *const objv[], enum OFNOper oper);
static int MakeFilterVista(Tcl_Interp *interp, OFNOpts *optsPtr,
               DWORD *countPtr, TCLCOMDLG_FILTERSPEC **dlgFilterPtrPtr,
               DWORD *defaultFilterIndexPtr);
static void FreeFilterVista(DWORD count, TCLCOMDLG_FILTERSPEC *dlgFilterPtr);
static int 		MakeFilter(Tcl_Interp *interp, Tcl_Obj *valuePtr,
			    Tcl_DString *dsPtr, Tcl_Obj *initialPtr,
			    int *indexPtr);
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 int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
                            enum OFNOper oper)
{
    HRESULT hr;
    HWND hWnd;
    DWORD flags, nfilters, defaultFilterIndex;
    TCLCOMDLG_FILTERSPEC *filterPtr = NULL;
    IFileDialog *fdlgIf = NULL;
    IShellItem *dirIf = NULL;
    LPWSTR wstr;
    Tcl_Obj *resultObj = NULL;
    ThreadSpecificData *tsdPtr =
	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
    int oldMode;
................................................................................
 *----------------------------------------------------------------------
 *
 * FreeFilterVista
 *
 *      Frees storage previously allocated by MakeFilterVista.
 *      count is the number of elements in dlgFilterPtr[]
 */
static void FreeFilterVista(DWORD count, TCLCOMDLG_FILTERSPEC *dlgFilterPtr)
{
    if (dlgFilterPtr != NULL) {
        DWORD dw;
        for (dw = 0; dw < count; ++dw) {
            if (dlgFilterPtr[dw].pszName != NULL)
                ckfree(dlgFilterPtr[dw].pszName);
            if (dlgFilterPtr[dw].pszSpec != NULL)
................................................................................
 *      described in the comments below.
 *----------------------------------------------------------------------
 */
static int MakeFilterVista(
    Tcl_Interp *interp,		/* Current interpreter. */
    OFNOpts *optsPtr,           /* Caller specified options */
    DWORD *countPtr,            /* Will hold number of filters */
    TCLCOMDLG_FILTERSPEC **dlgFilterPtrPtr, /* Will hold pointer to filter array.
                                         Set to NULL if no filters specified.
                                         Must be freed by calling
                                         FreeFilterVista */
    DWORD *initialIndexPtr)     /* Will hold index of default type */
{
    TCLCOMDLG_FILTERSPEC *dlgFilterPtr;
    const char *initial = NULL;
    FileFilterList flist;
    FileFilter *filterPtr;
    DWORD initialIndex = 0;
    Tcl_DString ds, patterns;
    int       i;