Hello,
Well this is it. Other then in the print dialogs all of the internal
Win16isms are GONE!!!! In a few days I will start on the print dialogs
again.
Now if only it will work =)
Thanks
Steven
Changelog:
Remove calls to FindResource16, FreeResource16, GlobalAlloc16, GlobalFree16
GlobalLock16, GlobalUnLock16, LoadResource16 when building as a 32 bit dll.
Create new internal functions FILEDLG_MapOfnStruct16 and
FILEDLG_DestroyPrivate16.
Share a few other internal functions with the 16 bit commdlg.
Index: filedlg.h
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/filedlg.h,v
retrieving revision 1.2
diff -u -r1.2 filedlg.h
--- filedlg.h 24 Jun 2003 19:24:29 -0000 1.2
+++ filedlg.h 26 Jun 2003 01:43:40 -0000
@@ -60,6 +60,7 @@
LPWSTR FILEDLG_GetFileType(LPWSTR cfptr, LPWSTR fptr, WORD index);
void FILEDLG_MapDrawItemStruct(LPDRAWITEMSTRUCT16 lpdis16, LPDRAWITEMSTRUCT lpdis);
+void FILEDLG_MapOfnStructA(LPOPENFILENAMEA ofnA, LPOPENFILENAMEW ofnW, BOOL open);
BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath);
LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
int savedlg, LPDRAWITEMSTRUCT lpdis);
Index: filedlg.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/filedlg.c,v
retrieving revision 1.64
diff -u -r1.64 filedlg.c
--- filedlg.c 24 Jun 2003 19:24:29 -0000 1.64
+++ filedlg.c 26 Jun 2003 01:43:48 -0000
@@ -155,81 +155,6 @@
return TRUE;
}
-
-/***********************************************************************
- * Get16BitsTemplate [internal]
- *
- * Get a template (FALSE if failure) when 16 bits dialogs are used
- * by a 16 bits application
- *
- */
-BOOL Get16BitsTemplate(LFSPRIVATE lfs)
-{
- LPOPENFILENAME16 ofn16 = lfs->ofn16;
- LPCVOID template;
- HGLOBAL16 hGlobal16 = 0;
-
- if (ofn16->Flags & OFN_ENABLETEMPLATEHANDLE)
- lfs->hDlgTmpl16 = ofn16->hInstance;
- else if (ofn16->Flags & OFN_ENABLETEMPLATE)
- {
- HANDLE16 hResInfo;
- if (!(hResInfo = FindResource16(ofn16->hInstance,
- MapSL(ofn16->lpTemplateName),
- RT_DIALOGA)))
- {
- COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
- return FALSE;
- }
- if (!(lfs->hDlgTmpl16 = LoadResource16( ofn16->hInstance, hResInfo )))
- {
- COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
- return FALSE;
- }
- lfs->hResource16 = lfs->hDlgTmpl16;
- }
- else
- { /* get resource from (32 bits) own Wine resource; convert it to 16 */
- HRSRC hResInfo;
- HGLOBAL hDlgTmpl32;
- LPCVOID template32;
- DWORD size;
-
- if (!(hResInfo = FindResourceA(COMDLG32_hInstance,
- lfs->open ? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA)))
- {
- COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
- return FALSE;
- }
- if (!(hDlgTmpl32 = LoadResource(COMDLG32_hInstance, hResInfo )) ||
- !(template32 = LockResource( hDlgTmpl32 )))
- {
- COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
- return FALSE;
- }
- size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
- hGlobal16 = GlobalAlloc16(0, size);
- if (!hGlobal16)
- {
- COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
- ERR("alloc failure for %ld bytes\n", size);
- return FALSE;
- }
- template = GlobalLock16(hGlobal16);
- if (!template)
- {
- COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
- ERR("global lock failure for %x handle\n", hGlobal16);
- GlobalFree16(hGlobal16);
- return FALSE;
- }
- ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
- lfs->hDlgTmpl16 = hGlobal16;
- lfs->hGlobal16 = hGlobal16;
- }
- return TRUE;
-}
-
/***********************************************************************
* FILEDLG_StripEditControl [internal]
* Strip pathnames off the contents of the edit control.
@@ -1107,44 +1032,6 @@
}
}
-
-/************************************************************************
- * FILEDLG_MapOfnStruct16 [internal]
- * map a 16 bits structure to an Unicode one
- */
-void FILEDLG_MapOfnStruct16(LPOPENFILENAME16 ofn16, LPOPENFILENAMEW ofnW, BOOL open)
-{
- OPENFILENAMEA ofnA;
- /* first convert to linear pointers */
- memset(&ofnA, 0, sizeof(OPENFILENAMEA));
- ofnA.lStructSize = sizeof(OPENFILENAMEA);
- ofnA.hwndOwner = HWND_32(ofn16->hwndOwner);
- ofnA.hInstance = HINSTANCE_32(ofn16->hInstance);
- if (ofn16->lpstrFilter)
- ofnA.lpstrFilter = MapSL(ofn16->lpstrFilter);
- if (ofn16->lpstrCustomFilter)
- ofnA.lpstrCustomFilter = MapSL(ofn16->lpstrCustomFilter);
- ofnA.nMaxCustFilter = ofn16->nMaxCustFilter;
- ofnA.nFilterIndex = ofn16->nFilterIndex;
- ofnA.lpstrFile = MapSL(ofn16->lpstrFile);
- ofnA.nMaxFile = ofn16->nMaxFile;
- ofnA.lpstrFileTitle = MapSL(ofn16->lpstrFileTitle);
- ofnA.nMaxFileTitle = ofn16->nMaxFileTitle;
- ofnA.lpstrInitialDir = MapSL(ofn16->lpstrInitialDir);
- ofnA.lpstrTitle = MapSL(ofn16->lpstrTitle);
- ofnA.Flags = ofn16->Flags;
- ofnA.nFileOffset = ofn16->nFileOffset;
- ofnA.nFileExtension = ofn16->nFileExtension;
- ofnA.lpstrDefExt = MapSL(ofn16->lpstrDefExt);
- if (HIWORD(ofn16->lpTemplateName))
- ofnA.lpTemplateName = MapSL(ofn16->lpTemplateName);
- else
- ofnA.lpTemplateName = (LPSTR) ofn16->lpTemplateName; /* ressource number */
- /* now calls the 32 bits Ansi to Unicode version to complete the job */
- FILEDLG_MapOfnStructA(&ofnA, ofnW, open);
-}
-
-
/************************************************************************
* FILEDLG_DestroyPrivate [internal]
* destroys the private object
@@ -1154,15 +1041,8 @@
HWND hwnd;
if (!lfs) return;
hwnd = lfs->hwnd;
- /* free resources for a 16 bits dialog */
- if (lfs->hResource16) FreeResource16(lfs->hResource16);
- if (lfs->hGlobal16)
- {
- GlobalUnlock16(lfs->hGlobal16);
- GlobalFree16(lfs->hGlobal16);
- }
/* if ofnW has been allocated, have to free everything in it */
- if (lfs->ofn16 || lfs->ofnA)
+ if (lfs->ofnA)
{
LPOPENFILENAMEW ofnW = lfs->ofnW;
if (ofnW->lpstrFilter) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrFilter);
@@ -1185,7 +1065,7 @@
* allocate a private object to hold 32 bits Unicode
* structure that will be used throughtout the calls, while
* keeping available the original structures and a few variables
- * On entry : type = dialog procedure type (16,32A,32W)
+ * On entry : type = dialog procedure type (32A,32W)
* dlgType = dialog type (open or save)
*/
LFSPRIVATE FILEDLG_AllocPrivate(LPARAM lParam, int type, UINT dlgType)
@@ -1204,14 +1084,6 @@
lfs->fileokstring = RegisterWindowMessageA(FILEOKSTRINGA);
switch(type)
{
- case LFS16:
- lfs->ofn16 = MapSL(lParam);
- if (lfs->ofn16->Flags & OFN_ENABLEHOOK)
- if (lfs->ofn16->lpfnHook)
- lfs->hook = TRUE;
-
- break;
-
case LFS32A:
lfs->ofnA = (LPOPENFILENAMEA) lParam;
if (lfs->ofnA->Flags & OFN_ENABLEHOOK)
@@ -1232,20 +1104,13 @@
lfs->ofnW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OPENFILENAMEW));
if (lfs->ofnW)
{
- if (lfs->ofn16)
- FILEDLG_MapOfnStruct16(lfs->ofn16, lfs->ofnW, lfs->open);
if (lfs->ofnA)
FILEDLG_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open);
}
else
ret = NULL;
}
- if (lfs->ofn16)
- {
- if (!Get16BitsTemplate(lfs)) ret = NULL;
- }
- else
- if (!Get32BitsTemplate(lfs)) ret = NULL;
+ if (!Get32BitsTemplate(lfs)) ret = NULL;
if (!ret) FILEDLG_DestroyPrivate(lfs);
return ret;
}
Index: filedlg16.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/filedlg16.c,v
retrieving revision 1.2
diff -u -r1.2 filedlg16.c
--- filedlg16.c 24 Jun 2003 19:24:29 -0000 1.2
+++ filedlg16.c 26 Jun 2003 01:43:56 -0000
@@ -184,6 +184,195 @@
return TRUE;
}
+/***********************************************************************
+ * Get16BitsTemplate [internal]
+ *
+ * Get a template (FALSE if failure) when 16 bits dialogs are used
+ * by a 16 bits application
+ *
+ */
+BOOL Get16BitsTemplate(LFSPRIVATE lfs)
+{
+ LPOPENFILENAME16 ofn16 = lfs->ofn16;
+ LPCVOID template;
+ HGLOBAL16 hGlobal16 = 0;
+
+ if (ofn16->Flags & OFN_ENABLETEMPLATEHANDLE)
+ lfs->hDlgTmpl16 = ofn16->hInstance;
+ else if (ofn16->Flags & OFN_ENABLETEMPLATE)
+ {
+ HANDLE16 hResInfo;
+ if (!(hResInfo = FindResource16(ofn16->hInstance,
+ MapSL(ofn16->lpTemplateName),
+ RT_DIALOGA)))
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
+ return FALSE;
+ }
+ if (!(lfs->hDlgTmpl16 = LoadResource16( ofn16->hInstance, hResInfo )))
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
+ return FALSE;
+ }
+ lfs->hResource16 = lfs->hDlgTmpl16;
+ }
+ else
+ { /* get resource from (32 bits) own Wine resource; convert it to 16 */
+ HRSRC hResInfo;
+ HGLOBAL hDlgTmpl32;
+ LPCVOID template32;
+ DWORD size;
+
+ if (!(hResInfo = FindResourceA(COMDLG32_hInstance,
+ lfs->open ? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA)))
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
+ return FALSE;
+ }
+ if (!(hDlgTmpl32 = LoadResource(COMDLG32_hInstance, hResInfo )) ||
+ !(template32 = LockResource( hDlgTmpl32 )))
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
+ return FALSE;
+ }
+ size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
+ hGlobal16 = GlobalAlloc16(0, size);
+ if (!hGlobal16)
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
+ ERR("alloc failure for %ld bytes\n", size);
+ return FALSE;
+ }
+ template = GlobalLock16(hGlobal16);
+ if (!template)
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
+ ERR("global lock failure for %x handle\n", hGlobal16);
+ GlobalFree16(hGlobal16);
+ return FALSE;
+ }
+ ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
+ lfs->hDlgTmpl16 = hGlobal16;
+ lfs->hGlobal16 = hGlobal16;
+ }
+ return TRUE;
+}
+
+/************************************************************************
+ * FILEDLG_MapOfnStruct16 [internal]
+ * map a 16 bits structure to an Unicode one
+ */
+void FILEDLG_MapOfnStruct16(LPOPENFILENAME16 ofn16, LPOPENFILENAMEW ofnW, BOOL open)
+{
+ OPENFILENAMEA ofnA;
+ /* first convert to linear pointers */
+ memset(&ofnA, 0, sizeof(OPENFILENAMEA));
+ ofnA.lStructSize = sizeof(OPENFILENAMEA);
+ ofnA.hwndOwner = HWND_32(ofn16->hwndOwner);
+ ofnA.hInstance = HINSTANCE_32(ofn16->hInstance);
+ if (ofn16->lpstrFilter)
+ ofnA.lpstrFilter = MapSL(ofn16->lpstrFilter);
+ if (ofn16->lpstrCustomFilter)
+ ofnA.lpstrCustomFilter = MapSL(ofn16->lpstrCustomFilter);
+ ofnA.nMaxCustFilter = ofn16->nMaxCustFilter;
+ ofnA.nFilterIndex = ofn16->nFilterIndex;
+ ofnA.lpstrFile = MapSL(ofn16->lpstrFile);
+ ofnA.nMaxFile = ofn16->nMaxFile;
+ ofnA.lpstrFileTitle = MapSL(ofn16->lpstrFileTitle);
+ ofnA.nMaxFileTitle = ofn16->nMaxFileTitle;
+ ofnA.lpstrInitialDir = MapSL(ofn16->lpstrInitialDir);
+ ofnA.lpstrTitle = MapSL(ofn16->lpstrTitle);
+ ofnA.Flags = ofn16->Flags;
+ ofnA.nFileOffset = ofn16->nFileOffset;
+ ofnA.nFileExtension = ofn16->nFileExtension;
+ ofnA.lpstrDefExt = MapSL(ofn16->lpstrDefExt);
+ if (HIWORD(ofn16->lpTemplateName))
+ ofnA.lpTemplateName = MapSL(ofn16->lpTemplateName);
+ else
+ ofnA.lpTemplateName = (LPSTR) ofn16->lpTemplateName; /* ressource number */
+ /* now calls the 32 bits Ansi to Unicode version to complete the job */
+ FILEDLG_MapOfnStructA(&ofnA, ofnW, open);
+}
+
+/************************************************************************
+ * FILEDLG_DestroyPrivate [internal]
+ * destroys the private object
+ */
+void FILEDLG_DestroyPrivate16(LFSPRIVATE lfs)
+{
+ HWND hwnd;
+ if (!lfs) return;
+ hwnd = lfs->hwnd;
+ /* free resources for a 16 bits dialog */
+ if (lfs->hResource16) FreeResource16(lfs->hResource16);
+ if (lfs->hGlobal16)
+ {
+ GlobalUnlock16(lfs->hGlobal16);
+ GlobalFree16(lfs->hGlobal16);
+ }
+ /* if ofnW has been allocated, have to free everything in it */
+ if (lfs->ofn16)
+ {
+ LPOPENFILENAMEW ofnW = lfs->ofnW;
+ if (ofnW->lpstrFilter) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrFilter);
+ if (ofnW->lpstrCustomFilter) HeapFree(GetProcessHeap(), 0, ofnW->lpstrCustomFilter);
+ if (ofnW->lpstrFile) HeapFree(GetProcessHeap(), 0, ofnW->lpstrFile);
+ if (ofnW->lpstrFileTitle) HeapFree(GetProcessHeap(), 0, ofnW->lpstrFileTitle);
+ if (ofnW->lpstrInitialDir) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrInitialDir);
+ if (ofnW->lpstrTitle) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrTitle);
+ if ((ofnW->lpTemplateName) && (HIWORD(ofnW->lpTemplateName)))
+ HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpTemplateName);
+ HeapFree(GetProcessHeap(), 0, ofnW);
+ }
+ TRACE("destroying private allocation %p\n", lfs);
+ HeapFree(GetProcessHeap(), 0, lfs);
+ RemovePropA(hwnd, OFN_PROP);
+}
+
+/************************************************************************
+ * FILEDLG_AllocPrivate16 [internal]
+ * allocate a 16 bit private object to hold 32 bits Unicode
+ * structure that will be used throughtout the calls, while
+ * keeping available the original structures and a few variables
+ * On entry : dlgType = dialog type (open or save)
+ *
+ */
+LFSPRIVATE FILEDLG_AllocPrivate16(LPARAM lParam, UINT dlgType)
+{
+ LFSPRIVATE lfs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct FSPRIVATE));
+ LFSPRIVATE ret;
+ TRACE("alloc private buf %p\n", lfs);
+ if (!lfs) return NULL;
+ lfs->hook = FALSE;
+ lfs->lParam = lParam;
+ if (dlgType == OPEN_DIALOG)
+ lfs->open = TRUE;
+ else
+ lfs->open = FALSE;
+ lfs->lbselchstring = RegisterWindowMessageA(LBSELCHSTRINGA);
+ lfs->fileokstring = RegisterWindowMessageA(FILEOKSTRINGA);
+ lfs->ofn16 = MapSL(lParam);
+
+ if (lfs->ofn16->Flags & OFN_ENABLEHOOK)
+ if (lfs->ofn16->lpfnHook)
+ lfs->hook = TRUE;
+ ret = lfs;
+ if (!lfs->ofnW)
+ { /* this structure is needed internally, so create it */
+ lfs->ofnW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OPENFILENAMEW));
+ if (lfs->ofnW)
+ {
+ if (lfs->ofn16)
+ FILEDLG_MapOfnStruct16(lfs->ofn16, lfs->ofnW, lfs->open);
+ }
+ else
+ ret = NULL;
+ }
+ if (!Get16BitsTemplate(lfs)) ret = NULL;
+ if (!ret) FILEDLG_DestroyPrivate16(lfs);
+ return ret;
+}
+
/* ------------------ Dialog procedures ---------------------- */
/***********************************************************************
@@ -312,14 +501,14 @@
if (!lpofn || !FileDlg_Init()) return FALSE;
- lfs = FILEDLG_AllocPrivate((LPARAM) ofn, LFS16, OPEN_DIALOG);
+ lfs = FILEDLG_AllocPrivate16((LPARAM) ofn, OPEN_DIALOG);
if (lfs)
{
hInst = GetWindowWord( HWND_32(lpofn->hwndOwner), GWL_HINSTANCE );
ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 6);
bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner,
(DLGPROC16) ptr, (LPARAM) lfs);
- FILEDLG_DestroyPrivate(lfs);
+ FILEDLG_DestroyPrivate16(lfs);
}
TRACE("return lpstrFile='%s' !\n", (char *)MapSL(lpofn->lpstrFile));
@@ -350,14 +539,14 @@
if (!lpofn || !FileDlg_Init()) return FALSE;
- lfs = FILEDLG_AllocPrivate((LPARAM) ofn, LFS16, SAVE_DIALOG);
+ lfs = FILEDLG_AllocPrivate16((LPARAM) ofn, SAVE_DIALOG);
if (lfs)
{
hInst = GetWindowWord( HWND_32(lpofn->hwndOwner), GWL_HINSTANCE );
ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 7);
bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner,
(DLGPROC16) ptr, (LPARAM) lfs);
- FILEDLG_DestroyPrivate(lfs);
+ FILEDLG_DestroyPrivate16(lfs);
}
TRACE("return lpstrFile='%s' !\n", (char *)MapSL(lpofn->lpstrFile));