Ignore:
Timestamp:
Nov 28, 1999, 1:32:28 PM (26 years ago)
Author:
sandervl
Message:

Merge with latest wine code

File:
1 edited

Legend:

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

    r1721 r1864  
    1 /* $Id: filedlg95.cpp,v 1.4 1999-11-13 15:41:44 sandervl Exp $ */
     1/* $Id: filedlg95.cpp,v 1.5 1999-11-28 12:32:27 sandervl Exp $ */
    22/*
    33 * COMMDLG - File Open Dialogs Win95 look and feel
    44 *
    55 */
     6#ifdef __WIN32OS2__
     7#include <os2win.h>
     8#include <heapstring.h>
     9// ><DJR 17.05.99 Force to use C-interfaces for now to prevent CALLBACK definition compiler error
     10#define CINTERFACE 1
     11
     12#define MapHModuleSL(a) a
     13#define MapHModuleLS(a) a
     14
     15#endif
    616#include <ctype.h>
    717#include <stdlib.h>
    818#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
    12 #include <os2win.h>
    13 #else
    1419#include "winbase.h"
    15 #include "tweak.h"
    16 #endif
    1720#include "ldt.h"
    1821#include "heap.h"
     
    2225#include "debugtools.h"
    2326#include "cderr.h"
     27#include "tweak.h"
    2428#include "winnls.h"
    2529#include "shellapi.h"
     
    2832#include "wine/obj_contextmenu.h"
    2933
    30 #ifdef __WIN32OS2__
    31 #include <heapstring.h>
    32 
    33 #define MapHModuleSL(a) a
    34 #define MapHModuleLS(a) a
    35 #endif
    36 
    3734DEFAULT_DEBUG_CHANNEL(commdlg)
    38 
    3935
    4036/***********************************************************************
     
    4642  HIMAGELIST hImgList;
    4743  int m_iIndent;      /* Indentation index */
    48   LPITEMIDLIST pidlItem;  /* absolute pidl of the item */ 
     44  LPITEMIDLIST pidlItem;  /* absolute pidl of the item */
    4945
    5046} SFOLDER,*LPSFOLDER;
     
    164160
    165161/* Shell memory allocation */
    166 char *MemAlloc(UINT size);
     162void *MemAlloc(UINT size);
    167163void MemFree(void *mem);
    168164
    169 BOOL WINAPI GetOpenFileName95(FileOpenDlgInfos *fodInfos);
    170 BOOL WINAPI GetSaveFileName95(FileOpenDlgInfos *fodInfos);
     165BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos);
    171166HRESULT WINAPI FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    172 
    173 /***********************************************************************
    174  *      GetOpenFileName95
    175  *
    176  * Creates an Open common dialog box that lets the user select
     167HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
     168HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
     169
     170/***********************************************************************
     171 *      GetFileName95
     172 *
     173 * Creates an Open common dialog box that lets the user select
    177174 * the drive, directory, and the name of a file or set of files to open.
    178175 *
     
    181178 *       FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
    182179 */
    183 BOOL WINAPI GetOpenFileName95(FileOpenDlgInfos *fodInfos)
     180BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos)
    184181{
    185182
    186183    LRESULT lRes;
    187     LPCVOID templateDlg;
     184    LPCVOID lpTemplate;
    188185    HRSRC hRes;
    189186    HANDLE hDlgTmpl = 0;
     
    191188    /* Create the dialog from a template */
    192189
    193     if(!(hRes = FindResourceA(COMDLG32_hInstance,MAKEINTRESOURCEA(IDD_OPENDIALOG),RT_DIALOGA)))
     190    if(!(hRes = FindResourceA(COMMDLG_hInstance32,MAKEINTRESOURCEA(NEWFILEOPENORD),RT_DIALOGA)))
    194191    {
    195192        COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    196193        return FALSE;
    197194    }
    198     if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hRes )) ||
    199         !(templateDlg = LockResource( hDlgTmpl )))
     195    if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hRes )) ||
     196        !(lpTemplate = LockResource( hDlgTmpl )))
    200197    {
    201198        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    202199        return FALSE;
    203200    }
    204     lRes = DialogBoxIndirectParamA(COMDLG32_hInstance,
    205                                   (LPDLGTEMPLATEA) templateDlg,
     201    lRes = DialogBoxIndirectParamA(COMMDLG_hInstance32,
     202                                  (LPDLGTEMPLATEA) lpTemplate,
    206203                                  fodInfos->ofnInfos.hwndOwner,
    207204                                  (DLGPROC) FileOpenDlgProc95,
     
    211208    if( lRes == -1)
    212209        return FALSE;
    213    
     210
    214211    return lRes;
    215212}
    216213
    217214/***********************************************************************
    218  *      GetSaveFileName95
    219  *
    220  * Creates an Save as common dialog box that lets the user select
    221  * the drive, directory, and the name of a file or set of files to open.
    222  *
    223  * IN  : The FileOpenDlgInfos structure associated with the dialog
    224  * OUT : TRUE on success
    225  *       FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
    226  */
    227 BOOL WINAPI GetSaveFileName95(FileOpenDlgInfos *fodInfos)
    228 {
    229 
    230     LRESULT lRes;
    231     LPCVOID templateDlg;
    232     HRSRC hRes;
    233     HANDLE hDlgTmpl = 0;
    234 
    235     /* Create the dialog from a template */
    236 
    237     if(!(hRes = FindResourceA(COMDLG32_hInstance,MAKEINTRESOURCEA(IDD_SAVEDIALOG),RT_DIALOGA)))
    238     {
    239         COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    240         return FALSE;
    241     }
    242     if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hRes )) ||
    243         !(templateDlg = LockResource( hDlgTmpl )))
    244     {
    245         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    246         return FALSE;
    247     }
    248     lRes = DialogBoxIndirectParamA(COMDLG32_hInstance,
    249                                   (LPDLGTEMPLATEA) templateDlg,
    250                                   fodInfos->ofnInfos.hwndOwner,
    251                                   (DLGPROC) FileOpenDlgProc95,
    252                                   (LPARAM) fodInfos);
    253     /* Unable to create the dialog*/
    254     if( lRes == -1)
    255         return FALSE;
    256    
    257     return lRes;
    258 }
    259 
    260 /***********************************************************************
    261215 *      GetFileDialog95A
    262216 *
    263217 * Copy the OPENFILENAMEA structure in a FileOpenDlgInfos structure.
    264  * Call GetOpenFileName95 with this structure and clean the memory.
     218 * Call GetFileName95 with this structure and clean the memory.
    265219 *
    266220 * IN  : The OPENFILENAMEA initialisation structure passed to
     
    272226  BOOL ret;
    273227  FileOpenDlgInfos *fodInfos;
    274  
    275   /* Initialise FileOpenDlgInfos structure*/ 
     228
     229  /* Initialise FileOpenDlgInfos structure*/
    276230  fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos));
    277231  memset(&fodInfos->ofnInfos,'\0',sizeof(*ofn)); fodInfos->ofnInfos.lStructSize = sizeof(*ofn);
     
    300254      s = s+strlen(s)+1;
    301255    s++;
    302     x = MemAlloc(s-ofn->lpstrCustomFilter);
     256    x = (LPSTR)MemAlloc(s-ofn->lpstrCustomFilter);
    303257    memcpy(x,ofn->lpstrCustomFilter,s-ofn->lpstrCustomFilter);
    304258    fodInfos->ofnInfos.lpstrCustomFilter = (LPSTR)x;
     
    333287  if (ofn->lpstrDefExt)
    334288  {
    335       fodInfos->ofnInfos.lpstrDefExt = MemAlloc(strlen(ofn->lpstrDefExt)+1);
     289      fodInfos->ofnInfos.lpstrDefExt = (LPSTR)MemAlloc(strlen(ofn->lpstrDefExt)+1);
    336290      strcpy((LPSTR)fodInfos->ofnInfos.lpstrDefExt,ofn->lpstrDefExt);
    337291  }
     
    339293  fodInfos->ofnInfos.lpfnHook = (LPOFNHOOKPROC)ofn->lpfnHook;
    340294
    341   //SvL: Bugfix; can be resource id
    342295  if (HIWORD(ofn->lpTemplateName))
    343296  {
     297      fodInfos->ofnInfos.lpTemplateName = (LPSTR)MemAlloc(strlen(ofn->lpTemplateName)+1);
     298      strcpy ((LPSTR)fodInfos->ofnInfos.lpTemplateName, ofn->lpTemplateName);
     299  }
     300  else
     301  {
     302      /* resource id */
    344303      fodInfos->ofnInfos.lpTemplateName = ofn->lpTemplateName;
    345304  }
     
    348307  if(!ofn->lpstrInitialDir)
    349308  {
    350     fodInfos->ofnInfos.lpstrInitialDir = MemAlloc(MAX_PATH);
     309    fodInfos->ofnInfos.lpstrInitialDir = (LPSTR)MemAlloc(MAX_PATH);
    351310    GetCurrentDirectoryA(MAX_PATH,(LPSTR)fodInfos->ofnInfos.lpstrInitialDir);
    352311  }
     
    354313  /* Initialise the dialog property */
    355314  fodInfos->DlgInfos.dwDlgProp = 0;
    356  
     315  fodInfos->DlgInfos.hwndCustomDlg = (HWND)NULL;
     316
    357317  switch(iDlgType)
    358318  {
    359319  case OPEN_DIALOG :
    360       ret = GetOpenFileName95(fodInfos);
     320      ret = GetFileName95(fodInfos);
    361321      break;
    362322  case SAVE_DIALOG :
    363323      fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
    364       ret = GetSaveFileName95(fodInfos);
     324      ret = GetFileName95(fodInfos);
    365325      break;
    366326  default :
     
    370330  ofn->nFileOffset = fodInfos->ofnInfos.nFileOffset;
    371331  ofn->nFileExtension = fodInfos->ofnInfos.nFileExtension;
     332
     333  /*
     334     Transfer the combo index in the OPENFILENAME structure;
     335     No support for custom filters, so nFilterIndex must be one-based.
     336  */
     337  ofn->nFilterIndex = fodInfos->ofnInfos.nFilterIndex + 1;
     338
    372339  if (fodInfos->ofnInfos.lpstrFilter)
    373340      MemFree((LPVOID)(fodInfos->ofnInfos.lpstrFilter));
    374   if (fodInfos->ofnInfos.lpTemplateName)
     341  if (HIWORD(fodInfos->ofnInfos.lpTemplateName))
    375342      MemFree((LPVOID)(fodInfos->ofnInfos.lpTemplateName));
    376343  if (fodInfos->ofnInfos.lpstrDefExt)
     
    383350      MemFree((LPVOID)(fodInfos->ofnInfos.lpstrCustomFilter));
    384351
    385   if (fodInfos->ofnInfos.lpstrFile) 
     352  if (fodInfos->ofnInfos.lpstrFile)
    386353    {
    387354      strcpy(ofn->lpstrFile,fodInfos->ofnInfos.lpstrFile);
    388355      MemFree((LPVOID)fodInfos->ofnInfos.lpstrFile);
    389356    }
    390   if (fodInfos->ofnInfos.lpstrFileTitle) 
     357  if (fodInfos->ofnInfos.lpstrFileTitle)
    391358    {
    392359      if (ofn->lpstrFileTitle)
     
    404371 *
    405372 * Copy the OPENFILENAMEW structure in a FileOpenDlgInfos structure.
    406  * Call GetOpenFileName95 with this structure and clean the memory.
     373 * Call GetFileName95 with this structure and clean the memory.
    407374 *
    408375 * IN  : The OPENFILENAMEW initialisation structure passed to
     
    428395    /* filter is a list...  title\0ext\0......\0\0 */
    429396    s = (LPWSTR)ofn->lpstrFilter;
    430    
     397
    431398    while (*s)
    432399      s = s+lstrlenW(s)+1;
     
    492459  fodInfos->ofnInfos.lCustData = ofn->lCustData;
    493460  fodInfos->ofnInfos.lpfnHook = (LPOFNHOOKPROC)ofn->lpfnHook;
    494   //SvL: Bugfix
     461
    495462  if (HIWORD(ofn->lpTemplateName))
    496   { 
     463  {
    497464    fodInfos->ofnInfos.lpTemplateName = (LPSTR)MemAlloc(lstrlenW(ofn->lpTemplateName)+1);
    498465    lstrcpyWtoA((LPSTR)fodInfos->ofnInfos.lpTemplateName,(LPWSTR)ofn->lpTemplateName);
    499466  }
     467  else
     468  {
     469      /* resource id */
     470      fodInfos->ofnInfos.lpTemplateName = (LPSTR)ofn->lpTemplateName;
     471  }
    500472  /* Initialise the dialog property */
    501473  fodInfos->DlgInfos.dwDlgProp = 0;
    502  
     474
    503475  switch(iDlgType)
    504476  {
    505477  case OPEN_DIALOG :
    506       ret = GetOpenFileName95(fodInfos);
     478      ret = GetFileName95(fodInfos);
    507479      break;
    508480  case SAVE_DIALOG :
    509481      fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
    510       ret = GetSaveFileName95(fodInfos);
     482      ret = GetFileName95(fodInfos);
    511483      break;
    512484  default :
    513485      ret = 0;
    514486  }
    515      
     487
    516488  /* Cleaning */
    517489  ofn->nFileOffset = fodInfos->ofnInfos.nFileOffset;
    518490  ofn->nFileExtension = fodInfos->ofnInfos.nFileExtension;
     491
     492  /*
     493     Transfer the combo index in the OPENFILENAME structure;
     494     No support for custom filters, so nFilterIndex must be one-based.
     495  */
     496  ofn->nFilterIndex = fodInfos->ofnInfos.nFilterIndex + 1;
     497
    519498  if (fodInfos->ofnInfos.lpstrFilter)
    520499    MemFree((LPVOID)(fodInfos->ofnInfos.lpstrFilter));
    521   if (fodInfos->ofnInfos.lpTemplateName)
     500  if (HIWORD(fodInfos->ofnInfos.lpTemplateName))
    522501    MemFree((LPVOID)(fodInfos->ofnInfos.lpTemplateName));
    523502  if (fodInfos->ofnInfos.lpstrDefExt)
     
    549528{
    550529
    551         HWND hwndChild,hwndStc32;
    552         RECT rectParent,rectChild,rectCtrl,rectStc32;
    553         POINT ptMoveCtl;
    554         HDWP handle;
    555         POINT ptParentClient;
    556 
    557         ptMoveCtl.x = ptMoveCtl.y = 0;
    558         hwndStc32=GetDlgItem(hwndChildDlg,stc32);
    559         GetClientRect(hwndParentDlg,&rectParent);
    560         GetClientRect(hwndChildDlg,&rectChild);
    561         if(hwndStc32)
    562         {
    563                 RECT rectTemp;
    564                 GetWindowRect(hwndStc32,&rectStc32);
    565                 MapWindowPoints(0, hwndChildDlg,(LPPOINT)&rectStc32,2);
    566                 CopyRect(&rectTemp,&rectStc32);
    567 
    568                 SetRect(&rectStc32,rectStc32.left,rectStc32.top,rectStc32.left + (rectParent.right-rectParent.left),rectStc32.top+(rectParent.bottom-rectParent.top));
    569                 SetWindowPos(hwndStc32,0,rectStc32.left,rectStc32.top,rectStc32.right-rectStc32.left,rectStc32.bottom-rectStc32.top,SWP_NOMOVE|SWP_NOZORDER | SWP_NOACTIVATE);
    570                 if(rectStc32.right < rectTemp.right)
    571                 {
    572                         ptParentClient.x = max((rectParent.right-rectParent.left),(rectChild.right-rectChild.left));
    573                         ptMoveCtl.x = 0;
    574                 }
    575                 else
    576                 {
    577                         ptMoveCtl.x = (rectStc32.right - rectTemp.right);
    578                         ptParentClient.x = max((rectParent.right-rectParent.left),((rectChild.right-rectChild.left)+rectStc32.right-rectTemp.right));
    579                 }
    580                 if(rectStc32.bottom < rectTemp.bottom)
    581                 {
    582                         ptParentClient.y = max((rectParent.bottom-rectParent.top),(rectChild.bottom-rectChild.top));
    583                         ptMoveCtl.y = 0;
    584                 }
    585                 else
    586                 {
    587                         ptMoveCtl.y = (rectStc32.bottom - rectTemp.bottom);
    588                         ptParentClient.y = max((rectParent.bottom-rectParent.top),((rectChild.bottom-rectChild.top)+rectStc32.bottom-rectTemp.bottom));
    589                 }
    590         }
    591         else
    592         {
    593                 if( (GetWindow(hwndChildDlg,GW_CHILD)) == (HWND) NULL)
     530    HWND hwndChild,hwndStc32;
     531    RECT rectParent, rectChild, rectCtrl, rectStc32, rectTemp;
     532    POINT ptMoveCtl;
     533    HDWP handle;
     534    POINT ptParentClient;
     535
     536    ptMoveCtl.x = ptMoveCtl.y = 0;
     537    hwndStc32=GetDlgItem(hwndChildDlg,stc32);
     538    GetClientRect(hwndParentDlg,&rectParent);
     539    GetClientRect(hwndChildDlg,&rectChild);
     540    if(hwndStc32)
     541    {
     542        GetWindowRect(hwndStc32,&rectStc32);
     543        MapWindowPoints(0, hwndChildDlg,(LPPOINT)&rectStc32,2);
     544        CopyRect(&rectTemp,&rectStc32);
     545
     546        SetRect(&rectStc32,rectStc32.left,rectStc32.top,rectStc32.left + (rectParent.right-rectParent.left),rectStc32.top+(rectParent.bottom-rectParent.top));
     547        SetWindowPos(hwndStc32,0,rectStc32.left,rectStc32.top,rectStc32.right-rectStc32.left,rectStc32.bottom-rectStc32.top,SWP_NOMOVE|SWP_NOZORDER | SWP_NOACTIVATE);
     548
     549        if(rectStc32.right < rectTemp.right)
     550        {
     551            ptParentClient.x = max((rectParent.right-rectParent.left),(rectChild.right-rectChild.left));
     552            ptMoveCtl.x = 0;
     553        }
     554        else
     555        {
     556            ptMoveCtl.x = (rectStc32.right - rectTemp.right);
     557            ptParentClient.x = max((rectParent.right-rectParent.left),((rectChild.right-rectChild.left)+rectStc32.right-rectTemp.right));
     558        }
     559        if(rectStc32.bottom < rectTemp.bottom)
     560        {
     561            ptParentClient.y = max((rectParent.bottom-rectParent.top),(rectChild.bottom-rectChild.top));
     562            ptMoveCtl.y = 0;
     563        }
     564        else
     565        {
     566            ptMoveCtl.y = (rectStc32.bottom - rectTemp.bottom);
     567            ptParentClient.y = max((rectParent.bottom-rectParent.top),((rectChild.bottom-rectChild.top)+rectStc32.bottom-rectTemp.bottom));
     568        }
     569    }
     570    else
     571    {
     572        if( (GetWindow(hwndChildDlg,GW_CHILD)) == (HWND) NULL)
    594573                   return;
    595                 ptParentClient.x = rectParent.right-rectParent.left;
    596                 ptParentClient.y = (rectParent.bottom-rectParent.top) + (rectChild.bottom-rectChild.top);
    597                 ptMoveCtl.y = rectParent.bottom-rectParent.top;
    598                 ptMoveCtl.x=0;
    599         }
    600         SetRect(&rectParent,rectParent.left,rectParent.top,rectParent.left+ptParentClient.x,rectParent.top+ptParentClient.y);
    601         AdjustWindowRectEx( &rectParent,GetWindowLongA(hwndParentDlg,GWL_STYLE),FALSE,GetWindowLongA(hwndParentDlg,GWL_EXSTYLE));
    602 
    603         SetWindowPos(hwndChildDlg, 0, 0,0, ptParentClient.x,ptParentClient.y,
    604                  SWP_NOZORDER );
    605         SetWindowPos(hwndParentDlg, 0, rectParent.left,rectParent.top, (rectParent.right- rectParent.left),
    606                 (rectParent.bottom-rectParent.top),SWP_NOMOVE | SWP_NOZORDER);
    607        
    608         hwndChild = GetWindow(hwndChildDlg,GW_CHILD);
    609         handle = BeginDeferWindowPos( 1 );
    610         if(hwndStc32)
    611         {
    612                 GetWindowRect(hwndStc32,&rectStc32);
    613                 MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
    614         }
    615         else
    616                 SetRect(&rectStc32,0,0,0,0);
    617         if (hwndChild && handle)
    618         {
    619                 do
    620                 {
    621                         if(hwndChild != hwndStc32)
    622                         {
    623                         if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
    624                                 continue;
    625                         GetWindowRect(hwndChild,&rectCtrl);
    626                         MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
    627                         if(rectCtrl.top > rectStc32.top)
    628                         {
    629                                  
    630                                 if(ptMoveCtl.x > 0)
    631                                         rectCtrl.left += ptMoveCtl.x;
    632                                 rectCtrl.top  += ptMoveCtl.y;
    633                                 handle = DeferWindowPos(handle, hwndChild, 0, rectCtrl.left, rectCtrl.top,
    634                                 rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
    635                                 SWP_NOSIZE | SWP_NOZORDER );
    636                                 }
    637                         }
    638                 }
    639                 while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL && handle);
    640         }               
    641         if(handle)
    642                 EndDeferWindowPos( handle );
    643         handle = BeginDeferWindowPos( 1 );
    644         hwndChild = GetWindow(hwndParentDlg,GW_CHILD);
    645         if(hwndStc32)
    646         {
    647                 GetWindowRect(hwndStc32,&rectStc32);
    648                 MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
    649                 ptMoveCtl.x = rectStc32.left - 0;
    650                 ptMoveCtl.y = rectStc32.top - 0;
    651                 if (hwndChild && handle)
    652                 {
    653                         do
    654                         {
    655                                 if(hwndChild != hwndChildDlg)
    656                                 {
    657 
    658                                         if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
    659                                                 continue;
    660                                         GetWindowRect(hwndChild,&rectCtrl);
    661                                         MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
    662 
    663                                         rectCtrl.left += ptMoveCtl.x;
    664                                         rectCtrl.top += ptMoveCtl.y;
    665 
    666                                         handle = DeferWindowPos(        handle, hwndChild, 0, rectCtrl.left, rectCtrl.top,
    667                                         rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
    668                                         SWP_NOSIZE |SWP_NOZORDER );
    669                                 }
    670                         }
    671                         while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL);
    672                 }               
    673                 if(handle)
    674                 EndDeferWindowPos( handle );
    675         }
     574        ptParentClient.x = rectParent.right-rectParent.left;
     575        ptParentClient.y = (rectParent.bottom-rectParent.top) + (rectChild.bottom-rectChild.top);
     576        ptMoveCtl.y = rectParent.bottom-rectParent.top;
     577        ptMoveCtl.x=0;
     578    }
     579    SetRect(&rectParent,rectParent.left,rectParent.top,rectParent.left+ptParentClient.x,rectParent.top+ptParentClient.y);
     580    AdjustWindowRectEx( &rectParent,GetWindowLongA(hwndParentDlg,GWL_STYLE),FALSE,GetWindowLongA(hwndParentDlg,GWL_EXSTYLE));
     581
     582    SetWindowPos(hwndChildDlg, 0, 0,0, ptParentClient.x,ptParentClient.y,
     583         SWP_NOZORDER );
     584    SetWindowPos(hwndParentDlg, 0, rectParent.left,rectParent.top, (rectParent.right- rectParent.left),
     585        (rectParent.bottom-rectParent.top),SWP_NOMOVE | SWP_NOZORDER);
     586
     587    hwndChild = GetWindow(hwndChildDlg,GW_CHILD);
     588    handle = BeginDeferWindowPos( 1 );
     589    if(hwndStc32)
     590    {
     591        GetWindowRect(hwndStc32,&rectStc32);
     592        MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
     593    }
     594    else
     595        SetRect(&rectStc32,0,0,0,0);
     596
     597    if (hwndChild && handle)
     598    {
     599        do
     600        {
     601            if(hwndChild != hwndStc32)
     602            {
     603            if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
     604                continue;
     605            GetWindowRect(hwndChild,&rectCtrl);
     606            MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
     607
     608                /*
     609                   Check the initial position of the controls relative to the initial
     610                   position and size of stc32 (before it is expanded).
     611                */
     612                if (rectCtrl.left > rectTemp.right && rectCtrl.top > rectTemp.bottom)
     613                {
     614                    rectCtrl.left += ptMoveCtl.x;
     615                rectCtrl.top  += ptMoveCtl.y;
     616                }
     617                else if (rectCtrl.left > rectTemp.right)
     618                    rectCtrl.left += ptMoveCtl.x;
     619                else if (rectCtrl.top > rectTemp.bottom)
     620                    rectCtrl.top  += ptMoveCtl.y;
     621
     622                handle = DeferWindowPos(handle, hwndChild, 0, rectCtrl.left, rectCtrl.top,
     623                rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
     624                SWP_NOSIZE | SWP_NOZORDER );
     625                }
     626            }
     627        while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL && handle);
     628    }
     629    if(handle)
     630        EndDeferWindowPos( handle );
     631    handle = BeginDeferWindowPos( 1 );
     632    hwndChild = GetWindow(hwndParentDlg,GW_CHILD);
     633
     634    if(hwndStc32)
     635    {
     636        GetWindowRect(hwndStc32,&rectStc32);
     637        MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
     638        ptMoveCtl.x = rectStc32.left - 0;
     639        ptMoveCtl.y = rectStc32.top - 0;
     640        if (hwndChild && handle)
     641        {
     642            do
     643            {
     644                if(hwndChild != hwndChildDlg)
     645                {
     646
     647                    if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
     648                        continue;
     649                    GetWindowRect(hwndChild,&rectCtrl);
     650                    MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
     651
     652                    rectCtrl.left += ptMoveCtl.x;
     653                    rectCtrl.top += ptMoveCtl.y;
     654
     655                    handle = DeferWindowPos(    handle, hwndChild, 0, rectCtrl.left, rectCtrl.top,
     656                    rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
     657                    SWP_NOSIZE |SWP_NOZORDER );
     658                }
     659            }
     660            while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL);
     661        }
     662        if(handle)
     663        EndDeferWindowPos( handle );
     664    }
    676665
    677666}
     
    683672  switch(uMsg)
    684673  {
    685         case WM_INITDIALOG:
    686         {         
    687                 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *)lParam;
    688                 procUserHook=NULL;
     674    case WM_INITDIALOG:
     675    {
     676        FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *)lParam;
     677        procUserHook=NULL;
    689678                lParam = (LPARAM) &fodInfos->ofnInfos;
    690                 ArrangeCtrlPositions(hwnd,GetParent(hwnd));
     679        ArrangeCtrlPositions(hwnd,GetParent(hwnd));
    691680                if(fodInfos->ofnInfos.Flags & OFN_ENABLEHOOK)
    692                         procUserHook = (WNDPROC) fodInfos->ofnInfos.lpfnHook;
    693                 if(procUserHook)
    694                          return CallWindowProcA(procUserHook,hwnd,uMsg,wParam,lParam);
    695                 return 0;       
    696         } }
     681                    procUserHook = (WNDPROC) fodInfos->ofnInfos.lpfnHook;
     682        if(procUserHook)
     683                 return CallWindowProcA(procUserHook,hwnd,uMsg,wParam,lParam);
     684            return 0;
     685    } }
    697686 if(procUserHook)
    698       return CallWindowProcA(procUserHook,hwnd,uMsg,wParam,lParam); 
    699   return DefWindowProcA(hwnd,uMsg,wParam,lParam); 
     687      return CallWindowProcA(procUserHook,hwnd,uMsg,wParam,lParam);
     688  return DefWindowProcA(hwnd,uMsg,wParam,lParam);
    700689}
    701690
    702691HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos,HWND hwnd)
    703692{
    704     LPCVOID templateDlg;
     693    LPCVOID lpTemplate;
    705694    HRSRC hRes;
    706695    HANDLE hDlgTmpl = 0;
     
    708697   if (fodInfos->ofnInfos.Flags & OFN_ENABLETEMPLATE || fodInfos->ofnInfos.Flags & OFN_ENABLETEMPLATEHANDLE)
    709698   {
    710         if (fodInfos->ofnInfos.Flags  & OFN_ENABLETEMPLATEHANDLE)
    711         {
    712            if( !(templateDlg = LockResource( fodInfos->ofnInfos.hInstance)))
    713                 {
    714                 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    715                 return (HWND)NULL;
    716                 }
    717                
    718         }
    719         else
    720         {
    721          if (!(hRes = FindResourceA(MapHModuleSL(fodInfos->ofnInfos.hInstance),
     699    if (fodInfos->ofnInfos.Flags  & OFN_ENABLETEMPLATEHANDLE)
     700    {
     701           if( !(lpTemplate = LockResource( fodInfos->ofnInfos.hInstance)))
     702            {
     703            COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     704            return (HWND)NULL;
     705            }
     706
     707    }
     708    else
     709    {
     710     if (!(hRes = FindResourceA(MapHModuleSL(fodInfos->ofnInfos.hInstance),
    722711            (fodInfos->ofnInfos.lpTemplateName), RT_DIALOGA)))
    723         {
    724                 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    725                  return (HWND)NULL;
    726         }
    727         if (!(hDlgTmpl = LoadResource( MapHModuleSL(fodInfos->ofnInfos.hInstance),
     712        {
     713            COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     714             return (HWND)NULL;
     715        }
     716        if (!(hDlgTmpl = LoadResource( MapHModuleSL(fodInfos->ofnInfos.hInstance),
    728717             hRes )) ||
    729                  !(templateDlg = LockResource( hDlgTmpl )))
    730         {
    731                 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    732                 return (HWND)NULL;
    733         }
    734         }
    735 
    736         hChildDlg= CreateDialogIndirectParamA(fodInfos->ofnInfos.hInstance,(LPCDLGTEMPLATEA)templateDlg,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
    737         if(hChildDlg)
    738         {
    739                 ShowWindow(hChildDlg,SW_SHOW);
    740                 return hChildDlg;
    741         }
     718                 !(lpTemplate = LockResource( hDlgTmpl )))
     719        {
     720            COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     721            return (HWND)NULL;
     722        }
     723    }
     724
     725    hChildDlg= CreateDialogIndirectParamA(fodInfos->ofnInfos.hInstance,(LPCDLGTEMPLATEA)lpTemplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
     726    if(hChildDlg)
     727    {
     728        ShowWindow(hChildDlg,SW_SHOW);
     729            return hChildDlg;
     730    }
    742731 }
    743732 else if(fodInfos->ofnInfos.Flags & OFN_ENABLEHOOK && fodInfos->ofnInfos.lpfnHook)
    744733 {
    745         RECT rectHwnd;
    746         DLGTEMPLATE tmplate;
    747         GetClientRect(hwnd,&rectHwnd);
    748         tmplate.style = WS_CHILD | WS_CLIPSIBLINGS;
    749         tmplate.dwExtendedStyle = 0;
    750         tmplate.cdit = 0;
    751         tmplate.x = 0;
    752         tmplate.y = 0;
    753         tmplate.cx = rectHwnd.right-rectHwnd.left;
    754         tmplate.cy = rectHwnd.bottom-rectHwnd.top;
    755        
    756         return CreateDialogIndirectParamA(fodInfos->ofnInfos.hInstance,&tmplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
     734    RECT rectHwnd;
     735    DLGTEMPLATE tmplate;
     736    GetClientRect(hwnd,&rectHwnd);
     737    tmplate.style = WS_CHILD | WS_CLIPSIBLINGS;
     738    tmplate.dwExtendedStyle = 0;
     739    tmplate.cdit = 0;
     740    tmplate.x = 0;
     741    tmplate.y = 0;
     742    tmplate.cx = rectHwnd.right-rectHwnd.left;
     743    tmplate.cy = rectHwnd.bottom-rectHwnd.top;
     744
     745    return CreateDialogIndirectParamA(fodInfos->ofnInfos.hInstance,&tmplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
    757746 }
    758747return (HWND)NULL;
     
    760749
    761750/***********************************************************************
     751*          SendCustomDlgNotificationMessage
     752*
     753* Send CustomDialogNotification (CDN_FIRST -- CDN_LAST) message to the custom template dialog
     754*/
     755
     756HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
     757{
     758    FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndParentDlg,FileOpenDlgInfosStr);
     759    if(!fodInfos)
     760        return 0;
     761    if(fodInfos->DlgInfos.hwndCustomDlg)
     762    {
     763        OFNOTIFYA ofnNotify;
     764        ofnNotify.hdr.hwndFrom=hwndParentDlg;
     765        ofnNotify.hdr.idFrom=0;
     766        ofnNotify.hdr.code = uCode;
     767        ofnNotify.lpOFN = &fodInfos->ofnInfos;
     768        return SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
     769    }
     770    return TRUE;
     771}
     772
     773/***********************************************************************
     774*         FILEDLG95_HandleCustomDialogMessages
     775*
     776* Handle Custom Dialog Messages (CDM_FIRST -- CDM_LAST) messages
     777*/
     778HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     779{
     780    LPSTR lpstrFileSpec;
     781    char lpstrCurrentDir[MAX_PATH]="";
     782    FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
     783    if(!fodInfos)
     784        return TRUE;
     785    switch(uMsg)
     786    {
     787        case CDM_GETFILEPATH:
     788        {
     789            char lpstrPathSpec[MAX_PATH]="";
     790            GetDlgItemTextA(hwnd,IDC_FILENAME,(LPSTR)lParam, (int)wParam);
     791            lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA((LPSTR)lParam);
     792            strcpy(lpstrPathSpec,(LPSTR)lParam);
     793            COMDLG32_PathRemoveFileSpecA(lpstrPathSpec);
     794            if(!lpstrPathSpec[0])
     795                COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,
     796                lpstrPathSpec);
     797            strcat(lpstrPathSpec,"\\");
     798            strcat(lpstrPathSpec,(LPSTR)lParam);
     799            strcpy((LPSTR)lParam,(LPSTR)lpstrPathSpec);
     800        }
     801            return TRUE;
     802        case CDM_GETFOLDERPATH:
     803            if(lParam)
     804            {
     805                if(fodInfos)
     806                {
     807                    COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,
     808                    lpstrCurrentDir);
     809                    strncpy((LPSTR)lParam,lpstrCurrentDir,(int)wParam);
     810                }
     811                else
     812                *((LPSTR)lParam)=0;
     813            }
     814            return TRUE;
     815    case CDM_GETSPEC:
     816            if(lParam)
     817            {
     818                GetDlgItemTextA(hwnd,IDC_FILENAME,(LPSTR)lParam, (int)wParam);
     819                lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA((LPSTR)lParam);
     820                if(lpstrFileSpec)
     821                   strcpy((LPSTR)lParam, lpstrFileSpec);
     822                else
     823                    *((LPSTR)lParam)=0;
     824            }
     825            return TRUE;
     826        case CDM_HIDECONTROL:
     827        case CDM_SETCONTROLTEXT:
     828        case CDM_SETDEFEXT:
     829        FIXME("CDM_HIDECONTROL,CDM_SETCONTROLTEXT,CDM_SETDEFEXT not implemented\n");
     830        return TRUE;
     831    }
     832    return TRUE;
     833}
     834
     835/***********************************************************************
    762836 *          FileOpenDlgProc95
    763837 *
     
    766840HRESULT WINAPI FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    767841{
    768 
    769842  switch(uMsg)
    770843  {
    771844    case WM_INITDIALOG :
    772         CreateTemplateDialog((FileOpenDlgInfos *)lParam,hwnd);
    773       return FILEDLG95_OnWMInitDialog(hwnd, wParam, lParam);
     845
     846         /* Adds the FileOpenDlgInfos in the property list of the dialog
     847            so it will be easily accessible through a GetPropA(...) */
     848         SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) lParam);
     849
     850         ((FileOpenDlgInfos *)lParam)->DlgInfos.hwndCustomDlg =
     851        CreateTemplateDialog((FileOpenDlgInfos *)lParam,hwnd);
     852         FILEDLG95_OnWMInitDialog(hwnd, wParam, lParam);
     853         SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE);
     854         return 0;
    774855    case WM_COMMAND:
    775856      return FILEDLG95_OnWMCommand(hwnd, wParam, lParam);
     
    784865      }
    785866      return FALSE;
    786          
     867
    787868    case WM_GETISHELLBROWSER:
    788869      return FILEDLG95_OnWMGetIShellBrowser(hwnd);
     
    792873
    793874    default :
     875      if(uMsg >= CDM_FIRST && uMsg <= CDM_LAST)
     876        return FILEDLG95_HandleCustomDialogMessages(hwnd, uMsg, wParam, lParam);
    794877      return FALSE;
    795878  }
     
    808891  TRACE("\n");
    809892
    810   /* Adds the FileOpenDlgInfos in the property list of the dialog
    811      so it will be easily accessible through a GetPropA(...) */
    812   SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) fodInfos);
    813 
     893  /* Make sure the common control DLL is loaded */
    814894#ifndef __WIN32OS2__
    815   /* Make sure the common control DLL is loaded */     
    816895  InitCommonControls();
    817896#endif
     
    875954    /* OK button */
    876955  case IDOK:
    877       FILEDLG95_OnOpen(hwnd);
     956      if(FILEDLG95_OnOpen(hwnd))
     957        SendCustomDlgNotificationMessage(hwnd,CDN_FILEOK);
    878958    break;
    879959    /* Cancel button */
     
    885965  case IDC_FILETYPE:
    886966    FILEDLG95_FILETYPE_OnCommand(hwnd,wNotifyCode);
     967    SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE);
    887968    break;
    888969    /* LookIn combo box */
     
    890971    FILEDLG95_LOOKIN_OnCommand(hwnd,wNotifyCode);
    891972    break;
     973
     974  /* --- toolbar --- */
    892975    /* Up folder button */
    893   case IDC_UPFOLDER:
     976  case FCIDM_TB_UPFOLDER:
    894977    FILEDLG95_SHELL_UpFolder(hwnd);
    895978    break;
     979    /* New folder button */
     980  case FCIDM_TB_NEWFOLDER:
     981    FILEDLG95_SHELL_NewFolder(hwnd);
     982    break;
    896983    /* List option button */
    897   case IDC_LIST:
     984  case FCIDM_TB_SMALLICON:
    898985    FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWLIST);
    899986    break;
    900987    /* Details option button */
    901   case IDC_DETAILS:
     988  case FCIDM_TB_REPORTVIEW:
    902989    FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWDETAILS);
    903990    break;
    904     /* New folder button */
    905   case IDC_NEWFOLDER:
    906     FILEDLG95_SHELL_NewFolder(hwnd);
    907     break;
    908991
    909992  case IDC_FILENAME:
     
    913996  /* Do not use the listview selection anymore */
    914997  fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW;
    915   return 0; 
     998  return 0;
    916999}
    9171000
     
    9301013  SetWindowLongA(hwnd,DWL_MSGRESULT,(LONG)fodInfos->Shell.FOIShellBrowser);
    9311014
    932   return TRUE; 
     1015  return TRUE;
    9331016}
    9341017
     
    9401023static LRESULT FILEDLG95_InitUI(HWND hwnd)
    9411024{
    942   HIMAGELIST himlToolbar;
    943   HICON hicon;
     1025  TBBUTTON tbb[] =
     1026  {{VIEW_PARENTFOLDER, FCIDM_TB_UPFOLDER,   TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
     1027   {0,                 0,                   TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
     1028   {VIEW_NEWFOLDER,    FCIDM_TB_NEWFOLDER,  TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
     1029   {0,                 0,                   TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
     1030   {VIEW_LIST,         FCIDM_TB_SMALLICON,  TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
     1031   {VIEW_DETAILS,      FCIDM_TB_REPORTVIEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
     1032  };
     1033  TBADDBITMAP tba = { HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR };
     1034  RECT rectTB;
     1035
    9441036  FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
    9451037
     
    9511043  fodInfos->DlgInfos.hwndLookInCB = GetDlgItem(hwnd,IDC_LOOKIN);
    9521044
    953     ShowWindow(GetDlgItem(hwnd,IDC_SHELLSTATIC),SW_HIDE);
    954   /* Load the icons bitmaps */
    955 
    956   if((himlToolbar = COMDLG32_ImageList_LoadImageA(COMDLG32_hInstance,
    957                                      MAKEINTRESOURCEA(IDB_TOOLBAR),
    958                                      0,
    959                                      1,
    960                                      CLR_DEFAULT,
    961                                      IMAGE_BITMAP,
    962                                      0)))
    963   {
    964     /* Up folder icon */
    965     if((hicon = COMDLG32_ImageList_GetIcon(himlToolbar,0,ILD_NORMAL)))
    966       SendDlgItemMessageA(hwnd,IDC_UPFOLDER,BM_SETIMAGE,(WPARAM)IMAGE_ICON,(LPARAM)hicon);
    967     /* New folder icon */
    968     if((hicon = COMDLG32_ImageList_GetIcon(himlToolbar,1,ILD_NORMAL)))
    969       SendDlgItemMessageA(hwnd,IDC_NEWFOLDER,BM_SETIMAGE,(WPARAM)IMAGE_ICON,(LPARAM)hicon);
    970     /* List view icon */
    971     if((hicon = COMDLG32_ImageList_GetIcon(himlToolbar,2,ILD_NORMAL)))
    972       SendDlgItemMessageA(hwnd,IDC_LIST,BM_SETIMAGE,(WPARAM)IMAGE_ICON,(LPARAM)hicon);
    973     /* Detail view icon */
    974     if((hicon = COMDLG32_ImageList_GetIcon(himlToolbar,3,ILD_NORMAL)))
    975       SendDlgItemMessageA(hwnd,IDC_DETAILS,BM_SETIMAGE,(WPARAM)IMAGE_ICON,(LPARAM)hicon);
    976     /* Cleanup */
    977     COMDLG32_ImageList_Destroy(himlToolbar);
    978   }
    979 
    980 
     1045  /* construct the toolbar */
     1046  GetWindowRect(GetDlgItem(hwnd,IDC_TOOLBARSTATIC),&rectTB);
     1047  MapWindowPoints( 0, hwnd,(LPPOINT)&rectTB,2);
     1048
     1049  fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, (LPSTR) NULL,
     1050        WS_CHILD | WS_GROUP | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NORESIZE,
     1051        0, 0, 150, 26,
     1052    hwnd, (HMENU) IDC_TOOLBAR, COMMDLG_hInstance32, NULL);
     1053
     1054  SetWindowPos(fodInfos->DlgInfos.hwndTB, 0,
     1055    rectTB.left,rectTB.top, rectTB.right-rectTB.left, rectTB.bottom-rectTB.top,
     1056    SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER );
     1057
     1058  SendMessageA(fodInfos->DlgInfos.hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
     1059
     1060/* fixme: use TB_LOADIMAGES when implemented */
     1061/*  SendMessageA(fodInfos->DlgInfos.hwndTB, TB_LOADIMAGES, (WPARAM) IDB_VIEW_SMALL_COLOR, HINST_COMMCTRL);*/
     1062  SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, (WPARAM) 12, (LPARAM) &tba);
     1063
     1064  SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSA, (WPARAM) 6,(LPARAM) &tbb);
     1065  SendMessageA(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0);
    9811066
    9821067  /* Set the window text with the text specified in the OPENFILENAME structure */
    9831068  if(fodInfos->ofnInfos.lpstrTitle)
    984     SetWindowTextA(hwnd,fodInfos->ofnInfos.lpstrTitle);
     1069  {
     1070      SetWindowTextA(hwnd,fodInfos->ofnInfos.lpstrTitle);
     1071  }
     1072  else if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
     1073  {
     1074      SetWindowTextA(hwnd,"Save");
     1075  }
    9851076
    9861077  /* Initialise the file name edit control */
     
    10001091    ShowWindow(GetDlgItem(hwnd,IDC_OPENREADONLY),SW_HIDE);
    10011092  }
    1002 
    1003   /* List View is selected by default */
    1004   SendDlgItemMessageA(hwnd, IDC_LIST, BM_SETCHECK,(WPARAM) BST_CHECKED,0);
    1005 
     1093  /* change Open to Save */
     1094  if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
     1095  {
     1096      SetDlgItemTextA(hwnd,IDOK,"Save");
     1097  }
    10061098  return 0;
    10071099}
     
    10111103 *
    10121104 * Ok button WM_COMMAND message handler
    1013  * 
     1105 *
    10141106 * If the function succeeds, the return value is nonzero.
    10151107 */
     
    10431135      char lpstrPathAndFile[MAX_PATH] = "";
    10441136
    1045       /* Separate the file spec from the path spec 
    1046          e.g.:
    1047               lpstrSpecifiedByUser  lpstrPathSpec  lpstrFileSpec
    1048               C:\TEXT1\TEXT2        C:\TEXT1          TEXT2
    1049       */     
     1137      /* Separate the file spec from the path spec
     1138     e.g.:
     1139          lpstrSpecifiedByUser  lpstrPathSpec  lpstrFileSpec
     1140          C:\TEXT1\TEXT2        C:\TEXT1          TEXT2
     1141      */
    10501142      lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA(lpstrSpecifiedByUser);
    10511143      strcpy(lpstrPathSpec,lpstrSpecifiedByUser);
    10521144      COMDLG32_PathRemoveFileSpecA(lpstrPathSpec);
    1053      
     1145
     1146      /* Get the index of the selected item in the filetype combo box */
     1147      fodInfos->ofnInfos.nFilterIndex = (DWORD) CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB);
     1148
    10541149      /* Get the current directory name */
    10551150      COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,
    1056                                     lpstrCurrentDir);
    1057 
    1058       /* Create an absolute path name */ 
     1151                    lpstrCurrentDir);
     1152
     1153      /* Create an absolute path name */
    10591154      if(lpstrSpecifiedByUser[1] != ':')
    10601155      {
    10611156          switch(lpstrSpecifiedByUser[0])
    10621157          {
    1063           /* Add drive spec  \TEXT => C:\TEXT */
    1064           case '\\':
    1065               {
    1066                   INT iCopy = 2;
    1067                   char lpstrTmp[MAX_PATH] = "";
    1068                   if(!strlen(lpstrPathSpec))
    1069                       iCopy = 3;
    1070                   strncpy(lpstrTmp,lpstrCurrentDir,iCopy);
    1071                   strcat(lpstrTmp,lpstrPathSpec);
    1072                   strcpy(lpstrPathSpec,lpstrTmp);
    1073               }
    1074               break;           
    1075           /* Go to parent ..\TEXT */ 
    1076           case '.':
    1077               {
    1078                   INT iSize;
    1079                   char lpstrTmp2[MAX_PATH] = "";
    1080                   LPSTR lpstrTmp = strrchr(lpstrCurrentDir,'\\');
    1081                   iSize = lpstrTmp - lpstrCurrentDir;
    1082                   strncpy(lpstrTmp2,lpstrCurrentDir,iSize + 1);
    1083                   if(strlen(lpstrSpecifiedByUser) <= 3)
    1084                       strcpy(lpstrFileSpec,"");
    1085                   if(strcmp(lpstrPathSpec,".."))
    1086                       strcat(lpstrTmp2,&lpstrPathSpec[3]);
    1087                   strcpy(lpstrPathSpec,lpstrTmp2);
    1088               }
    1089               break;
    1090           default:
    1091   {
    1092                   char lpstrTmp[MAX_PATH] = "";
    1093                   if(strcmp(&lpstrCurrentDir[strlen(lpstrCurrentDir)-1],"\\"))
    1094                       strcat(lpstrCurrentDir,"\\");
    1095                   strcpy(lpstrTmp,lpstrCurrentDir);
    1096                   strcat(lpstrTmp,lpstrPathSpec);
    1097                   strcpy(lpstrPathSpec,lpstrTmp);
    1098               }
    1099                  
     1158          /* Add drive spec  \TEXT => C:\TEXT */
     1159          case '\\':
     1160              {
     1161              INT iCopy = 2;
     1162              char lpstrTmp[MAX_PATH] = "";
     1163              if(!strlen(lpstrPathSpec))
     1164                  iCopy = 3;
     1165              strncpy(lpstrTmp,lpstrCurrentDir,iCopy);
     1166              strcat(lpstrTmp,lpstrPathSpec);
     1167              strcpy(lpstrPathSpec,lpstrTmp);
     1168              }
     1169              break;
     1170          /* Go to parent ..\TEXT */
     1171      case '.':
     1172          {
     1173              INT iSize;
     1174              char lpstrTmp2[MAX_PATH] = "";
     1175              LPSTR lpstrTmp = strrchr(lpstrCurrentDir,'\\');
     1176              iSize = lpstrTmp - lpstrCurrentDir;
     1177              strncpy(lpstrTmp2,lpstrCurrentDir,iSize + 1);
     1178          if(strlen(lpstrSpecifiedByUser) <= 3)
     1179              strcpy(lpstrFileSpec,"");
     1180              if(strcmp(lpstrPathSpec,".."))
     1181                  strcat(lpstrTmp2,&lpstrPathSpec[3]);
     1182          strcpy(lpstrPathSpec,lpstrTmp2);
     1183              }
     1184              break;
     1185          default:
     1186  {
     1187              char lpstrTmp[MAX_PATH] = "";
     1188              if(strcmp(&lpstrCurrentDir[strlen(lpstrCurrentDir)-1],"\\"))
     1189                  strcat(lpstrCurrentDir,"\\");
     1190              strcpy(lpstrTmp,lpstrCurrentDir);
     1191              strcat(lpstrTmp,lpstrPathSpec);
     1192              strcpy(lpstrPathSpec,lpstrTmp);
     1193              }
     1194
    11001195          } /* end switch */
    11011196      }
     
    11031198      if(strlen(lpstrPathSpec))
    11041199      {
    1105           /* Browse to the right directory */
    1106           COMDLG32_SHGetDesktopFolder(&psfDesktop);
    1107           if((browsePidl = GetPidlFromName(psfDesktop,lpstrPathSpec)))
    1108           {
    1109               /* Browse to directory */
    1110               IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
    1111                                          browsePidl,
    1112                                          SBSP_ABSOLUTE);
    1113               COMDLG32_SHFree(browsePidl);
    1114           }
    1115           else
    1116           {
    1117               /* Path does not exist */
    1118               if(fodInfos->ofnInfos.Flags & OFN_PATHMUSTEXIST)
    1119               {
    1120                   MessageBoxA(hwnd,
    1121                               "Path does not exist",
    1122                               fodInfos->ofnInfos.lpstrTitle,
    1123                               MB_OK | MB_ICONEXCLAMATION);
    1124                   return FALSE;
    1125               }
    1126           }
    1127          
    1128           strcat(lpstrPathAndFile,lpstrPathSpec);
    1129           IShellFolder_Release(psfDesktop);
     1200      /* Browse to the right directory */
     1201      COMDLG32_SHGetDesktopFolder(&psfDesktop);
     1202      if((browsePidl = GetPidlFromName(psfDesktop,lpstrPathSpec)))
     1203      {
     1204          /* Browse to directory */
     1205          IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
     1206                     browsePidl,
     1207                     SBSP_ABSOLUTE);
     1208          COMDLG32_SHFree(browsePidl);
    11301209      }
    11311210      else
    11321211      {
    1133           strcat(lpstrPathAndFile,lpstrCurrentDir);
     1212          /* Path does not exist */
     1213          if(fodInfos->ofnInfos.Flags & OFN_PATHMUSTEXIST)
     1214          {
     1215          MessageBoxA(hwnd,
     1216                  "Path does not exist",
     1217                  fodInfos->ofnInfos.lpstrTitle,
     1218                  MB_OK | MB_ICONEXCLAMATION);
     1219          return FALSE;
     1220          }
     1221      }
     1222
     1223      strcat(lpstrPathAndFile,lpstrPathSpec);
     1224      IShellFolder_Release(psfDesktop);
     1225      }
     1226      else
     1227      {
     1228      strcat(lpstrPathAndFile,lpstrCurrentDir);
    11341229      }
    11351230
     
    11371232      COMDLG32_PathAddBackslashA(lpstrPathAndFile);
    11381233      strcat(lpstrPathAndFile,lpstrFileSpec);
    1139      
     1234
    11401235      /* Update the edit field */
    11411236      SetDlgItemTextA(hwnd,IDC_FILENAME,lpstrFileSpec);
    11421237      SendDlgItemMessageA(hwnd,IDC_FILENAME,EM_SETSEL,0,-1);
    1143      
     1238
    11441239      /* Don't go further if we dont have a file spec */
    11451240      if(!strlen(lpstrFileSpec) || !strcmp(lpstrFileSpec,lpstrPathSpec))
    1146           return FALSE;
    1147 
    1148       /* Time to check lpstrFileSpec         */ 
     1241      return FALSE;
     1242
     1243      /* Time to check lpstrFileSpec         */
    11491244      /* search => contains * or ?           */
    11501245      /* browse => contains a directory name */
     
    11601255         MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
    11611256
    1162           fodInfos->ShellInfos.lpstrCurrentFilter = (LPWSTR)MemAlloc((strlen(lpstrFileSpec)+1)*2);
    1163           lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter,
    1164                       (LPSTR)strlwr((LPSTR)lpstrFileSpec));
    1165      
     1257      fodInfos->ShellInfos.lpstrCurrentFilter = (LPWSTR)MemAlloc((strlen(lpstrFileSpec)+1)*2);
     1258      lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter,
     1259              (LPSTR)strlwr((LPSTR)lpstrFileSpec));
     1260
    11661261      IShellView_Refresh(fodInfos->Shell.FOIShellView);
    11671262
    1168           if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB,
    1169                                                        lpstrFileSpec)))
     1263      if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB,
     1264                               lpstrFileSpec)))
    11701265        CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB,iPos);
    11711266
     
    11751270      /* browse if the user specified a directory */
    11761271      if((browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder,
    1177                                        lpstrFileSpec)))
     1272                       lpstrFileSpec)))
    11781273    {
    11791274          ULONG  ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
    1180           IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder,
    1181                                        1,
    1182                                        &browsePidl,
    1183                                        &ulAttr);
    1184 
    1185           /* Browse to directory */
    1186           if(ulAttr)
     1275      int    nMsgBoxRet;
     1276      char   lpstrFileExist[MAX_PATH + 50];
     1277
     1278          IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder,
     1279                       1,
     1280                       &browsePidl,
     1281                       &ulAttr);
     1282
     1283      /* The file does exist, so ask the user if we should overwrite it */
     1284      if(fodInfos->ofnInfos.Flags & OFN_OVERWRITEPROMPT)
     1285      {
     1286        strcpy(lpstrFileExist, lpstrFileSpec);
     1287        strcat(lpstrFileExist, " already exists.\nDo you want to replace it?");
     1288
     1289        nMsgBoxRet = MessageBoxA(hwnd,
     1290                        lpstrFileExist,
     1291                        fodInfos->ofnInfos.lpstrTitle,
     1292                        MB_YESNO | MB_ICONEXCLAMATION);
     1293        if(nMsgBoxRet == IDNO) return FALSE;
     1294      }
     1295
     1296      /* Browse to directory */
     1297      if(ulAttr)
    11871298        {
    1188               if(FAILED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
    1189                                                    browsePidl,
    1190                                                    SBSP_RELATIVE)))
     1299          if(FAILED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
     1300                           browsePidl,
     1301                           SBSP_RELATIVE)))
    11911302        {
    1192                   if(fodInfos->ofnInfos.Flags & OFN_PATHMUSTEXIST)
     1303          if(fodInfos->ofnInfos.Flags & OFN_PATHMUSTEXIST)
    11931304        {
    1194                       MessageBoxA(hwnd,
    1195                                   "Path does not exist",
    1196                                   fodInfos->ofnInfos.lpstrTitle,
    1197                                   MB_OK | MB_ICONEXCLAMATION);
    1198                       COMDLG32_SHFree(browsePidl);
    1199                       return FALSE;
     1305              MessageBoxA(hwnd,
     1306                  "Path does not exist",
     1307                  fodInfos->ofnInfos.lpstrTitle,
     1308                  MB_OK | MB_ICONEXCLAMATION);
     1309              COMDLG32_SHFree(browsePidl);
     1310              return FALSE;
    12001311        }
    12011312    }
    1202               COMDLG32_SHFree(browsePidl);
    1203               return FALSE;
    1204     }
    1205           COMDLG32_SHFree(browsePidl);
     1313          COMDLG32_SHFree(browsePidl);
     1314          return FALSE;
     1315    }
     1316      COMDLG32_SHFree(browsePidl);
    12061317      }
    12071318      else
    12081319    {
    1209           /* File does not exist in current directory */
    1210 
    1211           /* The selected file does not exist */
     1320      /* File does not exist in current directory */
     1321
     1322      /* The selected file does not exist */
    12121323      /* Tell the user the selected does not exist */
    12131324      if(fodInfos->ofnInfos.Flags & OFN_FILEMUSTEXIST)
     
    12171328        char tmp[400];
    12181329
    1219               LoadStringA(COMDLG32_hInstance,
    1220                           IDS_FILENOTFOUND,
    1221                           lpstrNotFound,
    1222                           100);
    1223               LoadStringA(COMDLG32_hInstance,
    1224                           IDS_VERIFYFILE,
    1225                           lpstrMsg,
    1226                           100);
     1330          LoadStringA(COMMDLG_hInstance32,
     1331              IDS_FILENOTFOUND,
     1332              lpstrNotFound,
     1333              100);
     1334          LoadStringA(COMMDLG_hInstance32,
     1335              IDS_VERIFYFILE,
     1336              lpstrMsg,
     1337              100);
    12271338
    12281339        strcpy(tmp,fodInfos->ofnInfos.lpstrFile);
     
    12321343        strcat(tmp,lpstrMsg);
    12331344
    1234               MessageBoxA(hwnd,
    1235                           tmp,
    1236                           fodInfos->ofnInfos.lpstrTitle,
    1237                           MB_OK | MB_ICONEXCLAMATION);
    1238         return FALSE;
     1345          MessageBoxA(hwnd,
     1346              tmp,
     1347              fodInfos->ofnInfos.lpstrTitle,
     1348              MB_OK | MB_ICONEXCLAMATION);
     1349    return FALSE;
    12391350      }
    12401351      /* Ask the user if he wants to create the file*/
     
    12431354        char tmp[100];
    12441355
    1245         LoadStringA(COMDLG32_hInstance,IDS_CREATEFILE,tmp,100);
    1246 
    1247               if(IDYES == MessageBoxA(hwnd,tmp,fodInfos->ofnInfos.lpstrTitle,
    1248                                       MB_YESNO | MB_ICONQUESTION))
     1356        LoadStringA(COMMDLG_hInstance32,IDS_CREATEFILE,tmp,100);
     1357
     1358          if(IDYES == MessageBoxA(hwnd,tmp,fodInfos->ofnInfos.lpstrTitle,
     1359                      MB_YESNO | MB_ICONQUESTION))
    12491360        {
    12501361            /* Create the file, clean and exit */
     
    12521363            return EndDialog(hwnd,TRUE);
    12531364        }
    1254         return FALSE;       
     1365    return FALSE;
    12551366      }
    12561367    }
     
    12611372      if(!strrchr(lpstrPathAndFile,'.'))
    12621373      {
    1263           /* if the file has no extension, append the selected
    1264              extension of the filetype combo box */
    1265           int iExt;
    1266           LPSTR lpstrExt;
    1267           iExt = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB);
    1268           lpstrTemp = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iExt);
     1374          /* if the file has no extension, append the selected
     1375             extension of the filetype combo box */
     1376          int iExt;
     1377          LPSTR lpstrExt;
     1378          iExt = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB);
     1379          lpstrTemp = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iExt);
    12691380
    12701381          //SvL: Check pointer first
    12711382          if(lpstrTemp != (LPSTR)-1) {
    1272                 if((lpstrExt = strchr(lpstrTemp,';')))
    1273                 {
    1274                       int i = lpstrExt - lpstrTemp;
    1275                       lpstrExt = MemAlloc(i);
    1276                       strncpy(lpstrExt,&lpstrTemp[1],i-1);
    1277                 }
    1278                 else
    1279                 {
    1280                       lpstrExt = MemAlloc(strlen(lpstrTemp));
    1281                       strcpy(lpstrExt,&lpstrTemp[1]);
    1282                 }
    1283                  
    1284                 if(!strcmp(&lpstrExt[1],"*") && fodInfos->ofnInfos.lpstrDefExt)
    1285                 {
    1286                         lpstrExt = MemAlloc(strlen(fodInfos->ofnInfos.lpstrDefExt)+2);
    1287                         strcat(lpstrExt,".");
    1288                         strcat(lpstrExt,(LPSTR) fodInfos->ofnInfos.lpstrDefExt);
    1289                 }
    1290                 strcat(lpstrPathAndFile,lpstrExt);
    1291           }
     1383            if((lpstrExt = strchr(lpstrTemp,';')))
     1384            {
     1385              int i = lpstrExt - lpstrTemp;
     1386              lpstrExt = (LPSTR)MemAlloc(i);
     1387              strncpy(lpstrExt,&lpstrTemp[1],i-1);
     1388            }
     1389            else
     1390            {
     1391              lpstrExt = (LPSTR)MemAlloc(strlen(lpstrTemp));
     1392              strcpy(lpstrExt,&lpstrTemp[1]);
     1393            }
     1394
     1395            if(!strcmp(&lpstrExt[1],"*") && fodInfos->ofnInfos.lpstrDefExt)
     1396            {
     1397              lpstrExt = (LPSTR)MemAlloc(strlen(fodInfos->ofnInfos.lpstrDefExt)+2);
     1398              strcat(lpstrExt,".");
     1399              strcat(lpstrExt,(LPSTR) fodInfos->ofnInfos.lpstrDefExt);
     1400            }
     1401            strcat(lpstrPathAndFile,lpstrExt);
     1402        }
    12921403      }
    12931404      /* Check that size size of the file does not exceed buffer size */
    12941405      if(strlen(lpstrPathAndFile) > fodInfos->ofnInfos.nMaxFile)
    12951406      {
    1296           /* set error FNERR_BUFFERTOSMALL */
    1297           FILEDLG95_Clean(hwnd);
    1298           return EndDialog(hwnd,FALSE);
     1407      /* set error FNERR_BUFFERTOSMALL */
     1408      FILEDLG95_Clean(hwnd);
     1409          return EndDialog(hwnd,FALSE);
    12991410      }
    13001411      strcpy(fodInfos->ofnInfos.lpstrFile,lpstrPathAndFile);
     
    13021413      /* Set the lpstrFileTitle of the OPENFILENAME structure */
    13031414      if(fodInfos->ofnInfos.lpstrFileTitle)
    1304           strncpy(fodInfos->ofnInfos.lpstrFileTitle,
    1305                   lpstrFileSpec,
    1306                   fodInfos->ofnInfos.nMaxFileTitle);
    1307 
    1308       /* Check if the file is to be opened as read only */           
     1415          strncpy(fodInfos->ofnInfos.lpstrFileTitle,
     1416              lpstrFileSpec,
     1417              fodInfos->ofnInfos.nMaxFileTitle);
     1418
     1419      /* Check if the file is to be opened as read only */
    13091420      if(BST_CHECKED == SendDlgItemMessageA(hwnd,
    1310                                             IDC_OPENREADONLY,
    1311                                             BM_GETSTATE,0,0))
    1312           SetFileAttributesA(fodInfos->ofnInfos.lpstrFile,
    1313                              FILE_ATTRIBUTE_READONLY);
     1421                        IDC_OPENREADONLY,
     1422                        BM_GETSTATE,0,0))
     1423      SetFileAttributesA(fodInfos->ofnInfos.lpstrFile,
     1424                 FILE_ATTRIBUTE_READONLY);
    13141425
    13151426      /*  nFileExtension and nFileOffset of OPENFILENAME structure */
     
    13191430      fodInfos->ofnInfos.nFileExtension = lpstrTemp - fodInfos->ofnInfos.lpstrFile + 1;
    13201431
    1321    
     1432
    13221433    /* clean and exit */
    13231434    FILEDLG95_Clean(hwnd);
     
    13401451
    13411452  /*
    1342    * Initialisation of the FileOpenDialogInfos structure 
     1453   * Initialisation of the FileOpenDialogInfos structure
    13431454   */
    13441455
     
    13601471
    13611472  /* Construct the IShellBrowser interface */
    1362   fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd); 
    1363    
     1473  fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd);
     1474
    13641475  return NOERROR;
    13651476}
     
    13801491
    13811492  if(SUCCEEDED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView,
    1382                                         SVGIO_BACKGROUND,
    1383                                         &IID_IContextMenu,
    1384                                         (LPVOID*)&pcm)))
     1493                    SVGIO_BACKGROUND,
     1494                    &IID_IContextMenu,
     1495                    (LPVOID*)&pcm)))
    13851496  {
    13861497    ci.cbSize = sizeof(CMINVOKECOMMANDINFO);
     
    14191530 *      FILEDLG95_SHELL_NewFolder
    14201531 *
    1421  * Creates a new directory with New folder as name 
     1532 * Creates a new directory with New folder as name
    14221533 * If the function succeeds, the return value is nonzero.
    14231534 * FIXME: let the contextmenu (CMDSTR_NEWFOLDER) do this thing
     
    14671578 *      FILEDLG95_FILETYPE_Init
    14681579 *
    1469  * Initialisation of the file type combo box 
     1580 * Initialisation of the file type combo box
    14701581 */
    14711582static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
     
    15021613      if(!lpstrExt)
    15031614          break;
    1504      
     1615
    15051616      strcpy(lpstrExt,lpstrExtTmp);
    15061617
    15071618      iStrIndex += strlen(lpstrExt) +1;
    1508            
     1619
    15091620      /* Add the item at the end of the combo */
    15101621      CBAddString(fodInfos->DlgInfos.hwndFileTypeCB,lpstrTmp);
     
    15521663      lpstrFilter = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
    15531664                                             iItem);
    1554       if((INT)lpstrFilter != CB_ERR)
     1665      if(lpstrFilter)
    15551666      {
    15561667        fodInfos->ShellInfos.lpstrCurrentFilter = (LPWSTR)MemAlloc((strlen(lpstrFilter)+1)*2);
     
    16141725
    16151726}
    1616    
     1727
    16171728/***********************************************************************
    16181729 *      FILEDLG95_LOOKIN_Init
    16191730 *
    1620  * Initialisation of the look in combo box 
     1731 * Initialisation of the look in combo box
    16211732 */
    16221733static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo)
    16231734{
    1624   IShellFolder  *psfRoot, *psfDrives;
    1625   IEnumIDList   *lpeRoot, *lpeDrives;
    1626   LPITEMIDLIST  pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp;
    1627 
    1628   LookInInfos *liInfos = (LookInInfos*)MemAlloc(sizeof(LookInInfos));
     1735  IShellFolder  *psfRoot, *psfDrives;
     1736  IEnumIDList   *lpeRoot, *lpeDrives;
     1737  LPITEMIDLIST  pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp;
     1738
     1739  LookInInfos *liInfos = (LookInInfos *)MemAlloc(sizeof(LookInInfos));
    16291740
    16301741  TRACE("\n");
     
    16511762      while (S_OK == IEnumIDList_Next(lpeRoot, 1, &pidlTmp, NULL))
    16521763      {
    1653         FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
    1654 
    1655         /* special handling for CSIDL_DRIVES */
    1656         if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives))
    1657         {
    1658           if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives)))
    1659           {
    1660             /* enumerate the drives */
    1661             if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives)))
    1662             {
    1663               while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL))
    1664               {
    1665                 pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1);
    1666                 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND);
    1667                 COMDLG32_SHFree(pidlAbsTmp);
    1668                 COMDLG32_SHFree(pidlTmp1);
    1669               }
    1670               IEnumIDList_Release(lpeDrives);
    1671             }
    1672             IShellFolder_Release(psfDrives);
    1673           }
    1674         }
     1764    FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
     1765
     1766    /* special handling for CSIDL_DRIVES */
     1767    if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives))
     1768    {
     1769      if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives)))
     1770      {
     1771        /* enumerate the drives */
     1772        if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives)))
     1773        {
     1774          while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL))
     1775          {
     1776            pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1);
     1777            FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND);
     1778            COMDLG32_SHFree(pidlAbsTmp);
     1779            COMDLG32_SHFree(pidlTmp1);
     1780          }
     1781          IEnumIDList_Release(lpeDrives);
     1782        }
     1783        IShellFolder_Release(psfDrives);
     1784      }
     1785    }
    16751786        COMDLG32_SHFree(pidlTmp);
    16761787      }
     
    17181829  {
    17191830    ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
    1720                                                0,   
    1721                                                &sfi,   
    1722                                                sizeof (SHFILEINFOA),   
    1723                                                SHGFI_PIDL | SHGFI_SMALLICON |   
    1724                                                SHGFI_OPENICON | SHGFI_SYSICONINDEX    | 
    1725                                                SHGFI_DISPLAYNAME );   
     1831                                               0,
     1832                                               &sfi,
     1833                                               sizeof (SHFILEINFOA),
     1834                                               SHGFI_PIDL | SHGFI_SMALLICON |
     1835                                               SHGFI_OPENICON | SHGFI_SYSICONINDEX    |
     1836                                               SHGFI_DISPLAYNAME );
    17261837  }
    17271838  else
    17281839  {
    17291840    ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
    1730                                                   0, 
    1731                                                   &sfi, 
     1841                                                  0,
     1842                                                  &sfi,
    17321843                                                  sizeof (SHFILEINFOA),
    1733                                                   SHGFI_PIDL | SHGFI_SMALLICON | 
    1734                                                   SHGFI_SYSICONINDEX | 
     1844                                                  SHGFI_PIDL | SHGFI_SMALLICON |
     1845                                                  SHGFI_SYSICONINDEX |
    17351846                                                  SHGFI_DISPLAYNAME);
    17361847  }
     
    17551866    iIndentation = 0;
    17561867    ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
    1757                                                 0, 
    1758                                                 &sfi, 
    1759                                                 sizeof (SHFILEINFOA), 
    1760                                                 SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON 
     1868                                                0,
     1869                                                &sfi,
     1870                                                sizeof (SHFILEINFOA),
     1871                                                SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON
    17611872                                                | SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME  );
    17621873
     
    17801891  rectText.bottom = pDIStruct->rcItem.bottom;
    17811892
    1782  
     1893
    17831894  /* Draw the icon from the image list */
    17841895  COMDLG32_ImageList_Draw(ilItemImage,
    17851896                 sfi.iIcon,
    1786                  pDIStruct->hDC, 
    1787                  rectIcon.left, 
    1788                  rectIcon.top, 
    1789                  ILD_TRANSPARENT ); 
     1897                 pDIStruct->hDC,
     1898                 rectIcon.left,
     1899                 rectIcon.top,
     1900                 ILD_TRANSPARENT );
    17901901
    17911902  /* Draw the associated text */
     
    18141925    {
    18151926      LPSFOLDER tmpFolder;
    1816       int iItem; 
     1927      int iItem;
    18171928
    18181929      iItem = CBGetCurSel(fodInfos->DlgInfos.hwndLookInCB);
     
    18201931      if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,
    18211932                                               iItem)))
    1822         return FALSE;
     1933    return FALSE;
    18231934
    18241935
     
    18311942      break;
    18321943    }
    1833      
     1944
    18341945  }
    18351946  return FALSE;
     
    18461957  LPITEMIDLIST pidlNext;
    18471958  SHFILEINFOA sfi;
    1848   SFOLDER *tmpFolder = (SFOLDER*)MemAlloc(sizeof(SFOLDER));
     1959  SFOLDER *tmpFolder = (SFOLDER *)MemAlloc(sizeof(SFOLDER));
    18491960  LookInInfos *liInfos;
    18501961
     
    18531964  if(!(liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr)))
    18541965    return -1;
    1855    
     1966
    18561967  tmpFolder->m_iIndent = 0;
    18571968
     
    18701981  if(tmpFolder->m_iIndent > liInfos->iMaxIndentation)
    18711982    liInfos->iMaxIndentation = tmpFolder->m_iIndent;
    1872  
     1983
    18731984  COMDLG32_SHGetFileInfoA((LPSTR)pidl,
    18741985                  0,
    18751986                  &sfi,
    18761987                  sizeof(sfi),
    1877                   SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX 
     1988                  SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX
    18781989                  | SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_ATTRIBUTES);
    18791990
     
    19042015 *      FILEDLG95_LOOKIN_InsertItemAfterParent
    19052016 *
    1906  * Insert an item below its parent 
     2017 * Insert an item below its parent
    19072018 */
    19082019static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl)
    19092020{
    1910  
     2021
    19112022  LPITEMIDLIST pidlParent = GetParentPidl(pidl);
    19122023  int iParentPos;
     
    19632074    }
    19642075  }
    1965  
     2076
    19662077  CBSetCurSel(hwnd,iItemPos);
    19672078  liInfos->uSelectedItem = iItemPos;
     
    20572168 *      GetName
    20582169 *
    2059  * Get the pidl's display name (relative to folder) and 
     2170 * Get the pidl's display name (relative to folder) and
    20602171 * put it in lpstrFileName.
    2061  * 
     2172 *
    20622173 * Return NOERROR on success,
    20632174 * E_FAIL otherwise
     
    20822193  /* Get the display name of the pidl relative to the folder */
    20832194  if (SUCCEEDED(hRes = IShellFolder_GetDisplayNameOf(lpsf,
    2084                                                      pidl, 
    2085                                                      dwFlags, 
     2195                                                     pidl,
     2196                                                     dwFlags,
    20862197                                                     &str)))
    20872198  {
     
    20942205 *      GetShellFolderFromPidl
    20952206 *
    2096  * pidlRel is the item pidl relative 
     2207 * pidlRel is the item pidl relative
    20972208 * Return the IShellFolder of the absolute pidl
    20982209 */
     
    21102221      if(SUCCEEDED(IShellFolder_BindToObject(psfParent, pidlAbs, NULL, &IID_IShellFolder, (LPVOID*)&psf)))
    21112222      {
    2112         IShellFolder_Release(psfParent);
     2223    IShellFolder_Release(psfParent);
    21132224        return psf;
    21142225      }
     
    21332244  pidlParent = COMDLG32_PIDL_ILClone(pidl);
    21342245  COMDLG32_PIDL_ILRemoveLastID(pidlParent);
    2135      
     2246
    21362247  return pidlParent;
    21372248}
     
    21402251 *      GetPidlFromName
    21412252 *
    2142  * returns the pidl of the file name relative to folder 
     2253 * returns the pidl of the file name relative to folder
    21432254 * NULL if an error occured
    21442255 */
     
    21542265  if(!lpcstrFileName)
    21552266    return NULL;
    2156    
     2267
    21572268  MultiByteToWideChar(CP_ACP,
    2158                       MB_PRECOMPOSED,   
    2159                       lpcstrFileName, 
    2160                       -1, 
    2161                       (LPWSTR)lpwstrDirName, 
    2162                       MAX_PATH); 
     2269                      MB_PRECOMPOSED,
     2270                      lpcstrFileName,
     2271                      -1,
     2272                      (LPWSTR)lpwstrDirName,
     2273                      MAX_PATH);
    21632274
    21642275  IShellFolder_ParseDisplayName(psf,                                0,
     
    21672278                                             &ulEaten,
    21682279                                             &pidl,
    2169                                 NULL);   
     2280                                NULL);
    21702281
    21712282    return pidl;
     
    21972308/*
    21982309 * Memory allocation methods */
    2199 char *MemAlloc(UINT size)
    2200 {
    2201     return (char *)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,size);
     2310void *MemAlloc(UINT size)
     2311{
     2312    return HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,size);
    22022313}
    22032314
Note: See TracChangeset for help on using the changeset viewer.