BOOL FD31_CallWindowProc(const FD31_DATA *lfs, UINT wMsg, WPARAM wParam,
LPARAM lParam)
{
- return lfs->callbacks->CWP(lfs, wMsg, wParam, lParam);
+ BOOL ret;
+
+ if (lfs->ofnA)
+ {
+ TRACE("Call hookA %p (%p, %04x, %08lx, %08lx)\n",
+ lfs->ofnA->lpfnHook, lfs->hwnd, wMsg, wParam, lParam);
+ ret = lfs->ofnA->lpfnHook(lfs->hwnd, wMsg, wParam, lParam);
+ TRACE("ret hookA %p (%p, %04x, %08lx, %08lx)\n",
+ lfs->ofnA->lpfnHook, lfs->hwnd, wMsg, wParam, lParam);
+ return ret;
+ }
+
+ TRACE("Call hookW %p (%p, %04x, %08lx, %08lx)\n",
+ lfs->ofnW->lpfnHook, lfs->hwnd, wMsg, wParam, lParam);
+ ret = lfs->ofnW->lpfnHook(lfs->hwnd, wMsg, wParam, lParam);
+ TRACE("Ret hookW %p (%p, %04x, %08lx, %08lx)\n",
+ lfs->ofnW->lpfnHook, lfs->hwnd, wMsg, wParam, lParam);
+ return ret;
}
/***********************************************************************
*/
static BOOL FD31_ScanDir(const OPENFILENAMEW *ofn, HWND hWnd, LPCWSTR newPath)
{
- WCHAR buffer[BUFFILE];
- HWND hdlg, hdlgDir;
- LRESULT lRet = TRUE;
- HCURSOR hCursorWait, oldCursor;
+ WCHAR buffer[BUFFILE];
+ HWND hdlg;
+ LRESULT lRet = TRUE;
+ HCURSOR hCursorWait, oldCursor;
TRACE("Trying to change to %s\n", debugstr_w(newPath));
if ( newPath[0] && !SetCurrentDirectoryW( newPath ))
/* list of directories */
strcpyW(buffer, FILE_star);
- if ((hdlgDir = GetDlgItem(hWnd, lst2)) != 0) {
+ if (GetDlgItem(hWnd, lst2) != 0) {
lRet = DlgDirListW(hWnd, buffer, lst2, stc1, DDL_EXCLUSIVE | DDL_DIRECTORY);
}
SetCursor(oldCursor);
SetBkColor( lpdis->hDC, oldBk );
SetTextColor( lpdis->hDC, oldText );
}
- DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder);
+ DrawIconEx( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder, 16, 16, 0, 0, DI_NORMAL );
HeapFree(GetProcessHeap(), 0, str);
return TRUE;
}
SetBkColor( lpdis->hDC, oldBk );
SetTextColor( lpdis->hDC, oldText );
}
- DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon);
+ DrawIconEx( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon, 16, 16, 0, 0, DI_NORMAL );
HeapFree(GetProcessHeap(), 0, str);
return TRUE;
}
{
int lenstr2;
LPOPENFILENAMEW ofnW = lfs->ofnW;
+ LPOPENFILENAMEA ofnA = lfs->ofnA;
WCHAR tmpstr2[BUFFILE];
WCHAR *p;
if (lenstr2 > 3)
tmpstr2[lenstr2++]='\\';
lstrcpynW(tmpstr2+lenstr2, tmpstr, BUFFILE-lenstr2);
- if (ofnW->lpstrFile)
- lstrcpynW(ofnW->lpstrFile, tmpstr2, ofnW->nMaxFile);
+ if (!ofnW->lpstrFile)
+ return;
+
+ lstrcpynW(ofnW->lpstrFile, tmpstr2, ofnW->nMaxFile);
/* set filename offset */
p = PathFindFileNameW(ofnW->lpstrFile);
debugstr_w(ofnW->lpstrFile), ofnW->nFileOffset, ofnW->nFileExtension);
/* update the real client structures if any */
- lfs->callbacks->UpdateResult(lfs);
+ if (ofnA)
+ {
+ LPSTR lpszTemp;
+ if (ofnW->nMaxFile &&
+ !WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
+ ofnA->lpstrFile, ofnA->nMaxFile, NULL, NULL ))
+ ofnA->lpstrFile[ofnA->nMaxFile-1] = 0;
+
+ /* offsets are not guaranteed to be the same in WCHAR to MULTIBYTE conversion */
+ /* set filename offset */
+ lpszTemp = PathFindFileNameA(ofnA->lpstrFile);
+ ofnA->nFileOffset = (lpszTemp - ofnA->lpstrFile);
+
+ /* set extension offset */
+ lpszTemp = PathFindExtensionA(ofnA->lpstrFile);
+ ofnA->nFileExtension = (*lpszTemp) ? (lpszTemp - ofnA->lpstrFile) + 1 : 0;
+ }
}
/***********************************************************************
{
LONG lRet;
LPOPENFILENAMEW ofnW = lfs->ofnW;
+ LPOPENFILENAMEA ofnA = lfs->ofnA;
+
if (ofnW->lpstrFileTitle != NULL)
{
lRet = SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETCURSEL, 0, 0);
SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETTEXT, lRet,
(LPARAM)ofnW->lpstrFileTitle );
- lfs->callbacks->UpdateFileTitle(lfs);
+ if (ofnA)
+ {
+ if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFileTitle, -1,
+ ofnA->lpstrFileTitle, ofnA->nMaxFileTitle, NULL, NULL ))
+ ofnA->lpstrFileTitle[ofnA->nMaxFileTitle-1] = 0;
+ }
}
}
HWND hWnd = lfs->hwnd;
LPWSTR pstr;
- lRet = lfs->callbacks->SendLbGetCurSel(lfs);
+ lRet = SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETCURSEL, 0, 0);
if (lRet == LB_ERR)
return TRUE;
/************************************************************************
* FD31_MapOfnStructA [internal]
- * map a 32 bits Ansi structure to an Unicode one
+ * map a 32 bits Ansi structure to a Unicode one
*/
void FD31_MapOfnStructA(const OPENFILENAMEA *ofnA, LPOPENFILENAMEW ofnW, BOOL open)
{
ofnW->lpstrDefExt = FD31_DupToW(ofnA->lpstrDefExt, 3);
if ((ofnA->Flags & OFN_ENABLETEMPLATE) && (ofnA->lpTemplateName))
{
- if (HIWORD(ofnA->lpTemplateName))
+ if (!IS_INTRESOURCE(ofnA->lpTemplateName))
{
RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpTemplateName);
ofnW->lpTemplateName = usBuffer.Buffer;
HeapFree(GetProcessHeap(), 0, ofnW->lpstrFileTitle);
HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrInitialDir);
HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrTitle);
- if (HIWORD(ofnW->lpTemplateName))
+ if (!IS_INTRESOURCE(ofnW->lpTemplateName))
HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpTemplateName);
}
if (!lfs) return;
hwnd = lfs->hwnd;
TRACE("destroying private allocation %p\n", lfs);
- lfs->callbacks->Destroy(lfs);
+
+ /* if ofnW has been allocated, have to free everything in it */
+ if (lfs->ofnA)
+ {
+ FD31_FreeOfnW(lfs->ofnW);
+ HeapFree(GetProcessHeap(), 0, lfs->ofnW);
+ }
HeapFree(GetProcessHeap(), 0, lfs);
RemovePropA(hwnd, FD31_OFN_PROP);
}
* On entry : type = dialog procedure type (16,32A,32W)
* dlgType = dialog type (open or save)
*/
-PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType,
- PFD31_CALLBACKS callbacks, DWORD data)
+PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode)
{
PFD31_DATA lfs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FD31_DATA));
lfs->hook = FALSE;
lfs->lParam = lParam;
lfs->open = (dlgType == OPEN_DIALOG);
- lfs->callbacks = callbacks;
- if (! lfs->callbacks->Init(lParam, lfs, data))
+
+ if (IsUnicode)
+ {
+ lfs->ofnA = NULL;
+ lfs->ofnW = (LPOPENFILENAMEW) lParam;
+ if (lfs->ofnW->Flags & OFN_ENABLEHOOK)
+ if (lfs->ofnW->lpfnHook)
+ lfs->hook = TRUE;
+ }
+ else
+ {
+ lfs->ofnA = (LPOPENFILENAMEA) lParam;
+ if (lfs->ofnA->Flags & OFN_ENABLEHOOK)
+ if (lfs->ofnA->lpfnHook)
+ lfs->hook = TRUE;
+ lfs->ofnW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*lfs->ofnW));
+ FD31_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open);
+ }
+
+ if (! FD32_GetTemplate(lfs))
{
FD31_DestroyPrivate(lfs);
return NULL;
PFD31_DATA lfs = (PFD31_DATA) lParam;
if (!lfs) return FALSE;
- SetPropA(hWnd, FD31_OFN_PROP, (HANDLE)lfs);
+ SetPropA(hWnd, FD31_OFN_PROP, lfs);
lfs->hwnd = hWnd;
ofn = lfs->ofnW;