Ignore:
Timestamp:
Nov 2, 1999, 9:37:43 PM (26 years ago)
Author:
sandervl
Message:

Wine 991031 update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comdlg32/filedlg95.cpp

    r1548 r1556  
    1 /* $Id: filedlg95.cpp,v 1.1 1999-11-02 19:09:42 sandervl Exp $ */
     1/* $Id: filedlg95.cpp,v 1.2 1999-11-02 20:37:42 sandervl Exp $ */
    22/*
    3  * COMMDLG - File Open Dialogs Win95 look and feel (990815)
    4  *
    5  */
    6 // ><DJR 17.05.99 Force to use C-interfaces for now to prevent CALLBACK definition compiler error
    7 #define CINTERFACE 1
    8 
     3 * COMMDLG - File Open Dialogs Win95 look and feel
     4 *
     5 */
    96#include <ctype.h>
    107#include <stdlib.h>
    118#include <string.h>
     9#ifdef __WIN32OS2__
     10// ><DJR 17.05.99 Force to use C-interfaces for now to prevent CALLBACK definition compiler error
     11#define CINTERFACE 1
    1212#include <os2win.h>
     13#else
     14#include "winbase.h"
     15#include "tweak.h"
     16#endif
    1317#include "ldt.h"
    1418#include "heap.h"
    1519#include "commdlg.h"
    1620#include "dlgs.h"
     21#include "cdlg.h"
    1722#include "debugtools.h"
    1823#include "cderr.h"
    19 //#include "tweak.h"
    2024#include "winnls.h"
    2125#include "shellapi.h"
    22 #include "commctrl.h"
    2326#include "tchar.h"
    2427#include "filedlgbrowser.h"
    25 #include "wine/undocshell.h"
    2628#include "wine/obj_contextmenu.h"
    2729
     30#ifdef __WIN32OS2__
     31#include <heapstring.h>
     32
     33#define MapHModuleSL(a) a
     34#define MapHModuleLS(a) a
     35#endif
     36
    2837DEFAULT_DEBUG_CHANNEL(commdlg)
    2938
    30 #include "cdlg.h"
    31 
    32 #include <heapstring.h>
    3339
    3440/***********************************************************************
     
    105111#define CBShowDropDown(hwnd,show) \
    106112  SendMessageA(hwnd,CB_SHOWDROPDOWN,(WPARAM)show,0);
     113#define CBSetItemHeight(hwnd,index,height) \
     114  SendMessageA(hwnd,CB_SETITEMHEIGHT,(WPARAM)index,(LPARAM)height);
    107115
    108116
     
    129137static BOOL    FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb);
    130138static BOOL    FILEDLG95_SHELL_NewFolder(HWND hwnd);
    131        BOOL    FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd,
    132                                                         LPITEMIDLIST pidlCurrentFolder,
    133                                                         LPSTR lpstrMask);
    134139static void    FILEDLG95_SHELL_Clean(HWND hwnd);
     140
    135141/* Functions used by the filetype combo box */
    136142static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd);
     
    159165/* Shell memory allocation */
    160166char *MemAlloc(UINT size);
    161 void  MemFree(void *mem);
     167void MemFree(void *mem);
    162168
    163169BOOL WINAPI GetOpenFileName95(FileOpenDlgInfos *fodInfos);
     
    179185
    180186    LRESULT lRes;
    181     LPCVOID dlgtemplate;
     187    LPCVOID templateDlg;
    182188    HRSRC hRes;
    183189    HANDLE hDlgTmpl = 0;
     
    185191    /* Create the dialog from a template */
    186192
    187   if (fodInfos->ofnInfos.Flags & OFN_ENABLETEMPLATEHANDLE)
    188   {
    189 #ifdef __WIN32OS2__
    190     if (!(dlgtemplate = LockResource( fodInfos->ofnInfos.hInstance)))
    191 #else
    192     if (!(dlgtemplate = LockResource( MapHModuleSL(fodInfos->ofnInfos.hInstance ))))
    193 #endif
    194     {
    195         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    196         return FALSE;
    197     }
    198   }
    199   else if (fodInfos->ofnInfos.Flags & OFN_ENABLETEMPLATE)
    200   {
    201 #ifdef __WIN32OS2__
    202     if (!(hRes = FindResourceA(fodInfos->ofnInfos.hInstance,
    203 #else
    204     if (!(hRes = FindResourceA(MapHModuleSL(fodInfos->ofnInfos.hInstance),
    205 #endif
    206             (fodInfos->ofnInfos.lpTemplateName), RT_DIALOGA)))
    207     {
    208         COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    209         return FALSE;
    210     }
    211 #ifdef __WIN32OS2__
    212     if (!(hDlgTmpl = LoadResource( fodInfos->ofnInfos.hInstance,
    213 #else
    214     if (!(hDlgTmpl = LoadResource( MapHModuleSL(fodInfos->ofnInfos.hInstance),
    215 #endif
    216              hRes )) ||
    217         !(dlgtemplate = LockResource( hDlgTmpl )))
    218     {
    219         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    220         return FALSE;
    221     }
    222   }
    223   else
    224   {
    225193    if(!(hRes = FindResourceA(COMDLG32_hInstance,MAKEINTRESOURCEA(IDD_OPENDIALOG),RT_DIALOGA)))
    226194    {
     
    229197    }
    230198    if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hRes )) ||
    231         !(dlgtemplate = LockResource( hDlgTmpl )))
     199        !(templateDlg = LockResource( hDlgTmpl )))
    232200    {
    233201        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    234202        return FALSE;
    235203    }
    236   }
    237 
    238204    lRes = DialogBoxIndirectParamA(COMDLG32_hInstance,
    239                                   (LPDLGTEMPLATEA) dlgtemplate,
     205                                  (LPDLGTEMPLATEA) templateDlg,
    240206                                  fodInfos->ofnInfos.hwndOwner,
    241207                                  (DLGPROC) FileOpenDlgProc95,
     
    263229
    264230    LRESULT lRes;
    265     LPCVOID dlgtemplate;
     231    LPCVOID templateDlg;
    266232    HRSRC hRes;
    267233    HANDLE hDlgTmpl = 0;
     
    269235    /* Create the dialog from a template */
    270236
    271   if (fodInfos->ofnInfos.Flags & OFN_ENABLETEMPLATEHANDLE)
    272   {
    273 #ifdef __WIN32OS2__
    274     if (!(dlgtemplate = LockResource( fodInfos->ofnInfos.hInstance)))
    275 #else
    276     if (!(dlgtemplate = LockResource( MapHModuleSL(fodInfos->ofnInfos.hInstance ))))
    277 #endif
    278     {
    279         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    280         return FALSE;
    281     }
    282   }
    283   else if (fodInfos->ofnInfos.Flags & OFN_ENABLETEMPLATE)
    284   {
    285 #ifdef __WIN32OS2__
    286     if (!(hRes = FindResourceA(fodInfos->ofnInfos.hInstance,
    287 #else
    288     if (!(hRes = FindResourceA(MapHModuleSL(fodInfos->ofnInfos.hInstance),
    289 #endif
    290             (fodInfos->ofnInfos.lpTemplateName), RT_DIALOGA)))
    291     {
    292         COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    293         return FALSE;
    294     }
    295 #ifdef __WIN32OS2__
    296     if (!(hDlgTmpl = LoadResource( fodInfos->ofnInfos.hInstance,
    297 #else
    298     if (!(hDlgTmpl = LoadResource( MapHModuleSL(fodInfos->ofnInfos.hInstance),
    299 #endif
    300              hRes )) ||
    301         !(dlgtemplate = LockResource( hDlgTmpl )))
    302     {
    303         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    304         return FALSE;
    305     }
    306   }
    307   else
    308   {
    309237    if(!(hRes = FindResourceA(COMDLG32_hInstance,MAKEINTRESOURCEA(IDD_SAVEDIALOG),RT_DIALOGA)))
    310238    {
     
    313241    }
    314242    if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hRes )) ||
    315         !(dlgtemplate = LockResource( hDlgTmpl )))
     243        !(templateDlg = LockResource( hDlgTmpl )))
    316244    {
    317245        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    318246        return FALSE;
    319247    }
    320   }
    321248    lRes = DialogBoxIndirectParamA(COMDLG32_hInstance,
    322                                   (LPDLGTEMPLATEA) dlgtemplate,
     249                                  (LPDLGTEMPLATEA) templateDlg,
    323250                                  fodInfos->ofnInfos.hwndOwner,
    324251                                  (DLGPROC) FileOpenDlgProc95,
     
    350277  memset(&fodInfos->ofnInfos,'\0',sizeof(*ofn)); fodInfos->ofnInfos.lStructSize = sizeof(*ofn);
    351278  fodInfos->ofnInfos.hwndOwner = ofn->hwndOwner;
    352 #ifdef __WIN32OS2__
    353   fodInfos->ofnInfos.hInstance = ofn->hInstance;
    354 #else
    355279  fodInfos->ofnInfos.hInstance = MapHModuleLS(ofn->hInstance);
    356 #endif
    357280  if (ofn->lpstrFilter)
    358281  {
     
    377300      s = s+strlen(s)+1;
    378301    s++;
    379     x = (LPSTR)MemAlloc(s-ofn->lpstrCustomFilter);
     302    x = MemAlloc(s-ofn->lpstrCustomFilter);
    380303    memcpy(x,ofn->lpstrCustomFilter,s-ofn->lpstrCustomFilter);
    381304    fodInfos->ofnInfos.lpstrCustomFilter = (LPSTR)x;
     
    395318  if (ofn->lpstrInitialDir)
    396319  {
    397       fodInfos->ofnInfos.lpstrInitialDir = (LPSTR)MemAlloc(strlen(ofn->lpstrInitialDir));
     320      fodInfos->ofnInfos.lpstrInitialDir = (LPSTR)MemAlloc(strlen(ofn->lpstrInitialDir)+1);
    398321      strcpy((LPSTR)fodInfos->ofnInfos.lpstrInitialDir,ofn->lpstrInitialDir);
    399322  }
     
    401324  if (ofn->lpstrTitle)
    402325  {
    403       fodInfos->ofnInfos.lpstrTitle = (LPSTR)MemAlloc(strlen(ofn->lpstrTitle));
     326      fodInfos->ofnInfos.lpstrTitle = (LPSTR)MemAlloc(strlen(ofn->lpstrTitle)+1);
    404327      strcpy((LPSTR)fodInfos->ofnInfos.lpstrTitle,ofn->lpstrTitle);
    405328  }
     
    410333  if (ofn->lpstrDefExt)
    411334  {
    412       fodInfos->ofnInfos.lpstrDefExt = (char *)MemAlloc(strlen(ofn->lpstrDefExt));
     335      fodInfos->ofnInfos.lpstrDefExt = MemAlloc(strlen(ofn->lpstrDefExt)+1);
    413336      strcpy((LPSTR)fodInfos->ofnInfos.lpstrDefExt,ofn->lpstrDefExt);
    414337  }
     
    418341  if (ofn->lpTemplateName)
    419342  {
    420       /* template don't work - using normal dialog */ 
    421       /* fodInfos->ofnInfos.lpTemplateName = MemAlloc(strlen(ofn->lpTemplateName));
    422         strcpy((LPSTR)fodInfos->ofnInfos.lpTemplateName,ofn->lpTemplateName);*/
    423       fodInfos->ofnInfos.Flags &= ~OFN_ENABLETEMPLATEHANDLE;
    424       fodInfos->ofnInfos.Flags &= ~OFN_ENABLETEMPLATE;
    425       FIXME("File dialog 95 template not implemented\n");
    426      
     343      fodInfos->ofnInfos.lpTemplateName = ofn->lpTemplateName;
    427344  }
    428345
     
    430347  if(!ofn->lpstrInitialDir)
    431348  {
    432     fodInfos->ofnInfos.lpstrInitialDir = (char *)MemAlloc(MAX_PATH);
     349    fodInfos->ofnInfos.lpstrInitialDir = MemAlloc(MAX_PATH);
    433350    GetCurrentDirectoryA(MAX_PATH,(LPSTR)fodInfos->ofnInfos.lpstrInitialDir);
    434351  }
    435352
     353  /* Initialise the dialog property */
     354  fodInfos->DlgInfos.dwDlgProp = 0;
     355 
    436356  switch(iDlgType)
    437357  {
     
    440360      break;
    441361  case SAVE_DIALOG :
     362      fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
    442363      ret = GetSaveFileName95(fodInfos);
    443364      break;
     
    497418  fodInfos->ofnInfos.lStructSize = sizeof(*ofn);
    498419  fodInfos->ofnInfos.hwndOwner = ofn->hwndOwner;
    499 #ifdef __WIN32OS2__
    500   fodInfos->ofnInfos.hInstance = ofn->hInstance;
    501 #else
    502420  fodInfos->ofnInfos.hInstance = MapHModuleLS(ofn->hInstance);
    503 #endif
    504421  if (ofn->lpstrFilter)
    505422  {
     
    555472    fodInfos->ofnInfos.lpstrFileTitle = (LPSTR)MemAlloc(ofn->nMaxFileTitle);
    556473  if (ofn->lpstrInitialDir)
    557     fodInfos->ofnInfos.lpstrInitialDir = (LPSTR)MemAlloc(lstrlenW(ofn->lpstrInitialDir));
     474  {
     475    fodInfos->ofnInfos.lpstrInitialDir = (LPSTR)MemAlloc(lstrlenW(ofn->lpstrInitialDir)+1);
     476    lstrcpyWtoA((LPSTR)fodInfos->ofnInfos.lpstrInitialDir,(LPWSTR)ofn->lpstrInitialDir);
     477  }
    558478  if (ofn->lpstrTitle)
    559     fodInfos->ofnInfos.lpstrTitle = (LPSTR)MemAlloc(lstrlenW(ofn->lpstrTitle));
     479  {
     480    fodInfos->ofnInfos.lpstrTitle = (LPSTR)MemAlloc(lstrlenW(ofn->lpstrTitle)+1);
     481    lstrcpyWtoA((LPSTR)fodInfos->ofnInfos.lpstrTitle,(LPWSTR)ofn->lpstrTitle);
     482  }
    560483  fodInfos->ofnInfos.Flags = ofn->Flags|OFN_WINE|OFN_UNICODE;
    561484  fodInfos->ofnInfos.nFileOffset = ofn->nFileOffset;
    562485  fodInfos->ofnInfos.nFileExtension = ofn->nFileExtension;
    563486  if (ofn->lpstrDefExt)
    564     fodInfos->ofnInfos.lpstrDefExt = (LPSTR)MemAlloc(lstrlenW(ofn->lpstrDefExt));
     487  {
     488    fodInfos->ofnInfos.lpstrDefExt = (LPSTR)MemAlloc(lstrlenW(ofn->lpstrDefExt)+1);
     489    lstrcpyWtoA((LPSTR)fodInfos->ofnInfos.lpstrDefExt,(LPWSTR)ofn->lpstrDefExt);
     490  }
    565491  fodInfos->ofnInfos.lCustData = ofn->lCustData;
    566492  fodInfos->ofnInfos.lpfnHook = (LPOFNHOOKPROC)ofn->lpfnHook;
    567493  if (ofn->lpTemplateName)
    568     fodInfos->ofnInfos.lpTemplateName = (LPSTR)MemAlloc(lstrlenW(ofn->lpTemplateName));
     494  {
     495    fodInfos->ofnInfos.lpTemplateName = (LPSTR)MemAlloc(lstrlenW(ofn->lpTemplateName)+1);
     496    lstrcpyWtoA((LPSTR)fodInfos->ofnInfos.lpTemplateName,(LPWSTR)ofn->lpTemplateName);
     497  }
     498  /* Initialise the dialog property */
     499  fodInfos->DlgInfos.dwDlgProp = 0;
     500 
    569501  switch(iDlgType)
    570502  {
     
    573505      break;
    574506  case SAVE_DIALOG :
     507      fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
    575508      ret = GetSaveFileName95(fodInfos);
    576509      break;
     
    579512  }
    580513     
    581 
    582514  /* Cleaning */
    583515  ofn->nFileOffset = fodInfos->ofnInfos.nFileOffset;
     
    612544}
    613545
     546void ArrangeCtrlPositions( HWND hwndChildDlg, HWND hwndParentDlg)
     547{
     548
     549        HWND hwndChild,hwndStc32;
     550        RECT rectParent,rectChild,rectCtrl,rectStc32;
     551        POINT ptMoveCtl;
     552        HDWP handle;
     553        POINT ptParentClient;
     554
     555        ptMoveCtl.x = ptMoveCtl.y = 0;
     556        hwndStc32=GetDlgItem(hwndChildDlg,stc32);
     557        GetClientRect(hwndParentDlg,&rectParent);
     558        GetClientRect(hwndChildDlg,&rectChild);
     559        if(hwndStc32)
     560        {
     561                RECT rectTemp;
     562                GetWindowRect(hwndStc32,&rectStc32);
     563                MapWindowPoints(0, hwndChildDlg,(LPPOINT)&rectStc32,2);
     564                CopyRect(&rectTemp,&rectStc32);
     565
     566                SetRect(&rectStc32,rectStc32.left,rectStc32.top,rectStc32.left + (rectParent.right-rectParent.left),rectStc32.top+(rectParent.bottom-rectParent.top));
     567                SetWindowPos(hwndStc32,0,rectStc32.left,rectStc32.top,rectStc32.right-rectStc32.left,rectStc32.bottom-rectStc32.top,SWP_NOMOVE|SWP_NOZORDER | SWP_NOACTIVATE);
     568                if(rectStc32.right < rectTemp.right)
     569                {
     570                        ptParentClient.x = max((rectParent.right-rectParent.left),(rectChild.right-rectChild.left));
     571                        ptMoveCtl.x = 0;
     572                }
     573                else
     574                {
     575                        ptMoveCtl.x = (rectStc32.right - rectTemp.right);
     576                        ptParentClient.x = max((rectParent.right-rectParent.left),((rectChild.right-rectChild.left)+rectStc32.right-rectTemp.right));
     577                }
     578                if(rectStc32.bottom < rectTemp.bottom)
     579                {
     580                        ptParentClient.y = max((rectParent.bottom-rectParent.top),(rectChild.bottom-rectChild.top));
     581                        ptMoveCtl.y = 0;
     582                }
     583                else
     584                {
     585                        ptMoveCtl.y = (rectStc32.bottom - rectTemp.bottom);
     586                        ptParentClient.y = max((rectParent.bottom-rectParent.top),((rectChild.bottom-rectChild.top)+rectStc32.bottom-rectTemp.bottom));
     587                }
     588        }
     589        else
     590        {
     591                if( (GetWindow(hwndChildDlg,GW_CHILD)) == (HWND) NULL)
     592                   return;
     593                ptParentClient.x = rectParent.right-rectParent.left;
     594                ptParentClient.y = (rectParent.bottom-rectParent.top) + (rectChild.bottom-rectChild.top);
     595                ptMoveCtl.y = rectParent.bottom-rectParent.top;
     596                ptMoveCtl.x=0;
     597        }
     598        SetRect(&rectParent,rectParent.left,rectParent.top,rectParent.left+ptParentClient.x,rectParent.top+ptParentClient.y);
     599        AdjustWindowRectEx( &rectParent,GetWindowLongA(hwndParentDlg,GWL_STYLE),FALSE,GetWindowLongA(hwndParentDlg,GWL_EXSTYLE));
     600
     601        SetWindowPos(hwndChildDlg, 0, 0,0, ptParentClient.x,ptParentClient.y,
     602                 SWP_NOZORDER );
     603        SetWindowPos(hwndParentDlg, 0, rectParent.left,rectParent.top, (rectParent.right- rectParent.left),
     604                (rectParent.bottom-rectParent.top),SWP_NOMOVE | SWP_NOZORDER);
     605       
     606        hwndChild = GetWindow(hwndChildDlg,GW_CHILD);
     607        handle = BeginDeferWindowPos( 1 );
     608        if(hwndStc32)
     609        {
     610                GetWindowRect(hwndStc32,&rectStc32);
     611                MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
     612        }
     613        else
     614                SetRect(&rectStc32,0,0,0,0);
     615        if (hwndChild && handle)
     616        {
     617                do
     618                {
     619                        if(hwndChild != hwndStc32)
     620                        {
     621                        if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
     622                                continue;
     623                        GetWindowRect(hwndChild,&rectCtrl);
     624                        MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
     625                        if(rectCtrl.top > rectStc32.top)
     626                        {
     627                                 
     628                                if(ptMoveCtl.x > 0)
     629                                        rectCtrl.left += ptMoveCtl.x;
     630                                rectCtrl.top  += ptMoveCtl.y;
     631                                handle = DeferWindowPos(handle, hwndChild, 0, rectCtrl.left, rectCtrl.top,
     632                                rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
     633                                SWP_NOSIZE | SWP_NOZORDER );
     634                                }
     635                        }
     636                }
     637                while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL && handle);
     638        }               
     639        if(handle)
     640                EndDeferWindowPos( handle );
     641        handle = BeginDeferWindowPos( 1 );
     642        hwndChild = GetWindow(hwndParentDlg,GW_CHILD);
     643        if(hwndStc32)
     644        {
     645                GetWindowRect(hwndStc32,&rectStc32);
     646                MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
     647                ptMoveCtl.x = rectStc32.left - 0;
     648                ptMoveCtl.y = rectStc32.top - 0;
     649                if (hwndChild && handle)
     650                {
     651                        do
     652                        {
     653                                if(hwndChild != hwndChildDlg)
     654                                {
     655
     656                                        if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
     657                                                continue;
     658                                        GetWindowRect(hwndChild,&rectCtrl);
     659                                        MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
     660
     661                                        rectCtrl.left += ptMoveCtl.x;
     662                                        rectCtrl.top += ptMoveCtl.y;
     663
     664                                        handle = DeferWindowPos(        handle, hwndChild, 0, rectCtrl.left, rectCtrl.top,
     665                                        rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
     666                                        SWP_NOSIZE |SWP_NOZORDER );
     667                                }
     668                        }
     669                        while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL);
     670                }               
     671                if(handle)
     672                EndDeferWindowPos( handle );
     673        }
     674
     675}
     676
     677
     678HRESULT WINAPI FileOpenDlgProcUserTemplate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     679{
     680  static WNDPROC procUserHook=NULL;
     681  switch(uMsg)
     682  {
     683        case WM_INITDIALOG:
     684        {         
     685                FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *)lParam;
     686                procUserHook=NULL;
     687                lParam = (LPARAM) &fodInfos->ofnInfos;
     688                ArrangeCtrlPositions(hwnd,GetParent(hwnd));
     689                if(fodInfos->ofnInfos.Flags & OFN_ENABLEHOOK)
     690                        procUserHook = (WNDPROC) fodInfos->ofnInfos.lpfnHook;
     691                if(procUserHook)
     692                         return CallWindowProcA(procUserHook,hwnd,uMsg,wParam,lParam);
     693                return 0;       
     694        } }
     695 if(procUserHook)
     696      return CallWindowProcA(procUserHook,hwnd,uMsg,wParam,lParam);
     697  return DefWindowProcA(hwnd,uMsg,wParam,lParam);
     698}
     699
     700HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos,HWND hwnd)
     701{
     702    LPCVOID templateDlg;
     703    HRSRC hRes;
     704    HANDLE hDlgTmpl = 0;
     705    HWND hChildDlg = 0;
     706   if (fodInfos->ofnInfos.Flags & OFN_ENABLETEMPLATE || fodInfos->ofnInfos.Flags & OFN_ENABLETEMPLATEHANDLE)
     707   {
     708        if (fodInfos->ofnInfos.Flags  & OFN_ENABLETEMPLATEHANDLE)
     709        {
     710           if( !(templateDlg = LockResource( fodInfos->ofnInfos.hInstance)))
     711                {
     712                COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     713                return (HWND)NULL;
     714                }
     715               
     716        }
     717        else
     718        {
     719         if (!(hRes = FindResourceA(MapHModuleSL(fodInfos->ofnInfos.hInstance),
     720            (fodInfos->ofnInfos.lpTemplateName), RT_DIALOGA)))
     721        {
     722                COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     723                 return (HWND)NULL;
     724        }
     725        if (!(hDlgTmpl = LoadResource( MapHModuleSL(fodInfos->ofnInfos.hInstance),
     726             hRes )) ||
     727                 !(templateDlg = LockResource( hDlgTmpl )))
     728        {
     729                COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     730                return (HWND)NULL;
     731        }
     732        }
     733
     734        hChildDlg= CreateDialogIndirectParamA(fodInfos->ofnInfos.hInstance,(LPCDLGTEMPLATEA)templateDlg,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
     735        if(hChildDlg)
     736        {
     737                ShowWindow(hChildDlg,SW_SHOW);
     738                return hChildDlg;
     739        }
     740 }
     741 else if(fodInfos->ofnInfos.Flags & OFN_ENABLEHOOK && fodInfos->ofnInfos.lpfnHook)
     742 {
     743        RECT rectHwnd;
     744        DLGTEMPLATE tmplate;
     745        GetClientRect(hwnd,&rectHwnd);
     746        tmplate.style = WS_CHILD | WS_CLIPSIBLINGS;
     747        tmplate.dwExtendedStyle = 0;
     748        tmplate.cdit = 0;
     749        tmplate.x = 0;
     750        tmplate.y = 0;
     751        tmplate.cx = rectHwnd.right-rectHwnd.left;
     752        tmplate.cy = rectHwnd.bottom-rectHwnd.top;
     753       
     754        return CreateDialogIndirectParamA(fodInfos->ofnInfos.hInstance,&tmplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
     755 }
     756return (HWND)NULL;
     757}
    614758
    615759/***********************************************************************
     
    624768  {
    625769    case WM_INITDIALOG :
     770        CreateTemplateDialog((FileOpenDlgInfos *)lParam,hwnd);
    626771      return FILEDLG95_OnWMInitDialog(hwnd, wParam, lParam);
    627772    case WM_COMMAND:
     
    637782      }
    638783      return FALSE;
    639 #ifndef __WIN32OS2__         
     784         
    640785    case WM_GETISHELLBROWSER:
    641786      return FILEDLG95_OnWMGetIShellBrowser(hwnd);
    642 #endif
    643787
    644788  case WM_DESTROY:
    645789      RemovePropA(hwnd, FileOpenDlgInfosStr);
     790
    646791    default :
    647792      return FALSE;
     
    698843
    699844  /* Free pidlItem memory */
    700   SHFree(pidlItemId);
     845  COMDLG32_SHFree(pidlItemId);
    701846
    702847  return TRUE;
     
    722867  WORD wNotifyCode = HIWORD(wParam); /* notification code */
    723868  WORD wID = LOWORD(wParam);         /* item, control, or accelerator identifier */
     869  FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
    724870
    725871  switch(wID)
     
    763909
    764910  }
    765 
     911  /* Do not use the listview selection anymore */
     912  fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW;
    766913  return 0;
    767914}
     
    851998  }
    852999
     1000  /* List View is selected by default */
     1001  SendDlgItemMessageA(hwnd, IDC_LIST, BM_SETCHECK,(WPARAM) BST_CHECKED,0);
     1002
    8531003  return 0;
    8541004}
     
    8631013BOOL FILEDLG95_OnOpen(HWND hwnd)
    8641014{
    865   char lpstrFileName[MAX_PATH];
     1015  char lpstrSpecifiedByUser[MAX_PATH] = "";
    8661016  FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
     1017  LPITEMIDLIST pidlSelection;
    8671018
    8681019  TRACE("\n");
    8691020
    870   if(GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrFileName,MAX_PATH))
    871   {
    872     char *tmp;
    873     char lpstrFile[MAX_PATH];
    874 
    875     /* Get the selected file name and path */
    876     SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,
    877                          lpstrFile);
    878     if(strcmp(&lpstrFile[strlen(lpstrFile)-1],"\\"))
    879         strcat(lpstrFile,"\\");
    880     strcat(lpstrFile,lpstrFileName);
     1021  /* Check if there is a selected item in the listview */
     1022  if(fodInfos->DlgInfos.dwDlgProp & FODPROP_USEVIEW)
     1023  {
     1024      pidlSelection = GetSelectedPidl(fodInfos->Shell.FOIShellView);
     1025      GetName(fodInfos->Shell.FOIShellFolder,pidlSelection,SHGDN_NORMAL,lpstrSpecifiedByUser);
     1026      COMDLG32_SHFree((LPVOID)pidlSelection);
     1027  }
     1028  else
     1029      /* Get the text from the filename edit */
     1030      GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrSpecifiedByUser,MAX_PATH);
     1031
     1032  if(strlen(lpstrSpecifiedByUser))
     1033  {
     1034      LPSHELLFOLDER psfDesktop;
     1035      LPITEMIDLIST browsePidl;
     1036      LPSTR lpstrFileSpec;
     1037      LPSTR lpstrTemp;
     1038      char lpstrPathSpec[MAX_PATH] = "";
     1039      char lpstrCurrentDir[MAX_PATH] = "";
     1040      char lpstrPathAndFile[MAX_PATH] = "";
     1041
     1042      /* Separate the file spec from the path spec
     1043         e.g.:
     1044              lpstrSpecifiedByUser  lpstrPathSpec  lpstrFileSpec
     1045              C:\TEXT1\TEXT2        C:\TEXT1          TEXT2
     1046      */     
     1047      lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA(lpstrSpecifiedByUser);
     1048      strcpy(lpstrPathSpec,lpstrSpecifiedByUser);
     1049      COMDLG32_PathRemoveFileSpecA(lpstrPathSpec);
     1050     
     1051      /* Get the current directory name */
     1052      COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,
     1053                                    lpstrCurrentDir);
     1054
     1055      /* Create an absolute path name */
     1056      if(lpstrSpecifiedByUser[1] != ':')
     1057      {
     1058          switch(lpstrSpecifiedByUser[0])
     1059          {
     1060          /* Add drive spec  \TEXT => C:\TEXT */
     1061          case '\\':
     1062              {
     1063                  INT iCopy = 2;
     1064                  char lpstrTmp[MAX_PATH] = "";
     1065                  if(!strlen(lpstrPathSpec))
     1066                      iCopy = 3;
     1067                  strncpy(lpstrTmp,lpstrCurrentDir,iCopy);
     1068                  strcat(lpstrTmp,lpstrPathSpec);
     1069                  strcpy(lpstrPathSpec,lpstrTmp);
     1070              }
     1071              break;           
     1072          /* Go to parent ..\TEXT */
     1073          case '.':
     1074              {
     1075                  INT iSize;
     1076                  char lpstrTmp2[MAX_PATH] = "";
     1077                  LPSTR lpstrTmp = strrchr(lpstrCurrentDir,'\\');
     1078                  iSize = lpstrTmp - lpstrCurrentDir;
     1079                  strncpy(lpstrTmp2,lpstrCurrentDir,iSize + 1);
     1080                  if(strlen(lpstrSpecifiedByUser) <= 3)
     1081                      strcpy(lpstrFileSpec,"");
     1082                  if(strcmp(lpstrPathSpec,".."))
     1083                      strcat(lpstrTmp2,&lpstrPathSpec[3]);
     1084                  strcpy(lpstrPathSpec,lpstrTmp2);
     1085              }
     1086              break;
     1087          default:
     1088  {
     1089                  char lpstrTmp[MAX_PATH] = "";
     1090                  if(strcmp(&lpstrCurrentDir[strlen(lpstrCurrentDir)-1],"\\"))
     1091                      strcat(lpstrCurrentDir,"\\");
     1092                  strcpy(lpstrTmp,lpstrCurrentDir);
     1093                  strcat(lpstrTmp,lpstrPathSpec);
     1094                  strcpy(lpstrPathSpec,lpstrTmp);
     1095              }
     1096                 
     1097          } /* end switch */
     1098      }
     1099
     1100      if(strlen(lpstrPathSpec))
     1101      {
     1102          /* Browse to the right directory */
     1103          COMDLG32_SHGetDesktopFolder(&psfDesktop);
     1104          if((browsePidl = GetPidlFromName(psfDesktop,lpstrPathSpec)))
     1105          {
     1106              /* Browse to directory */
     1107              IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
     1108                                         browsePidl,
     1109                                         SBSP_ABSOLUTE);
     1110              COMDLG32_SHFree(browsePidl);
     1111          }
     1112          else
     1113          {
     1114              /* Path does not exist */
     1115              if(fodInfos->ofnInfos.Flags & OFN_PATHMUSTEXIST)
     1116              {
     1117                  MessageBoxA(hwnd,
     1118                              "Path does not exist",
     1119                              fodInfos->ofnInfos.lpstrTitle,
     1120                              MB_OK | MB_ICONEXCLAMATION);
     1121                  return FALSE;
     1122              }
     1123          }
     1124         
     1125          strcat(lpstrPathAndFile,lpstrPathSpec);
     1126          IShellFolder_Release(psfDesktop);
     1127      }
     1128      else
     1129      {
     1130          strcat(lpstrPathAndFile,lpstrCurrentDir);
     1131      }
     1132
     1133      /* Create the path and file string */
     1134      COMDLG32_PathAddBackslashA(lpstrPathAndFile);
     1135      strcat(lpstrPathAndFile,lpstrFileSpec);
     1136     
     1137      /* Update the edit field */
     1138      SetDlgItemTextA(hwnd,IDC_FILENAME,lpstrFileSpec);
     1139      SendDlgItemMessageA(hwnd,IDC_FILENAME,EM_SETSEL,0,-1);
     1140     
     1141      /* Don't go further if we dont have a file spec */
     1142      if(!strlen(lpstrFileSpec) || !strcmp(lpstrFileSpec,lpstrPathSpec))
     1143          return FALSE;
     1144
     1145      /* Time to check lpstrFileSpec         */
     1146      /* search => contains * or ?           */
     1147      /* browse => contains a directory name */
     1148      /* file   => contains a file name      */
    8811149
    8821150    /* Check if this is a search */
    883     if(strchr(lpstrFileName,'*') || strchr(lpstrFileName,'?'))
     1151      if(strchr(lpstrFileSpec,'*') || strchr(lpstrFileSpec,'?'))
    8841152    {
    8851153      int iPos;
     
    8891157         MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
    8901158
    891       fodInfos->ShellInfos.lpstrCurrentFilter = (LPWSTR)MemAlloc((strlen(lpstrFileName)+1)*2);
    892       lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter,(LPSTR)strlwr((LPSTR)lpstrFileName));
    893 
     1159          fodInfos->ShellInfos.lpstrCurrentFilter = (LPWSTR)MemAlloc((strlen(lpstrFileSpec)+1)*2);
     1160          lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter,
     1161                      (LPSTR)strlwr((LPSTR)lpstrFileSpec));
    8941162     
    8951163      IShellView_Refresh(fodInfos->Shell.FOIShellView);
    8961164
    897       if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB,lpstrFileName)))
     1165          if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB,
     1166                                                       lpstrFileSpec)))
    8981167        CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB,iPos);
    8991168
     
    9011170    }
    9021171
    903     /* Check file extension */
    904 
    905     if(!strrchr(lpstrFile,'.'))
     1172      /* browse if the user specified a directory */
     1173      if((browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder,
     1174                                       lpstrFileSpec)))
    9061175    {
    907         /* if the file has no extension, append the selected
    908            extension of the filetype combo box */
    909         int iExt;
    910         LPSTR lpstrExt;
    911         LPSTR lpstrTmp;
    912         iExt = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB);
    913         lpstrTmp = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iExt);
    914 
    915         if((lpstrExt = strchr(lpstrTmp,';')))
     1176          ULONG  ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
     1177          IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder,
     1178                                       1,
     1179                                       &browsePidl,
     1180                                       &ulAttr);
     1181
     1182          /* Browse to directory */
     1183          if(ulAttr)
    9161184        {
    917             int i = lpstrExt - lpstrTmp;
    918             lpstrExt = MemAlloc(i);
    919             strncpy(lpstrExt,&lpstrTmp[1],i-1);
     1185              if(FAILED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
     1186                                                   browsePidl,
     1187                                                   SBSP_RELATIVE)))
     1188        {
     1189                  if(fodInfos->ofnInfos.Flags & OFN_PATHMUSTEXIST)
     1190        {
     1191                      MessageBoxA(hwnd,
     1192                                  "Path does not exist",
     1193                                  fodInfos->ofnInfos.lpstrTitle,
     1194                                  MB_OK | MB_ICONEXCLAMATION);
     1195                      COMDLG32_SHFree(browsePidl);
     1196                      return FALSE;
    9201197        }
    921         else
    922         {
    923             lpstrExt = MemAlloc(strlen(lpstrTmp)-1);
    924             strcpy(lpstrExt,&lpstrTmp[1]);
    925         }
    926 
    927         if(!strcmp(&lpstrExt[1],"*") && fodInfos->ofnInfos.lpstrDefExt)
    928         {
    929             lpstrExt = MemAlloc(strlen(fodInfos->ofnInfos.lpstrDefExt)+1);
    930             strcat(lpstrExt,".");
    931             strcat(lpstrExt,(LPSTR) fodInfos->ofnInfos.lpstrDefExt);
    932         }
    933 
    934         strcat(lpstrFile,lpstrExt);
    9351198    }
    936     /* Check if the selected file exist */
    937 
    938     if(strlen(lpstrFile) > fodInfos->ofnInfos.nMaxFile)
     1199              COMDLG32_SHFree(browsePidl);
     1200              return FALSE;
     1201    }
     1202          COMDLG32_SHFree(browsePidl);
     1203      }
     1204      else
    9391205    {
    940         /* set error FNERR_BUFFERTOSMALL */
    941         FILEDLG95_Clean(hwnd);
    942         return EndDialog(hwnd,FALSE);
    943     }
    944     strcpy(fodInfos->ofnInfos.lpstrFile,lpstrFile);
    945 
    946     /* Set the lpstrFileTitle of the OPENFILENAME structure */
    947     if(fodInfos->ofnInfos.lpstrFileTitle)
    948       strncpy(fodInfos->ofnInfos.lpstrFileTitle,
    949               lpstrFileName,
    950               fodInfos->ofnInfos.nMaxFileTitle);
    951 
    952     /* Check if the file is to be opened as read only */
    953     if(BST_CHECKED == SendDlgItemMessageA(hwnd,IDC_OPENREADONLY,BM_GETSTATE,0,0))
    954       SetFileAttributesA(fodInfos->ofnInfos.lpstrFile,FILE_ATTRIBUTE_READONLY);
    955 
    956     /*  nFileExtension and nFileOffset of OPENFILENAME structure */
    957     tmp = strrchr(fodInfos->ofnInfos.lpstrFile,'\\');
    958     fodInfos->ofnInfos.nFileOffset = tmp - fodInfos->ofnInfos.lpstrFile + 1;
    959     tmp = strrchr(fodInfos->ofnInfos.lpstrFile,'.');
    960     fodInfos->ofnInfos.nFileExtension = tmp - fodInfos->ofnInfos.lpstrFile + 1;
    961 
    962     /* Check if selected file exists */
    963     if(!GetPidlFromName(fodInfos->Shell.FOIShellFolder, lpstrFileName))
    964     {
     1206          /* File does not exist in current directory */
     1207
     1208          /* The selected file does not exist */
    9651209      /* Tell the user the selected does not exist */
    9661210      if(fodInfos->ofnInfos.Flags & OFN_FILEMUSTEXIST)
     
    9701214        char tmp[400];
    9711215
    972         LoadStringA(COMDLG32_hInstance,IDS_FILENOTFOUND,lpstrNotFound,100);
    973         LoadStringA(COMDLG32_hInstance,IDS_VERIFYFILE,lpstrMsg,100);
     1216              LoadStringA(COMDLG32_hInstance,
     1217                          IDS_FILENOTFOUND,
     1218                          lpstrNotFound,
     1219                          100);
     1220              LoadStringA(COMDLG32_hInstance,
     1221                          IDS_VERIFYFILE,
     1222                          lpstrMsg,
     1223                          100);
    9741224
    9751225        strcpy(tmp,fodInfos->ofnInfos.lpstrFile);
     
    9791229        strcat(tmp,lpstrMsg);
    9801230
    981         MessageBoxA(hwnd,tmp,fodInfos->ofnInfos.lpstrTitle,MB_OK | MB_ICONEXCLAMATION);
     1231              MessageBoxA(hwnd,
     1232                          tmp,
     1233                          fodInfos->ofnInfos.lpstrTitle,
     1234                          MB_OK | MB_ICONEXCLAMATION);
    9821235        return FALSE;
    9831236      }
     
    9891242        LoadStringA(COMDLG32_hInstance,IDS_CREATEFILE,tmp,100);
    9901243
    991         if(IDYES == MessageBoxA(hwnd,tmp,fodInfos->ofnInfos.lpstrTitle,MB_YESNO | MB_ICONQUESTION))
     1244              if(IDYES == MessageBoxA(hwnd,tmp,fodInfos->ofnInfos.lpstrTitle,
     1245                                      MB_YESNO | MB_ICONQUESTION))
    9921246        {
    9931247            /* Create the file, clean and exit */
     
    9981252      }
    9991253    }
     1254
     1255      /* Open the selected file */
     1256
     1257      /* Check file extension */
     1258      if(!strrchr(lpstrPathAndFile,'.'))
     1259      {
     1260          /* if the file has no extension, append the selected
     1261             extension of the filetype combo box */
     1262          int iExt;
     1263          LPSTR lpstrExt;
     1264          iExt = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB);
     1265          lpstrTemp = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iExt);
     1266
     1267          if((lpstrExt = strchr(lpstrTemp,';')))
     1268          {
     1269              int i = lpstrExt - lpstrTemp;
     1270              lpstrExt = MemAlloc(i);
     1271              strncpy(lpstrExt,&lpstrTemp[1],i-1);
     1272          }
     1273          else
     1274          {
     1275              lpstrExt = MemAlloc(strlen(lpstrTemp));
     1276              strcpy(lpstrExt,&lpstrTemp[1]);
     1277          }
     1278                 
     1279          if(!strcmp(&lpstrExt[1],"*") && fodInfos->ofnInfos.lpstrDefExt)
     1280          {
     1281              lpstrExt = MemAlloc(strlen(fodInfos->ofnInfos.lpstrDefExt)+2);
     1282              strcat(lpstrExt,".");
     1283              strcat(lpstrExt,(LPSTR) fodInfos->ofnInfos.lpstrDefExt);
     1284          }
     1285          strcat(lpstrPathAndFile,lpstrExt);
     1286      }
     1287      /* Check that size size of the file does not exceed buffer size */
     1288      if(strlen(lpstrPathAndFile) > fodInfos->ofnInfos.nMaxFile)
     1289      {
     1290          /* set error FNERR_BUFFERTOSMALL */
     1291          FILEDLG95_Clean(hwnd);
     1292          return EndDialog(hwnd,FALSE);
     1293      }
     1294      strcpy(fodInfos->ofnInfos.lpstrFile,lpstrPathAndFile);
     1295
     1296      /* Set the lpstrFileTitle of the OPENFILENAME structure */
     1297      if(fodInfos->ofnInfos.lpstrFileTitle)
     1298          strncpy(fodInfos->ofnInfos.lpstrFileTitle,
     1299                  lpstrFileSpec,
     1300                  fodInfos->ofnInfos.nMaxFileTitle);
     1301
     1302      /* Check if the file is to be opened as read only */           
     1303      if(BST_CHECKED == SendDlgItemMessageA(hwnd,
     1304                                            IDC_OPENREADONLY,
     1305                                            BM_GETSTATE,0,0))
     1306          SetFileAttributesA(fodInfos->ofnInfos.lpstrFile,
     1307                             FILE_ATTRIBUTE_READONLY);
     1308
     1309      /*  nFileExtension and nFileOffset of OPENFILENAME structure */
     1310      lpstrTemp = strrchr(fodInfos->ofnInfos.lpstrFile,'\\');
     1311      fodInfos->ofnInfos.nFileOffset = lpstrTemp - fodInfos->ofnInfos.lpstrFile + 1;
     1312      lpstrTemp = strrchr(fodInfos->ofnInfos.lpstrFile,'.');
     1313      fodInfos->ofnInfos.nFileExtension = lpstrTemp - fodInfos->ofnInfos.lpstrFile + 1;
     1314
     1315   
    10001316    /* clean and exit */
    10011317    FILEDLG95_Clean(hwnd);
     
    10241340
    10251341  fodInfos->Shell.FOIShellView = NULL;
    1026   if(FAILED(SHGetDesktopFolder(&fodInfos->Shell.FOIShellFolder)))
     1342  if(FAILED(COMDLG32_SHGetDesktopFolder(&fodInfos->Shell.FOIShellFolder)))
    10271343    return E_FAIL;
    10281344
     
    11771493          break;
    11781494
    1179       lpstrExt = (LPSTR) MemAlloc(strlen(lpstrExtTmp));
     1495      lpstrExt = (LPSTR) MemAlloc(strlen(lpstrExtTmp)+1);
    11801496      if(!lpstrExt)
    11811497          break;
     
    12301546      lpstrFilter = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
    12311547                                             iItem);
    1232       if(lpstrFilter)
     1548      if((INT)lpstrFilter != CB_ERR)
    12331549      {
    12341550        fodInfos->ShellInfos.lpstrCurrentFilter = (LPWSTR)MemAlloc((strlen(lpstrFilter)+1)*2);
     
    13111627
    13121628  SetPropA(hwndCombo, LookInInfosStr, (HANDLE) liInfos);
     1629  CBSetItemHeight(hwndCombo,0,GetSystemMetrics(SM_CYSMICON));
    13131630
    13141631  /* Initialise data of Desktop folder */
    1315   SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidlTmp);
     1632  COMDLG32_SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidlTmp);
    13161633  FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
    1317   SHFree(pidlTmp);
    1318 
    1319   SHGetSpecialFolderLocation(0,CSIDL_DRIVES,&pidlDrives);
    1320 
    1321   SHGetDesktopFolder(&psfRoot);
     1634  COMDLG32_SHFree(pidlTmp);
     1635
     1636  COMDLG32_SHGetSpecialFolderLocation(0,CSIDL_DRIVES,&pidlDrives);
     1637
     1638  COMDLG32_SHGetDesktopFolder(&psfRoot);
    13221639
    13231640  if (psfRoot)
     
    13311648
    13321649        /* special handling for CSIDL_DRIVES */
    1333         if (ILIsEqual(pidlTmp, pidlDrives))
     1650        if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives))
    13341651        {
    13351652          if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives)))
     
    13401657              while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL))
    13411658              {
    1342                 pidlAbsTmp = ILCombine(pidlTmp, pidlTmp1);
     1659                pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1);
    13431660                FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND);
    1344                 SHFree(pidlAbsTmp);
    1345                 SHFree(pidlTmp1);
     1661                COMDLG32_SHFree(pidlAbsTmp);
     1662                COMDLG32_SHFree(pidlTmp1);
    13461663              }
    13471664              IEnumIDList_Release(lpeDrives);
     
    13501667          }
    13511668        }
    1352         SHFree(pidlTmp);
     1669        COMDLG32_SHFree(pidlTmp);
    13531670      }
    13541671      IEnumIDList_Release(lpeRoot);
     
    13571674
    13581675  IShellFolder_Release(psfRoot);
    1359   SHFree(pidlDrives);
     1676  COMDLG32_SHFree(pidlDrives);
    13601677
    13611678  return NOERROR;
     
    13941711  if(pDIStruct->itemID == liInfos->uSelectedItem)
    13951712  {
    1396     ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
     1713    ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
    13971714                                               0,   
    13981715                                               &sfi,   
     
    14041721  else
    14051722  {
    1406     ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
     1723    ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
    14071724                                                  0,
    14081725                                                  &sfi,
     
    14311748  {
    14321749    iIndentation = 0;
    1433     ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
     1750    ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
    14341751                                                0,
    14351752                                                &sfi,
     
    14951812      iItem = CBGetCurSel(fodInfos->DlgInfos.hwndLookInCB);
    14961813
    1497       tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,
    1498                                                iItem);
     1814      if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,
     1815                                               iItem)))
     1816        return FALSE;
    14991817
    15001818
     
    15371855  /* Calculate the indentation of the item in the lookin*/
    15381856  pidlNext = pidl;
    1539   while( (pidlNext=ILGetNext(pidlNext)) )
     1857  while( (pidlNext=COMDLG32_PIDL_ILGetNext(pidlNext)) )
    15401858  {
    15411859    tmpFolder->m_iIndent++;
    15421860  }
    15431861
    1544   tmpFolder->pidlItem = ILClone(pidl);
     1862  tmpFolder->pidlItem = COMDLG32_PIDL_ILClone(pidl);
    15451863
    15461864  if(tmpFolder->m_iIndent > liInfos->iMaxIndentation)
    15471865    liInfos->iMaxIndentation = tmpFolder->m_iIndent;
    15481866 
    1549   SHGetFileInfoA((LPSTR)pidl,
     1867  COMDLG32_SHGetFileInfoA((LPSTR)pidl,
    15501868                  0,
    15511869                  &sfi,
     
    15981916
    15991917  /* Free pidlParent memory */
    1600   SHFree((LPVOID)pidlParent);
     1918  COMDLG32_SHFree((LPVOID)pidlParent);
    16011919
    16021920  return FILEDLG95_LOOKIN_AddItem(hwnd,pidl,iParentPos + 1);
     
    16932011    LPSFOLDER tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,i);
    16942012
    1695     if(iSearchMethod == SEARCH_PIDL && ILIsEqual((LPITEMIDLIST)searchArg,tmpFolder->pidlItem))
     2013    if(iSearchMethod == SEARCH_PIDL && COMDLG32_PIDL_ILIsEqual((LPITEMIDLIST)searchArg,tmpFolder->pidlItem))
    16962014      return i;
    16972015    if(iSearchMethod == SEARCH_EXP && tmpFolder->m_iIndent == (int)searchArg)
     
    17502068  {
    17512069    HRESULT hRes;
    1752     SHGetDesktopFolder(&lpsf);
     2070    COMDLG32_SHGetDesktopFolder(&lpsf);
    17532071    hRes = GetName(lpsf,pidl,dwFlags,lpstrFileName);
    17542072    IShellFolder_Release(lpsf);
     
    17622080                                                     &str)))
    17632081  {
    1764     return StrRetToStrNA(lpstrFileName, MAX_PATH, &str, pidl);
     2082      return StrRetToBufA(&str, pidl,lpstrFileName, MAX_PATH);
    17652083  }
    17662084  return E_FAIL;
     
    17792097  TRACE("%p\n", pidlAbs);
    17802098
    1781   if(SUCCEEDED(SHGetDesktopFolder(&psfParent)))
     2099  if(SUCCEEDED(COMDLG32_SHGetDesktopFolder(&psfParent)))
    17822100  {
    17832101    psf = psfParent;
    17842102    if(pidlAbs && pidlAbs->mkid.cb)
    17852103    {
    1786       if(FAILED(IShellFolder_BindToObject(psfParent, pidlAbs, NULL, &IID_IShellFolder, (LPVOID*)&psf)))
     2104      if(SUCCEEDED(IShellFolder_BindToObject(psfParent, pidlAbs, NULL, &IID_IShellFolder, (LPVOID*)&psf)))
    17872105      {
    1788         psf = NULL;
     2106        IShellFolder_Release(psfParent);
     2107        return psf;
    17892108      }
    17902109    }
    1791     IShellFolder_Release(psfParent);
    1792   }
    1793 
    1794   return psf;
    1795 
     2110    /* return the desktop */
     2111    return psfParent;
     2112  }
     2113  return NULL;
    17962114}
    17972115
     
    18072125  TRACE("%p\n", pidl);
    18082126
    1809   pidlParent = ILClone(pidl);
    1810   ILRemoveLastID(pidlParent);
    1811 
     2127  pidlParent = COMDLG32_PIDL_ILClone(pidl);
     2128  COMDLG32_PIDL_ILRemoveLastID(pidlParent);
     2129     
    18122130  return pidlParent;
    1813 
    18142131}
    18152132
     
    18252142  ULONG ulEaten;
    18262143  wchar_t lpwstrDirName[MAX_PATH];
     2144
    18272145
    18282146  TRACE("sf=%p file=%s\n", psf, lpcstrFileName);
     
    18382156                      MAX_PATH); 
    18392157
    1840    
    1841 
    1842   if(SUCCEEDED(IShellFolder_ParseDisplayName(psf,
    1843                                              0,
     2158  IShellFolder_ParseDisplayName(psf,                                0,
    18442159                                             NULL,
    18452160                                             (LPWSTR)lpwstrDirName,
    18462161                                             &ulEaten,
    18472162                                             &pidl,
    1848                                              NULL)))
    1849   {
     2163                                NULL);   
     2164
    18502165    return pidl;
    1851   }
    1852   return NULL;
    18532166}
    18542167
Note: See TracChangeset for help on using the changeset viewer.