Sync to Wine-20050419:
Francois Gouget <fgouget@free.fr>
- Assorted spelling fixes.
- SBSP_ABSOLUTE is 0 so we cannot do (wFlags & SBSP_ABSOLUTE).
- Add COMDLG32_DumpSBSPFlags().
Eric Pouech <pouech-eric@wanadoo.fr>
- Added proper definition for PRINTDLGEX[AW] structures.
Jakob Eriksson <jakov@vmlinux.org>
- Get rid of HeapAlloc casts.
Juan Lang <juan_lang@yahoo.com>
- Change a fixme to a warn, and use W version of call.
Peter Berg Larsen <pebl@math.ku.dk>
- Replace strncpy with memcpy or lstrcpyn.
- Janitorial: Get rid of strncpy/strncpyW.
Modified: trunk/reactos/lib/comdlg32/colordlg.c
Modified: trunk/reactos/lib/comdlg32/colordlg16.c
Modified: trunk/reactos/lib/comdlg32/filedlg.c
Modified: trunk/reactos/lib/comdlg32/filedlgbrowser.c
Modified: trunk/reactos/lib/comdlg32/printdlg.c
Modified: trunk/reactos/lib/comdlg32/printdlg16.c
Modified: trunk/reactos/w32api/include/shlobj.h

Modified: trunk/reactos/lib/comdlg32/colordlg.c
--- trunk/reactos/lib/comdlg32/colordlg.c	2005-04-26 19:06:19 UTC (rev 14820)
+++ trunk/reactos/lib/comdlg32/colordlg.c	2005-04-26 19:18:13 UTC (rev 14821)
@@ -65,7 +65,7 @@
 /* Chose Color PRIVATE Structure:
  *
  * This structure is duplicated in the 16 bit code with
- * a extra member
+ * an extra member
  */
 
 typedef struct CCPRIVATE

Modified: trunk/reactos/lib/comdlg32/colordlg16.c
--- trunk/reactos/lib/comdlg32/colordlg16.c	2005-04-26 19:06:19 UTC (rev 14820)
+++ trunk/reactos/lib/comdlg32/colordlg16.c	2005-04-26 19:18:13 UTC (rev 14821)
@@ -46,7 +46,7 @@
 /* Chose Color PRIVATE Structure:
  *
  * This is a duplicate of the 32bit code with
- * a extra member
+ * an extra member
  */
 typedef struct CCPRIVATE
 {

Modified: trunk/reactos/lib/comdlg32/filedlg.c
--- trunk/reactos/lib/comdlg32/filedlg.c	2005-04-26 19:06:19 UTC (rev 14820)
+++ trunk/reactos/lib/comdlg32/filedlg.c	2005-04-26 19:18:13 UTC (rev 14821)
@@ -462,16 +462,17 @@
   if(ofn->lpstrFile)
   {
     fodInfos.filename = MemAlloc(ofn->nMaxFile*sizeof(WCHAR));
-    strncpyW(fodInfos.filename,ofn->lpstrFile,ofn->nMaxFile);
+    lstrcpynW(fodInfos.filename,ofn->lpstrFile,ofn->nMaxFile);
   }
   else
     fodInfos.filename = NULL;
 
   if(ofn->lpstrInitialDir)
   {
-    DWORD len = strlenW(ofn->lpstrInitialDir);
-    fodInfos.initdir = MemAlloc((len+1)*sizeof(WCHAR));
-    strcpyW(fodInfos.initdir,ofn->lpstrInitialDir);
+    /* fodInfos.initdir = strdupW(ofn->lpstrInitialDir); */
+    DWORD len = strlenW(ofn->lpstrInitialDir)+1;
+    fodInfos.initdir = MemAlloc(len*sizeof(WCHAR));
+    memcpy(fodInfos.initdir,ofn->lpstrInitialDir,len*sizeof(WCHAR));
   }
   else
     fodInfos.initdir = NULL;
@@ -853,7 +854,7 @@
 
         /* Prepend the current path */
         n = strlenW(lpstrCurrentDir) + 1;
-        strncpyW( bufW, lpstrCurrentDir, size );
+        memcpy( bufW, lpstrCurrentDir, min(n,size) * sizeof(WCHAR));
         if(n<size)
         {
             /* 'n' includes trailing \0 */
@@ -2034,7 +2035,7 @@
              {
                LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
 
-               strncpyW(ofn->lpstrFile, lpstrPathAndFile, ofn->nMaxFile);
+               lstrcpynW(ofn->lpstrFile, lpstrPathAndFile, ofn->nMaxFile);
                if (ofn->Flags & OFN_ALLOWMULTISELECT)
                  ofn->lpstrFile[lstrlenW(ofn->lpstrFile) + 1] = '\0';
              }
@@ -2064,7 +2065,7 @@
             if(fodInfos->unicode)
             {
               LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
-	      strncpyW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
+	      lstrcpynW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
             }
             else
             {
@@ -2406,7 +2407,7 @@
 /***********************************************************************
  *      FILEDLG95_FILETYPE_SearchExt
  *
- * searches for a extension in the filetype box
+ * searches for an extension in the filetype box
  */
 static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCWSTR lpstrExt)
 {
@@ -2958,7 +2959,7 @@
 
     /* allocate the buffer */
     if (nFiles <= 1) nLength = MAX_PATH;
-    lpstrAllFile = (LPSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength);
+    lpstrAllFile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength);
     lpstrAllFile[0] = '\0';
 
     /* Generate the string for the edit control */

Modified: trunk/reactos/lib/comdlg32/filedlgbrowser.c
--- trunk/reactos/lib/comdlg32/filedlgbrowser.c	2005-04-26 19:06:19 UTC (rev 14820)
+++ trunk/reactos/lib/comdlg32/filedlgbrowser.c	2005-04-26 19:18:13 UTC (rev 14821)
@@ -95,6 +95,49 @@
  *   Helper functions
  */
 
+#define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
+static void COMDLG32_DumpSBSPFlags(UINT uflags)
+{
+    if (TRACE_ON(commdlg))
+    {
+	unsigned int   i;
+	static const struct {
+	    DWORD       mask;
+	    const char  *name;
+	} flags[] = {
+#define FE(x) { x, #x}
+            /* SBSP_DEFBROWSER == 0 */
+            FE(SBSP_SAMEBROWSER),
+            FE(SBSP_NEWBROWSER),
+
+            /* SBSP_DEFMODE == 0 */
+            FE(SBSP_OPENMODE),
+            FE(SBSP_EXPLOREMODE),
+            FE(SBSP_HELPMODE),
+            FE(SBSP_NOTRANSFERHIST),
+
+            /* SBSP_ABSOLUTE == 0 */
+            FE(SBSP_RELATIVE),
+            FE(SBSP_PARENT),
+            FE(SBSP_NAVIGATEBACK),
+            FE(SBSP_NAVIGATEFORWARD),
+            FE(SBSP_ALLOW_AUTONAVIGATE),
+
+            FE(SBSP_NOAUTOSELECT),
+            FE(SBSP_WRITENOHISTORY),
+
+            FE(SBSP_REDIRECT),
+            FE(SBSP_INITIATEDBYHLINKFRAME),
+        };
+#undef FE
+        DPRINTF("SBSP Flags: %08x =", uflags);
+	for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
+	    if (flags[i].mask & uflags)
+		DPRINTF("%s ", flags[i].name);
+	DPRINTF("\n");
+    }
+}
+
 static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos)
 {
     char lpstrPath[MAX_PATH];
@@ -314,10 +357,8 @@
 
     IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
 
-    TRACE("(%p)(pidl=%p,flags=0x%08x(%s))\n", This, pidl, wFlags,
-	(wFlags & SBSP_RELATIVE) ? "SBSP_RELATIVE" :
-	(wFlags & SBSP_PARENT) ? "SBSP_PARENT" :
- 	(wFlags & SBSP_ABSOLUTE) ? "SBSP_ABSOLUTE" : "SBPS_????");
+    TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This, pidl, wFlags);
+    COMDLG32_DumpSBSPFlags(wFlags);
 
     fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
 
@@ -720,7 +761,7 @@
 
     fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
 
-    /* If the selected object is not a folder, send a IDOK command to parent window */
+    /* If the selected object is not a folder, send an IDOK command to parent window */
     if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
     {
         HRESULT hRes;

Modified: trunk/reactos/lib/comdlg32/printdlg.c
--- trunk/reactos/lib/comdlg32/printdlg.c	2005-04-26 19:06:19 UTC (rev 14820)
+++ trunk/reactos/lib/comdlg32/printdlg.c	2005-04-26 19:18:13 UTC (rev 14821)
@@ -86,14 +86,14 @@
  */
 BOOL PRINTDLG_OpenDefaultPrinter(HANDLE *hprn)
 {
-    char buf[260];
-    DWORD dwBufLen = sizeof(buf);
+    WCHAR buf[260];
+    DWORD dwBufLen = sizeof(buf) / sizeof(buf[0]);
     BOOL res;
-    if(!GetDefaultPrinterA(buf, &dwBufLen))
+    if(!GetDefaultPrinterW(buf, &dwBufLen))
         return FALSE;
-    res = OpenPrinterA(buf, hprn, NULL);
+    res = OpenPrinterW(buf, hprn, NULL);
     if (!res)
-	FIXME("Could not open printer %s?!\n",buf);
+        WARN("Could not open printer %s\n", debugstr_w(buf));
     return res;
 }
 
@@ -459,7 +459,7 @@
 	goto out;
     }
 
-    Names = (char*)HeapAlloc(GetProcessHeap(),0,NrOfEntries*64);
+    Names = HeapAlloc(GetProcessHeap(),0,NrOfEntries*64);
     if (NrOfEntries != (ret=DeviceCapabilitiesA(devname,portname,DC_PAPERNAMES,Names,dm))) {
 	FIXME("Number of returned vals %d is not %d\n",NrOfEntries,ret);
 	goto out;
@@ -517,7 +517,7 @@
 	goto out;
     }
 
-    Names = (WCHAR*)HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*NrOfEntries*64);
+    Names = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*NrOfEntries*64);
     if (NrOfEntries != (ret=DeviceCapabilitiesW(devname,portname,DC_PAPERNAMES,Names,dm))) {
 	FIXME("Number of returned vals %d is not %d\n",NrOfEntries,ret);
 	goto out;
@@ -3026,6 +3026,7 @@
 	FIXME("stub\n");
 	return E_NOTIMPL;
 }
+
 /***********************************************************************
  *	PrintDlgExW (COMDLG32.@)
  */

Modified: trunk/reactos/lib/comdlg32/printdlg16.c
--- trunk/reactos/lib/comdlg32/printdlg16.c	2005-04-26 19:06:19 UTC (rev 14820)
+++ trunk/reactos/lib/comdlg32/printdlg16.c	2005-04-26 19:18:13 UTC (rev 14821)
@@ -427,7 +427,7 @@
         ptr16 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PRINT_PTRA16));
         ptr16->lpPrintDlg16 = lppd;
         PrintStructures = &ptr16->print32;
-        PrintStructures->lpPrintDlg = (LPPRINTDLGA)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(PRINTDLGA));
+        PrintStructures->lpPrintDlg = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(PRINTDLGA));
 #define CVAL(x)	PrintStructures->lpPrintDlg->x = lppd->x;
 #define MVAL(x)	PrintStructures->lpPrintDlg->x = MapSL(lppd->x);
 	CVAL(Flags);

Modified: trunk/reactos/w32api/include/shlobj.h
--- trunk/reactos/w32api/include/shlobj.h	2005-04-26 19:06:19 UTC (rev 14820)
+++ trunk/reactos/w32api/include/shlobj.h	2005-04-26 19:18:13 UTC (rev 14821)
@@ -315,8 +315,15 @@
 #define SBSP_OPENMODE	16
 #define SBSP_EXPLOREMODE	32
 #define SBSP_ABSOLUTE	0
+#define SBSP_HELPMODE	0x40
+#define SBSP_NOTRANSFERHIST	0x80
 #define SBSP_RELATIVE	0x1000
 #define SBSP_PARENT	0x2000
+#define SBSP_NAVIGATEBACK	0x4000
+#define SBSP_NAVIGATEFORWARD	0x8000
+#define SBSP_ALLOW_AUTONAVIGATE	0x10000
+#define SBSP_NOAUTOSELECT	0x4000000
+#define SBSP_WRITENOHISTORY	0x8000000
 #define SBSP_INITIATEDBYHLINKFRAME	0x80000000
 #define SBSP_REDIRECT	0x40000000
 #define FCW_STATUS	1