Changeset 6645 for trunk/src


Ignore:
Timestamp:
Sep 5, 2001, 2:14:25 PM (24 years ago)
Author:
bird
Message:

Added $Id:$ keyword.

Location:
trunk/src
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comdlg32/colordlg.c

    r5583 r6645  
     1/* $Id: colordlg.c,v 1.4 2001-09-05 12:11:59 bird Exp $ */
    12/*
    23 * COMMDLG - Color Dialog
     
    7475 int nextuserdef;     /* next free place in user defined color array */
    7576 HDC hdcMem;        /* color graph used for BitBlt() */
    76  HBITMAP hbmMem;    /* color graph bitmap */   
     77 HBITMAP hbmMem;    /* color graph bitmap */
    7778 RECT fullsize;     /* original dialog window size */
    7879 UINT msetrgb;        /* # of SETRGBSTRING message (today not used)  */
     
    155156  /* lum */
    156157  case 'L': mmsum *= 120;              /* 0...61200=(255+255)*120 */
    157            result = mmsum / 255;        /* 0...240 */
    158            break;
     158       result = mmsum / 255;        /* 0...240 */
     159       break;
    159160  /* saturation */
    160161  case 'S': if (!mmsum)
    161             result = 0;
    162            else
    163             if (!mini || maxi == 255)
    164              result = 240;
    165            else
    166            {
    167             result = mmdif * 240;       /* 0...61200=255*240 */
    168             result /= (mmsum > 255 ? mmsum = 510 - mmsum : mmsum); /* 0..255 */
    169            }
    170            break;
     162        result = 0;
     163       else
     164        if (!mini || maxi == 255)
     165         result = 240;
     166       else
     167       {
     168        result = mmdif * 240;       /* 0...61200=255*240 */
     169        result /= (mmsum > 255 ? mmsum = 510 - mmsum : mmsum); /* 0..255 */
     170       }
     171       break;
    171172  /* hue */
    172173  case 'H': if (!mmdif)
    173             result = 160;
    174            else
    175            {
    176             if (maxi == r)
    177             {
    178              iresult = 40 * (g - b);       /* -10200 ... 10200 */
    179              iresult /= (int) mmdif;    /* -40 .. 40 */
    180              if (iresult < 0)
    181               iresult += 240;          /* 0..40 and 200..240 */
    182             }
    183             else
    184              if (maxi == g)
    185              {
    186               iresult = 40 * (b - r);
    187               iresult /= (int) mmdif;
    188               iresult += 80;           /* 40 .. 120 */
    189              }
    190              else
    191               if (maxi == b)
    192               {
    193                iresult = 40 * (r - g);
    194                iresult /= (int) mmdif;
    195                iresult += 160;         /* 120 .. 200 */
    196               }
    197             result = iresult;
    198            }
    199            break;
     174        result = 160;
     175       else
     176       {
     177        if (maxi == r)
     178        {
     179         iresult = 40 * (g - b);       /* -10200 ... 10200 */
     180         iresult /= (int) mmdif;    /* -40 .. 40 */
     181         if (iresult < 0)
     182          iresult += 240;          /* 0..40 and 200..240 */
     183        }
     184        else
     185         if (maxi == g)
     186         {
     187          iresult = 40 * (b - r);
     188          iresult /= (int) mmdif;
     189          iresult += 80;           /* 40 .. 120 */
     190         }
     191         else
     192          if (maxi == b)
     193          {
     194           iresult = 40 * (r - g);
     195           iresult /= (int) mmdif;
     196           iresult += 160;         /* 120 .. 200 */
     197          }
     198        result = iresult;
     199       }
     200       break;
    200201 }
    201202 return result;    /* is this integer arithmetic precise enough ? */
     
    249250 */
    250251static int CC_MouseCheckPredefColorArray( LCCPRIV lpp, HWND hDlg, int dlgitem, int rows, int cols,
    251             LPARAM lParam )
     252        LPARAM lParam )
    252253{
    253254 HWND hwnd;
     
    283284 */
    284285static int CC_MouseCheckUserColorArray( LCCPRIV lpp, HWND hDlg, int dlgitem, int rows, int cols,
    285             LPARAM lParam )
     286        LPARAM lParam )
    286287{
    287288 HWND hwnd;
     
    317318
    318319/*  240  ^......        ^^ 240
    319         |     .        ||
     320    |     .        ||
    320321    SAT  |     .        || LUM
    321         |     .        ||
    322         +-----> 239   ----
    323            HUE
     322    |     .        ||
     323    +-----> 239   ----
     324       HUE
    324325*/
    325326/***********************************************************************
     
    464465 RECT rect;
    465466 HWND hwnd = GetDlgItem(hDlg, 0x2be);
    466  LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER); 
     467 LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER);
    467468
    468469 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6)))   /* if full size */
     
    476477   ScreenToClient(hDlg, points);    /*  |<  |  */
    477478   oben = points[0].y;                 /*  | \ |  */
    478                                      /*  |  \|  */
     479                     /*  |  \|  */
    479480   temp = (long)height * (long)y;
    480481   points[0].y = oben + height - temp / (long)MAXVERT;
     
    502503 int w = GetDialogBaseUnits();
    503504 HWND hwnd = GetDlgItem(hDlg, 0x2c6);
    504  LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER ); 
     505 LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER );
    505506 RECT rect;
    506507 POINT point, p;
     
    524525   lpp->oldcross.right  = point.x + w + 1;
    525526   lpp->oldcross.top    = point.y - w - 1;
    526    lpp->oldcross.bottom = point.y + w + 1; 
    527 
    528    MoveToEx(hDC, point.x - w, point.y, &p); 
     527   lpp->oldcross.bottom = point.y + w + 1;
     528
     529   MoveToEx(hDC, point.x - w, point.y, &p);
    529530   LineTo(hDC, point.x + w, point.y);
    530    MoveToEx(hDC, point.x, point.y - w, &p); 
     531   MoveToEx(hDC, point.x, point.y - w, &p);
    531532   LineTo(hDC, point.x, point.y + w);
    532533   DeleteObject( SelectObject(hDC, hPen)) ;
     
    543544 *                    CC_PrepareColorGraph                    [internal]
    544545 */
    545 static void CC_PrepareColorGraph( HWND hDlg )   
     546static void CC_PrepareColorGraph( HWND hDlg )
    546547{
    547548 int sdif, hdif, xdif, ydif, r, g, b, hue, sat;
    548549 HWND hwnd = GetDlgItem(hDlg, 0x2c6);
    549  LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
     550 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
    550551 HBRUSH hbrush;
    551552 HDC hdc ;
     
    590591{
    591592 HWND hwnd = GetDlgItem( hDlg, 0x2c6 );
    592  LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
     593 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
    593594 HDC  hDC;
    594595 RECT rect;
     
    650651{
    651652 char buffer[10];
    652  LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
     653 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
    653654 int r = GetRValue(cr);
    654655 int g = GetGValue(cr);
     
    695696{
    696697 int i;
    697  LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
    698  
     698 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
     699
    699700 EnableWindow( GetDlgItem(hDlg, 0x2cf), FALSE);
    700701 CC_PrepareColorGraph(hDlg);
     
    743744 for ( j = 0; j < rows; j++ )
    744745 {
    745   for ( i = 0; i < cols; i++ ) 
     746  for ( i = 0; i < cols; i++ )
    746747  {
    747748   hBrush = CreateSolidBrush(predefcolors[j][i]);
     
    764765/***********************************************************************
    765766 *                             CC_PaintUserColorArray         [internal]
    766  *               Paint the 16 user-selected colors 
     767 *               Paint the 16 user-selected colors
    767768 */
    768769static void CC_PaintUserColorArray( HWND hDlg, int rows, int cols, COLORREF* lpcr )
     
    782783
    783784 hdc = GetDC(hwnd);
    784  if (hdc) 
     785 if (hdc)
    785786 {
    786787  FillRect(hdc, &rect, GetClassLongA(hwnd, GCL_HBRBACKGROUND) );
     
    791792    hBrush = CreateSolidBrush(lpcr[i+j*cols]);
    792793    if (hBrush)
    793     { 
     794    {
    794795     hBrush = SelectObject(hdc, hBrush) ;
    795796     Rectangle(hdc, rect.left, rect.top,
     
    826827 *                              CC_WMInitDialog                  [internal]
    827828 */
    828 static LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL b16 ) 
     829static LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL b16 )
    829830{
    830831   int i, res;
     
    833834   RECT rect;
    834835   POINT point;
    835    LCCPRIV lpp; 
    836    
     836   LCCPRIV lpp;
     837
    837838   TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
    838839   lpp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct CCPRIVATE) );
     
    851852       }
    852853       ch32->lStructSize = sizeof(CHOOSECOLORW);
    853        ch32->hwndOwner = ch16->hwndOwner; 
     854       ch32->hwndOwner = ch16->hwndOwner;
    854855       ch32->hInstance = ch16->hInstance;
    855856       ch32->lpCustColors = PTR_SEG_TO_LIN(ch16->lpCustColors);
     
    866867      return FALSE;
    867868   }
    868    SetWindowLongA(hDlg, DWL_USER, (LONG)lpp); 
     869   SetWindowLongA(hDlg, DWL_USER, (LONG)lpp);
    869870
    870871   if (!(lpp->lpcc->Flags & CC_SHOWHELP))
     
    876877   if (lpp->lpcc->Flags & CC_RGBINIT)
    877878   {
    878      for (i = 0; i < 6; i++) 
     879     for (i = 0; i < 6; i++)
    879880       for (j = 0; j < 8; j++)
    880881        if (predefcolors[i][j] == lpp->lpcc->rgbResult)
     
    930931          res = CallWindowProcA( (WNDPROC)lpp->lpcc->lpfnHook, hDlg, WM_INITDIALOG, wParam, lParam);
    931932   }
    932    
     933
    933934   /* Set the initial values of the color chooser dialog */
    934935   r = GetRValue(lpp->lpcc->rgbResult);
     
    959960 *                              CC_WMCommand                  [internal]
    960961 */
    961 static LRESULT CC_WMCommand( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl ) 
     962static LRESULT CC_WMCommand( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl )
    962963{
    963964    int  r, g, b, i, xx;
     
    965966    HDC hdc;
    966967    COLORREF *cr;
    967     LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
     968    LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
    968969    TRACE("CC_WMCommand wParam=%x lParam=%lx\n", wParam, lParam);
    969970    switch (wParam)
    970971    {
    971972          case 0x2c2:  /* edit notify RGB */
    972           case 0x2c3:
    973           case 0x2c4:
    974                if (notifyCode == EN_UPDATE && !lpp->updating)
    975                         {
    976                            i = CC_CheckDigitsInEdit(hwndCtl, 255);
    977                            r = GetRValue(lpp->lpcc->rgbResult);
    978                            g = GetGValue(lpp->lpcc->rgbResult);
    979                            b= GetBValue(lpp->lpcc->rgbResult);
    980                            xx = 0;
    981                            switch (wParam)
    982                            {
    983                             case 0x2c2: if ((xx = (i != r))) r = i; break;
    984                             case 0x2c3: if ((xx = (i != g))) g = i; break;
    985                             case 0x2c4: if ((xx = (i != b))) b = i; break;
    986                            }
    987                            if (xx) /* something has changed */
    988                            {
    989                             lpp->lpcc->rgbResult = RGB(r, g, b);
    990                             CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
    991                             lpp->h = CC_RGBtoHSL('H', r, g, b);
    992                             lpp->s = CC_RGBtoHSL('S', r, g, b);
    993                             lpp->l = CC_RGBtoHSL('L', r, g, b);
    994                             CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
    995                             CC_PaintCross(hDlg, lpp->h, lpp->s);
    996                             CC_PaintTriangle(hDlg, lpp->l);
    997                            }
    998                         }
    999                 break;
    1000                  
    1001           case 0x2bf:  /* edit notify HSL */
    1002           case 0x2c0:
    1003           case 0x2c1:
    1004                if (notifyCode == EN_UPDATE && !lpp->updating)
    1005                         {
    1006                            i = CC_CheckDigitsInEdit(hwndCtl , wParam == 0x2bf ? 239:240);
    1007                            xx = 0;
    1008                            switch (wParam)
    1009                            {
    1010                             case 0x2bf: if ((xx = ( i != lpp->h))) lpp->h = i; break;
    1011                             case 0x2c0: if ((xx = ( i != lpp->s))) lpp->s = i; break;
    1012                             case 0x2c1: if ((xx = ( i != lpp->l))) lpp->l = i; break;
    1013                            }
    1014                            if (xx) /* something has changed */
    1015                            {
    1016                             r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
    1017                             g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
    1018                             b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
    1019                             lpp->lpcc->rgbResult = RGB(r, g, b);
    1020                             CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
    1021                             CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
    1022                             CC_PaintCross(hDlg, lpp->h, lpp->s);
    1023                             CC_PaintTriangle(hDlg, lpp->l);
    1024                            }
    1025                         }
    1026                break;
    1027                
     973      case 0x2c3:
     974      case 0x2c4:
     975           if (notifyCode == EN_UPDATE && !lpp->updating)
     976            {
     977               i = CC_CheckDigitsInEdit(hwndCtl, 255);
     978               r = GetRValue(lpp->lpcc->rgbResult);
     979               g = GetGValue(lpp->lpcc->rgbResult);
     980               b= GetBValue(lpp->lpcc->rgbResult);
     981               xx = 0;
     982               switch (wParam)
     983               {
     984                case 0x2c2: if ((xx = (i != r))) r = i; break;
     985                case 0x2c3: if ((xx = (i != g))) g = i; break;
     986                case 0x2c4: if ((xx = (i != b))) b = i; break;
     987               }
     988               if (xx) /* something has changed */
     989               {
     990                lpp->lpcc->rgbResult = RGB(r, g, b);
     991                CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
     992                lpp->h = CC_RGBtoHSL('H', r, g, b);
     993                lpp->s = CC_RGBtoHSL('S', r, g, b);
     994                lpp->l = CC_RGBtoHSL('L', r, g, b);
     995                CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
     996                CC_PaintCross(hDlg, lpp->h, lpp->s);
     997                CC_PaintTriangle(hDlg, lpp->l);
     998               }
     999            }
     1000        break;
     1001
     1002      case 0x2bf:  /* edit notify HSL */
     1003      case 0x2c0:
     1004      case 0x2c1:
     1005           if (notifyCode == EN_UPDATE && !lpp->updating)
     1006            {
     1007               i = CC_CheckDigitsInEdit(hwndCtl , wParam == 0x2bf ? 239:240);
     1008               xx = 0;
     1009               switch (wParam)
     1010               {
     1011                case 0x2bf: if ((xx = ( i != lpp->h))) lpp->h = i; break;
     1012                case 0x2c0: if ((xx = ( i != lpp->s))) lpp->s = i; break;
     1013                case 0x2c1: if ((xx = ( i != lpp->l))) lpp->l = i; break;
     1014               }
     1015               if (xx) /* something has changed */
     1016               {
     1017                r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
     1018                g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
     1019                b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
     1020                lpp->lpcc->rgbResult = RGB(r, g, b);
     1021                CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
     1022                CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
     1023                CC_PaintCross(hDlg, lpp->h, lpp->s);
     1024                CC_PaintTriangle(hDlg, lpp->l);
     1025               }
     1026            }
     1027           break;
     1028
    10281029          case 0x2cf:
    10291030               CC_SwitchToFullSize(hDlg, lpp->lpcc->rgbResult, &lpp->fullsize);
    1030                SetFocus( GetDlgItem(hDlg, 0x2bf));
    1031                break;
     1031           SetFocus( GetDlgItem(hDlg, 0x2bf));
     1032           break;
    10321033
    10331034          case 0x2c8:    /* add colors ... column by column */
     
    10351036               cr[(lpp->nextuserdef % 2) * 8 + lpp->nextuserdef / 2] = lpp->lpcc->rgbResult;
    10361037               if (++lpp->nextuserdef == 16)
    1037                    lpp->nextuserdef = 0;
    1038                CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors);
    1039                break;
     1038           lpp->nextuserdef = 0;
     1039           CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors);
     1040           break;
    10401041
    10411042          case 0x2c9:              /* resulting color */
    1042                hdc = GetDC(hDlg);
    1043                lpp->lpcc->rgbResult = GetNearestColor(hdc, lpp->lpcc->rgbResult);
    1044                ReleaseDC(hDlg, hdc);
    1045                CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
    1046                CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
    1047                r = GetRValue(lpp->lpcc->rgbResult);
    1048                g = GetGValue(lpp->lpcc->rgbResult);
    1049                b = GetBValue(lpp->lpcc->rgbResult);
    1050                lpp->h = CC_RGBtoHSL('H', r, g, b);
    1051                lpp->s = CC_RGBtoHSL('S', r, g, b);
    1052                lpp->l = CC_RGBtoHSL('L', r, g, b);
    1053                CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
    1054                CC_PaintCross(hDlg, lpp->h, lpp->s);
    1055                CC_PaintTriangle(hDlg, lpp->l);
    1056                break;
    1057 
    1058           case 0x40e:           /* Help! */ /* The Beatles, 1965  ;-) */
    1059                i = RegisterWindowMessageA(HELPMSGSTRINGA);
     1043           hdc = GetDC(hDlg);
     1044           lpp->lpcc->rgbResult = GetNearestColor(hdc, lpp->lpcc->rgbResult);
     1045           ReleaseDC(hDlg, hdc);
     1046           CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
     1047           CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
     1048           r = GetRValue(lpp->lpcc->rgbResult);
     1049           g = GetGValue(lpp->lpcc->rgbResult);
     1050           b = GetBValue(lpp->lpcc->rgbResult);
     1051           lpp->h = CC_RGBtoHSL('H', r, g, b);
     1052           lpp->s = CC_RGBtoHSL('S', r, g, b);
     1053           lpp->l = CC_RGBtoHSL('L', r, g, b);
     1054           CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
     1055           CC_PaintCross(hDlg, lpp->h, lpp->s);
     1056           CC_PaintTriangle(hDlg, lpp->l);
     1057           break;
     1058
     1059      case 0x40e:           /* Help! */ /* The Beatles, 1965  ;-) */
     1060           i = RegisterWindowMessageA(HELPMSGSTRINGA);
    10601061#ifndef __WIN32OS2__
    10611062               if (lpp->lpcc16)
    10621063               {
    10631064                   if (lpp->lpcc->hwndOwner)
    1064                        SendMessage16(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc16);
     1065               SendMessage16(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc16);
    10651066                   if ( CC_HookCallChk(lpp->lpcc))
    1066                        CallWindowProc16( (WNDPROC16) lpp->lpcc16->lpfnHook, hDlg,
    1067                           WM_COMMAND, psh15, (LPARAM)lpp->lpcc16);
     1067               CallWindowProc16( (WNDPROC16) lpp->lpcc16->lpfnHook, hDlg,
     1068                  WM_COMMAND, psh15, (LPARAM)lpp->lpcc16);
    10681069               }
    10691070               else
     
    10711072#endif //!__WIN32OS2__
    10721073                   if (lpp->lpcc->hwndOwner)
    1073                        SendMessageA(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc);
     1074               SendMessageA(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc);
    10741075                   if ( CC_HookCallChk(lpp->lpcc))
    1075                        CallWindowProcA( (WNDPROC) lpp->lpcc->lpfnHook, hDlg,
    1076                           WM_COMMAND, psh15, (LPARAM)lpp->lpcc);
     1076               CallWindowProcA( (WNDPROC) lpp->lpcc->lpfnHook, hDlg,
     1077                  WM_COMMAND, psh15, (LPARAM)lpp->lpcc);
    10771078#ifndef __WIN32OS2__
    10781079               }
    10791080#endif //!__WIN32OS2__
    1080                break;
     1081           break;
    10811082
    10821083          case IDOK :
    1083                 cokmsg = RegisterWindowMessageA(COLOROKSTRINGA);
     1084        cokmsg = RegisterWindowMessageA(COLOROKSTRINGA);
    10841085#ifndef __WIN32OS2__
    10851086                if (lpp->lpcc16)
    10861087                {
    1087                     if (lpp->lpcc->hwndOwner)
    1088                         if (SendMessage16(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc16))
    1089                            break;    /* do NOT close */
     1088            if (lpp->lpcc->hwndOwner)
     1089            if (SendMessage16(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc16))
     1090               break;    /* do NOT close */
    10901091                }
    10911092                else
    10921093                {
    10931094#endif //!__WIN32OS2__
    1094                     if (lpp->lpcc->hwndOwner)
    1095                         if (SendMessageA(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc))
    1096                            break;    /* do NOT close */
     1095            if (lpp->lpcc->hwndOwner)
     1096            if (SendMessageA(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc))
     1097               break;    /* do NOT close */
    10971098#ifndef __WIN32OS2__
    10981099                }
     
    11041105                }
    11051106#endif
    1106                 EndDialog(hDlg, 1) ;
    1107                 return TRUE ;
    1108        
    1109           case IDCANCEL :
    1110                 EndDialog(hDlg, 0) ;
    1111                 return TRUE ;
     1107        EndDialog(hDlg, 1) ;
     1108        return TRUE ;
     1109
     1110      case IDCANCEL :
     1111        EndDialog(hDlg, 0) ;
     1112        return TRUE ;
    11121113
    11131114       }
     
    11181119 *                              CC_WMPaint                    [internal]
    11191120 */
    1120 static LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam ) 
     1121static LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam )
    11211122{
    11221123    HDC hdc;
    11231124    PAINTSTRUCT ps;
    1124     LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
     1125    LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
    11251126
    11261127    hdc = BeginPaint(hDlg, &ps);
     
    11511152       CC_PaintCross(hDlg, lpp->h, lpp->s);
    11521153       return 1;
    1153    } 
     1154   }
    11541155   return 0;
    11551156}
     
    11591160 *                              CC_WMMouseMove              [internal]
    11601161 */
    1161 static LRESULT CC_WMMouseMove( HWND hDlg, LPARAM lParam ) 
    1162 {
    1163    LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
     1162static LRESULT CC_WMMouseMove( HWND hDlg, LPARAM lParam )
     1163{
     1164   LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
    11641165   int r, g, b;
    11651166
     
    11671168   {
    11681169      int *ptrh = NULL, *ptrs = &lpp->l;
    1169       if (lpp->capturedGraph == 0x2c6) 
     1170      if (lpp->capturedGraph == 0x2c6)
    11701171      {
    11711172          ptrh = &lpp->h;
     
    11961197 *                              CC_WMLButtonDown              [internal]
    11971198 */
    1198 static LRESULT CC_WMLButtonDown( HWND hDlg, WPARAM wParam, LPARAM lParam ) 
    1199 {
    1200    LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
     1199static LRESULT CC_WMLButtonDown( HWND hDlg, WPARAM wParam, LPARAM lParam )
     1200{
     1201   LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
    12011202   int r, g, b, i;
    12021203   i = 0;
     
    12081209         i = 1;
    12091210      else
    1210         if (CC_MouseCheckColorGraph(hDlg, 0x2c6, &lpp->h, &lpp->s, lParam))
     1211    if (CC_MouseCheckColorGraph(hDlg, 0x2c6, &lpp->h, &lpp->s, lParam))
    12111212         {
    1212             i = 2;
     1213        i = 2;
    12131214            lpp->capturedGraph = 0x2c6;
    12141215         }
    1215         else
    1216             if (CC_MouseCheckColorGraph(hDlg, 0x2be, NULL, &lpp->l, lParam))
     1216    else
     1217        if (CC_MouseCheckColorGraph(hDlg, 0x2be, NULL, &lpp->l, lParam))
    12171218            {
    1218                i = 2;
     1219           i = 2;
    12191220               lpp->capturedGraph = 0x2be;
    12201221            }
     
    12761277
    12771278 switch (message)
    1278         {
    1279           case WM_INITDIALOG:
    1280                         return CC_WMInitDialog(hDlg, wParam, lParam, FALSE);
    1281           case WM_NCDESTROY:
    1282                         DeleteDC(lpp->hdcMem);
    1283                         DeleteObject(lpp->hbmMem);
     1279    {
     1280      case WM_INITDIALOG:
     1281                    return CC_WMInitDialog(hDlg, wParam, lParam, FALSE);
     1282      case WM_NCDESTROY:
     1283                    DeleteDC(lpp->hdcMem);
     1284                    DeleteObject(lpp->hbmMem);
    12841285                        HeapFree(GetProcessHeap(), 0, lpp);
    1285                         SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
    1286                         break;
    1287           case WM_COMMAND:
    1288                         if (CC_WMCommand( hDlg, wParam, lParam, HIWORD(wParam), (HWND) lParam))
    1289                            return TRUE;
    1290                         break;     
    1291           case WM_PAINT:
    1292                         if ( CC_WMPaint(hDlg, wParam, lParam))
    1293                            return TRUE;
    1294                         break;
    1295           case WM_LBUTTONDBLCLK:
    1296                         if (CC_MouseCheckResultWindow(hDlg, lParam))
    1297                           return TRUE;
    1298                         break;
    1299           case WM_MOUSEMOVE:
    1300                         if (CC_WMMouseMove(hDlg, lParam))
    1301                           return TRUE;
    1302                         break;
    1303           case WM_LBUTTONUP:  /* FIXME: ClipCursor off (if in color graph)*/
     1286                    SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
     1287                    break;
     1288      case WM_COMMAND:
     1289                    if (CC_WMCommand( hDlg, wParam, lParam, HIWORD(wParam), (HWND) lParam))
     1290                       return TRUE;
     1291                    break;
     1292      case WM_PAINT:
     1293                    if ( CC_WMPaint(hDlg, wParam, lParam))
     1294                       return TRUE;
     1295                    break;
     1296      case WM_LBUTTONDBLCLK:
     1297                    if (CC_MouseCheckResultWindow(hDlg, lParam))
     1298              return TRUE;
     1299            break;
     1300      case WM_MOUSEMOVE:
     1301                    if (CC_WMMouseMove(hDlg, lParam))
     1302              return TRUE;
     1303            break;
     1304      case WM_LBUTTONUP:  /* FIXME: ClipCursor off (if in color graph)*/
    13041305                        if (CC_WMLButtonUp(hDlg, wParam, lParam))
    13051306                           return TRUE;
    1306                         break;
    1307           case WM_LBUTTONDOWN:/* FIXME: ClipCursor on  (if in color graph)*/
    1308                         if (CC_WMLButtonDown(hDlg, wParam, lParam))
    1309                            return TRUE;
    1310                         break;     
    1311         }
     1307            break;
     1308      case WM_LBUTTONDOWN:/* FIXME: ClipCursor on  (if in color graph)*/
     1309                    if (CC_WMLButtonDown(hDlg, wParam, lParam))
     1310                       return TRUE;
     1311                    break;
     1312    }
    13121313     return FALSE ;
    13131314}
     
    13211322{
    13221323 int res;
    1323  LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER); 
     1324 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
    13241325 if (message != WM_INITDIALOG)
    13251326 {
     
    13391340
    13401341 switch (message)
    1341         {
    1342           case WM_INITDIALOG:
    1343                         return CC_WMInitDialog(hDlg, wParam, lParam, TRUE);
    1344           case WM_NCDESTROY:
    1345                         DeleteDC(lpp->hdcMem);
    1346                         DeleteObject(lpp->hbmMem);
     1342    {
     1343      case WM_INITDIALOG:
     1344                    return CC_WMInitDialog(hDlg, wParam, lParam, TRUE);
     1345      case WM_NCDESTROY:
     1346                    DeleteDC(lpp->hdcMem);
     1347                    DeleteObject(lpp->hbmMem);
    13471348                        HeapFree(GetProcessHeap(), 0, lpp->lpcc);
    13481349                        HeapFree(GetProcessHeap(), 0, lpp);
    1349                         SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
    1350                         break;
    1351           case WM_COMMAND:
    1352                         if (CC_WMCommand(hDlg, wParam, lParam, HIWORD(lParam), (HWND)LOWORD(lParam)))
    1353                            return TRUE;
    1354                         break;     
    1355           case WM_PAINT:
    1356                         if (CC_WMPaint(hDlg, wParam, lParam))
    1357                            return TRUE;
    1358                         break;
    1359           case WM_LBUTTONDBLCLK:
    1360                         if (CC_MouseCheckResultWindow(hDlg,lParam))
    1361                           return TRUE;
    1362                         break;
    1363           case WM_MOUSEMOVE:
    1364                         if (CC_WMMouseMove(hDlg, lParam))
    1365                           return TRUE;
    1366                         break;
    1367           case WM_LBUTTONUP:  /* FIXME: ClipCursor off (if in color graph)*/
     1350                    SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
     1351                    break;
     1352      case WM_COMMAND:
     1353                    if (CC_WMCommand(hDlg, wParam, lParam, HIWORD(lParam), (HWND)LOWORD(lParam)))
     1354                       return TRUE;
     1355                    break;
     1356      case WM_PAINT:
     1357                    if (CC_WMPaint(hDlg, wParam, lParam))
     1358                       return TRUE;
     1359                    break;
     1360      case WM_LBUTTONDBLCLK:
     1361                    if (CC_MouseCheckResultWindow(hDlg,lParam))
     1362              return TRUE;
     1363            break;
     1364      case WM_MOUSEMOVE:
     1365                    if (CC_WMMouseMove(hDlg, lParam))
     1366              return TRUE;
     1367            break;
     1368      case WM_LBUTTONUP:  /* FIXME: ClipCursor off (if in color graph)*/
    13681369                        if (CC_WMLButtonUp(hDlg, wParam, lParam))
    13691370                           return TRUE;
    1370                         break;
    1371           case WM_LBUTTONDOWN:/* FIXME: ClipCursor on  (if in color graph)*/
    1372                         if (CC_WMLButtonDown(hDlg, wParam, lParam))
    1373                            return TRUE;
    1374                         break;     
    1375         }
     1371            break;
     1372      case WM_LBUTTONDOWN:/* FIXME: ClipCursor on  (if in color graph)*/
     1373                    if (CC_WMLButtonDown(hDlg, wParam, lParam))
     1374                       return TRUE;
     1375                    break;
     1376    }
    13761377     return FALSE ;
    13771378}
     
    13901391    LPCVOID template;
    13911392    FARPROC16 ptr;
    1392  
     1393
    13931394    TRACE("ChooseColor\n");
    1394     if (!lpChCol) return FALSE;   
     1395    if (!lpChCol) return FALSE;
    13951396
    13961397    if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
     
    14151416    else
    14161417    {
    1417         HANDLE hResInfo, hDlgTmpl32;
     1418    HANDLE hResInfo, hDlgTmpl32;
    14181419        LPCVOID template32;
    14191420        DWORD size;
    1420         if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
    1421         {
    1422             COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    1423             return FALSE;
    1424         }
    1425         if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo)) ||
    1426             !(template32 = LockResource(hDlgTmpl32)))
    1427         {
    1428             COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    1429             return FALSE;
    1430         }
     1421    if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
     1422    {
     1423        COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     1424        return FALSE;
     1425    }
     1426    if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo)) ||
     1427        !(template32 = LockResource(hDlgTmpl32)))
     1428    {
     1429        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     1430        return FALSE;
     1431    }
    14311432        size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
    14321433        hGlobal16 = GlobalAlloc16(0, size);
     
    14381439        }
    14391440        template = GlobalLock16(hGlobal16);
    1440         if (!template) 
     1441        if (!template)
    14411442        {
    14421443            COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
     
    14751476
    14761477    TRACE("ChooseColor\n");
    1477     if (!lpChCol) return FALSE;   
     1478    if (!lpChCol) return FALSE;
    14781479
    14791480    if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
     
    15041505    else
    15051506    {
    1506         HANDLE hResInfo, hDlgTmpl;
    1507         if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
    1508         {
    1509             COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    1510             return FALSE;
    1511         }
    1512         if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
    1513             !(template = LockResource(hDlgTmpl)))
    1514         {
    1515             COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    1516             return FALSE;
    1517         }
     1507    HANDLE hResInfo, hDlgTmpl;
     1508    if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
     1509    {
     1510        COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     1511        return FALSE;
     1512    }
     1513    if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
     1514        !(template = LockResource(hDlgTmpl)))
     1515    {
     1516        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     1517        return FALSE;
     1518    }
    15181519    }
    15191520
     
    15411542  if ((lpcc->Flags & CC_ENABLETEMPLATE) && (lpChCol->lpTemplateName)) {
    15421543      if (HIWORD(lpChCol->lpTemplateName))
    1543           lpcc->lpTemplateName = HEAP_strdupAtoW(GetProcessHeap(), 0, lpChCol->lpTemplateName);
     1544      lpcc->lpTemplateName = HEAP_strdupAtoW(GetProcessHeap(), 0, lpChCol->lpTemplateName);
    15441545      else
    1545           lpcc->lpTemplateName = (LPWSTR)lpChCol->lpTemplateName;
     1546      lpcc->lpTemplateName = (LPWSTR)lpChCol->lpTemplateName;
    15461547  }
    15471548
  • trunk/src/comdlg32/filedlg.c

    r6315 r6645  
     1/* $Id: filedlg.c,v 1.6 2001-09-05 12:12:00 bird Exp $ */
    12/*
    23 * COMMDLG - File Dialogs
     
    2829#define GlobalLock16 GlobalLock
    2930#define GlobalUnlock16 GlobalUnlock
    30 #define GlobalAlloc16   GlobalAlloc
    31 #define FreeResource16  FreeResource
     31#define GlobalAlloc16   GlobalAlloc
     32#define FreeResource16  FreeResource
    3233#define LoadResource16  LoadResourceA
    3334#define FindResource16  FindResourceA
    34 #define MapSL(a)        a
     35#define MapSL(a)    a
    3536#define CallWindowProc16 CallWindowProcA
    3637
     
    4243
    4344#define BUFFILE 512
    44 #define BUFFILEALLOC 512 * sizeof(WCHAR)   
    45 
    46 struct FSPRIVATE 
     45#define BUFFILEALLOC 512 * sizeof(WCHAR)
     46
     47struct FSPRIVATE
    4748{
    4849    HWND hwnd; /* file dialog window handle */
     
    7576#define LFS32A 2
    7677#define LFS32W 3
    77  
     78
    7879static const WCHAR FILE_star[] = {'*','.','*', 0};
    7980static const WCHAR FILE_bslash[] = {'\\', 0};
     
    111112
    112113LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
    113                                 LPARAM lParam);
     114                LPARAM lParam);
    114115LRESULT WINAPI FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
    115                                 LPARAM lParam);
     116                LPARAM lParam);
    116117
    117118static LRESULT WINAPI FileOpenDlgProc(HWND hDlg, UINT msg,
     
    119120
    120121/***********************************************************************
    121  *                              FileDlg_Init                    [internal]
     122 *              FileDlg_Init            [internal]
    122123 */
    123124static BOOL FileDlg_Init(void)
     
    125126    static BOOL initialized = 0;
    126127    CURSORICONINFO *fldrInfo;
    127    
     128
    128129    if (!initialized) {
    129130#ifdef __WIN32OS2__
    130         if (!hFolder) hFolder = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER), IMAGE_ICON, 16, 16, LR_SHARED);
    131         if (!hFolder2) hFolder2 = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER2), IMAGE_ICON, 16, 16, LR_SHARED);
    132         if (!hFloppy) hFloppy = LoadImageA(0, MAKEINTRESOURCEA(OIC_FLOPPY), IMAGE_ICON, 16, 16, LR_SHARED);
    133         if (!hHDisk) hHDisk = LoadImageA(0, MAKEINTRESOURCEA(OIC_HDISK), IMAGE_ICON, 16, 16, LR_SHARED);
    134         if (!hCDRom) hCDRom = LoadImageA(0, MAKEINTRESOURCEA(OIC_CDROM), IMAGE_ICON, 16, 16, LR_SHARED);
    135         if (!hNet) hNet = LoadImageA(0, MAKEINTRESOURCEA(OIC_NETWORK), IMAGE_ICON, 16, 16, LR_SHARED);
     131    if (!hFolder) hFolder = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER), IMAGE_ICON, 16, 16, LR_SHARED);
     132    if (!hFolder2) hFolder2 = LoadImageA(0, MAKEINTRESOURCEA(OIC_FOLDER2), IMAGE_ICON, 16, 16, LR_SHARED);
     133    if (!hFloppy) hFloppy = LoadImageA(0, MAKEINTRESOURCEA(OIC_FLOPPY), IMAGE_ICON, 16, 16, LR_SHARED);
     134    if (!hHDisk) hHDisk = LoadImageA(0, MAKEINTRESOURCEA(OIC_HDISK), IMAGE_ICON, 16, 16, LR_SHARED);
     135    if (!hCDRom) hCDRom = LoadImageA(0, MAKEINTRESOURCEA(OIC_CDROM), IMAGE_ICON, 16, 16, LR_SHARED);
     136    if (!hNet) hNet = LoadImageA(0, MAKEINTRESOURCEA(OIC_NETWORK), IMAGE_ICON, 16, 16, LR_SHARED);
    136137#else
    137138        HINSTANCE inst = GetModuleHandleA( "comdlg32.dll" );
     
    148149        hNet     = LoadImageA( inst, "NETWORK", IMAGE_ICON, 16, 16, LR_SHARED );
    149150#endif
    150         if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
    151             hHDisk == 0 || hCDRom == 0 || hNet == 0)
    152         {
    153             ERR("Error loading icons !\n");
    154             return FALSE;
    155         }
     151    if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
     152        hHDisk == 0 || hCDRom == 0 || hNet == 0)
     153    {
     154        ERR("Error loading icons !\n");
     155        return FALSE;
     156    }
    156157#ifdef __WIN32OS2__
    157         fldrHeight = 16;
    158         fldrWidth = 16;
     158    fldrHeight = 16;
     159    fldrWidth = 16;
    159160#else
    160         fldrInfo = (CURSORICONINFO *) GlobalLock16( hFolder2 );
    161         if (!fldrInfo)
    162         {       
    163             ERR("Error measuring icons !\n");
    164             return FALSE;
    165         }
    166         fldrHeight = fldrInfo -> nHeight;
    167         fldrWidth = fldrInfo -> nWidth;
    168         GlobalUnlock16( hFolder2 );
    169 #endif
    170         initialized = TRUE;
     161    fldrInfo = (CURSORICONINFO *) GlobalLock16( hFolder2 );
     162    if (!fldrInfo)
     163    {
     164        ERR("Error measuring icons !\n");
     165        return FALSE;
     166    }
     167    fldrHeight = fldrInfo -> nHeight;
     168    fldrWidth = fldrInfo -> nWidth;
     169    GlobalUnlock16( hFolder2 );
     170#endif
     171    initialized = TRUE;
    171172    }
    172173    return TRUE;
     
    188189    if (ofnW->Flags & OFN_ENABLETEMPLATEHANDLE)
    189190    {
    190         if (!(lfs->template = LockResource( ofnW->hInstance )))
    191         {
    192             COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    193             return FALSE;
    194         }
     191    if (!(lfs->template = LockResource( ofnW->hInstance )))
     192    {
     193        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     194        return FALSE;
     195    }
    195196    }
    196197    else if (ofnW->Flags & OFN_ENABLETEMPLATE)
    197198    {
    198         HANDLE hResInfo;
     199    HANDLE hResInfo;
    199200        if (lfs->ofnA)
    200             hResInfo = FindResourceA(lfs->ofnA->hInstance,
    201                                 lfs->ofnA->lpTemplateName,
     201        hResInfo = FindResourceA(lfs->ofnA->hInstance,
     202                lfs->ofnA->lpTemplateName,
    202203                                 RT_DIALOGA);
    203204        else
    204             hResInfo = FindResourceW(ofnW->hInstance,
    205                                 ofnW->lpTemplateName,
     205        hResInfo = FindResourceW(ofnW->hInstance,
     206                ofnW->lpTemplateName,
    206207                                 RT_DIALOGW);
    207208        if (!hResInfo)
    208         {
    209             COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    210             return FALSE;
    211         }
    212         if (!(hDlgTmpl = LoadResource(ofnW->hInstance,
    213                                 hResInfo)) ||
    214                     !(lfs->template = LockResource(hDlgTmpl)))
    215         {
    216             COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    217             return FALSE;
    218         }
     209    {
     210        COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     211        return FALSE;
     212    }
     213    if (!(hDlgTmpl = LoadResource(ofnW->hInstance,
     214                hResInfo)) ||
     215            !(lfs->template = LockResource(hDlgTmpl)))
     216    {
     217        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     218        return FALSE;
     219    }
    219220    } else { /* get it from internal Wine resource */
    220         HANDLE hResInfo;
    221         if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
     221    HANDLE hResInfo;
     222    if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
    222223             lfs->open? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA)))
    223         {
    224             COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    225             return FALSE;
     224    {
     225        COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     226        return FALSE;
    226227        }
    227228        if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
     
    253254    else if (ofn16->Flags & OFN_ENABLETEMPLATE)
    254255    {
    255         HANDLE16 hResInfo;
    256         if (!(hResInfo = FindResource16(ofn16->hInstance,
    257                                         MapSL(ofn16->lpTemplateName),
     256    HANDLE16 hResInfo;
     257    if (!(hResInfo = FindResource16(ofn16->hInstance,
     258                    MapSL(ofn16->lpTemplateName),
    258259                                        RT_DIALOGA)))
    259         {
    260             COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    261             return FALSE;
    262         }
    263         if (!(lfs->hDlgTmpl16 = LoadResource16( ofn16->hInstance, hResInfo )))
    264         {
    265             COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    266             return FALSE;
    267         }
     260    {
     261        COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     262        return FALSE;
     263    }
     264    if (!(lfs->hDlgTmpl16 = LoadResource16( ofn16->hInstance, hResInfo )))
     265    {
     266        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     267        return FALSE;
     268    }
    268269        lfs->hResource16 = lfs->hDlgTmpl16;
    269270    }
    270271    else
    271272    { /* get resource from (32 bits) own Wine resource; convert it to 16 */
    272         HANDLE hResInfo, hDlgTmpl32;
     273    HANDLE hResInfo, hDlgTmpl32;
    273274        LPCVOID template32;
    274275        DWORD size;
    275276
    276         if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
     277    if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
    277278               lfs->open ? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA)))
    278         {
    279             COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
    280             return FALSE;
    281         }
    282         if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
    283             !(template32 = LockResource( hDlgTmpl32 )))
    284         {
    285             COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    286             return FALSE;
    287         }
     279    {
     280        COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
     281        return FALSE;
     282    }
     283    if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
     284        !(template32 = LockResource( hDlgTmpl32 )))
     285    {
     286        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     287        return FALSE;
     288    }
    288289        size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
    289290        hGlobal16 = GlobalAlloc16(0, size);
     
    321322    cp = strrchrW(temp, '\\');
    322323    if (cp != NULL) {
    323         strcpyW(temp, cp+1);
     324    strcpyW(temp, cp+1);
    324325    }
    325326    cp = strrchrW(temp, ':');
    326327    if (cp != NULL) {
    327         strcpyW(temp, cp+1);
     328    strcpyW(temp, cp+1);
    328329    }
    329330    /* FIXME: shouldn't we do something with the result here? ;-) */
     
    366367
    367368/***********************************************************************
    368  *                              FILEDLG_ScanDir                 [internal]
     369 *              FILEDLG_ScanDir                 [internal]
    369370 */
    370371static BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath)
    371372{
    372     WCHAR               buffer[BUFFILE];
    373     HWND                hdlg, hdlgDir;
     373    WCHAR       buffer[BUFFILE];
     374    HWND        hdlg, hdlgDir;
    374375    LRESULT             lRet = TRUE;
    375376    HCURSOR             hCursorWait, oldCursor;
     
    387388    /* list of files */
    388389    if ((hdlg = GetDlgItem(hWnd, lst1)) != 0) {
    389         WCHAR*  scptr; /* ptr on semi-colon */
    390         WCHAR*  filter = buffer;
    391 
    392         TRACE("Using filter %s\n", debugstr_w(filter));
    393         SendMessageW(hdlg, LB_RESETCONTENT, 0, 0);
    394         while (filter) {
    395             scptr = strchrW(filter, ';');
    396             if (scptr)  *scptr = 0;
     390        WCHAR*  scptr; /* ptr on semi-colon */
     391    WCHAR*  filter = buffer;
     392
     393    TRACE("Using filter %s\n", debugstr_w(filter));
     394    SendMessageW(hdlg, LB_RESETCONTENT, 0, 0);
     395    while (filter) {
     396        scptr = strchrW(filter, ';');
     397        if (scptr)  *scptr = 0;
    397398            while (*filter == ' ') filter++;
    398             TRACE("Using file spec %s\n", debugstr_w(filter));
    399             if (SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter) == LB_ERR)
    400                 return FALSE;
    401             if (scptr) *scptr = ';';
    402                 filter = (scptr) ? (scptr + 1) : 0;
    403         }
     399        TRACE("Using file spec %s\n", debugstr_w(filter));
     400        if (SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter) == LB_ERR)
     401            return FALSE;
     402        if (scptr) *scptr = ';';
     403            filter = (scptr) ? (scptr + 1) : 0;
     404    }
    404405    }
    405406
     
    416417
    417418/***********************************************************************
    418  *                              FILEDLG_GetFileType             [internal]
     419 *              FILEDLG_GetFileType     [internal]
    419420 */
    420421
     
    424425  i = 0;
    425426  if (cfptr)
    426     for ( ;(n = lstrlenW(cfptr)) != 0; i++) 
     427    for ( ;(n = lstrlenW(cfptr)) != 0; i++)
    427428      {
    428         cfptr += n + 1;
    429         if (i == index)
    430           return cfptr;
    431         cfptr += lstrlenW(cfptr) + 1;
     429    cfptr += n + 1;
     430    if (i == index)
     431      return cfptr;
     432    cfptr += lstrlenW(cfptr) + 1;
    432433      }
    433434  if (fptr)
    434     for ( ;(n = lstrlenW(fptr)) != 0; i++) 
     435    for ( ;(n = lstrlenW(fptr)) != 0; i++)
    435436      {
    436         fptr += n + 1;
    437         if (i == index)
    438           return fptr;
    439         fptr += lstrlenW(fptr) + 1;
     437    fptr += n + 1;
     438    if (i == index)
     439      return fptr;
     440    fptr += lstrlenW(fptr) + 1;
    440441    }
    441442  return (LPWSTR) FILE_star; /* FIXME */
     
    455456    {
    456457        if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) return FALSE;
    457         SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
     458    SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
    458459                      (LPARAM)str);
    459460
    460         if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
    461         {
    462             oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
    463             oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
    464         }
    465         if (savedlg)
    466             SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
    467 
    468         ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + 1,
     461    if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
     462    {
     463        oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
     464        oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
     465    }
     466    if (savedlg)
     467        SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
     468
     469    ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + 1,
    469470                  lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
    470471                  &(lpdis->rcItem), str, lstrlenW(str), NULL);
    471472
    472         if (lpdis->itemState & ODS_SELECTED)
    473             DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
    474 
    475         if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
    476         {
    477             SetBkColor( lpdis->hDC, oldBk );
    478             SetTextColor( lpdis->hDC, oldText );
    479         }
     473    if (lpdis->itemState & ODS_SELECTED)
     474        DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
     475
     476    if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
     477    {
     478        SetBkColor( lpdis->hDC, oldBk );
     479        SetTextColor( lpdis->hDC, oldText );
     480    }
    480481        HeapFree(GetProcessHeap(), 0, str);
    481         return TRUE;
     482    return TRUE;
    482483    }
    483484
     
    486487        if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
    487488            return FALSE;
    488         SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
     489    SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
    489490                      (LPARAM)str);
    490491
    491         if (lpdis->itemState & ODS_SELECTED)
    492         {
    493             oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
    494             oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
    495         }
    496         ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
     492    if (lpdis->itemState & ODS_SELECTED)
     493    {
     494        oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
     495        oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
     496    }
     497    ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
    497498                  lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
    498499                  &(lpdis->rcItem), str, lstrlenW(str), NULL);
    499500
    500         if (lpdis->itemState & ODS_SELECTED)
    501             DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
    502 
    503         if (lpdis->itemState & ODS_SELECTED)
    504         {
    505             SetBkColor( lpdis->hDC, oldBk );
    506             SetTextColor( lpdis->hDC, oldText );
    507         }
    508         DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder);
     501    if (lpdis->itemState & ODS_SELECTED)
     502        DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
     503
     504    if (lpdis->itemState & ODS_SELECTED)
     505    {
     506        SetBkColor( lpdis->hDC, oldBk );
     507        SetTextColor( lpdis->hDC, oldText );
     508    }
     509    DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder);
    509510        HeapFree(GetProcessHeap(), 0, str);
    510         return TRUE;
     511    return TRUE;
    511512    }
    512513    if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
     
    515516        if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
    516517            return FALSE;
    517         SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID,
     518    SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID,
    518519                      (LPARAM)str);
    519520        root[0] += str[2] - 'a';
     
    526527        default:           hIcon = hHDisk; break;
    527528        }
    528         if (lpdis->itemState & ODS_SELECTED)
    529         {
    530             oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
    531             oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
    532         }
    533         ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
     529    if (lpdis->itemState & ODS_SELECTED)
     530    {
     531        oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
     532        oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
     533    }
     534    ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
    534535                  lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
    535536                  &(lpdis->rcItem), str, lstrlenW(str), NULL);
    536537
    537         if (lpdis->itemState & ODS_SELECTED)
    538         {
    539             SetBkColor( lpdis->hDC, oldBk );
    540             SetTextColor( lpdis->hDC, oldText );
    541         }
    542         DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon);
     538    if (lpdis->itemState & ODS_SELECTED)
     539    {
     540        SetBkColor( lpdis->hDC, oldBk );
     541        SetTextColor( lpdis->hDC, oldText );
     542    }
     543    DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon);
    543544        HeapFree(GetProcessHeap(), 0, str);
    544         return TRUE;
     545    return TRUE;
    545546    }
    546547    return FALSE;
     
    550551 *                              FILEDLG_WMMeasureItem           [internal]
    551552 */
    552 static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam) 
     553static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
    553554{
    554555    LPMEASUREITEMSTRUCT lpmeasure;
    555    
     556
    556557    lpmeasure = (LPMEASUREITEMSTRUCT)lParam;
    557558    lpmeasure->itemHeight = fldrHeight;
     
    562563 */
    563564#ifdef __WIN32OS2__
    564 static LONG FILEDLG_WMMeasureItem16(HWND hWnd, WPARAM wParam, LPARAM lParam) 
     565static LONG FILEDLG_WMMeasureItem16(HWND hWnd, WPARAM wParam, LPARAM lParam)
    565566{
    566567    LPMEASUREITEMSTRUCT lpmeasure;
    567    
     568
    568569    lpmeasure = (LPMEASUREITEMSTRUCT)lParam;
    569570    lpmeasure->itemHeight = fldrHeight;
     
    571572}
    572573#else
    573 static LONG FILEDLG_WMMeasureItem16(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam) 
     574static LONG FILEDLG_WMMeasureItem16(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
    574575{
    575576    LPMEASUREITEMSTRUCT16 lpmeasure;
    576    
     577
    577578    lpmeasure = MapSL(lParam);
    578579    lpmeasure->itemHeight = fldrHeight;
     
    608609      TRACE("lpstrCustomFilter = %p\n", pstr);
    609610      while(*pstr)
    610         {
    611           old_pstr = pstr;
     611    {
     612      old_pstr = pstr;
    612613          i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
    613614                                   (LPARAM)(ofn->lpstrCustomFilter) + n );
    614615          n += lstrlenW(pstr) + 1;
    615           pstr += lstrlenW(pstr) + 1;
    616           TRACE("add str='%s' "
    617           "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr));
     616      pstr += lstrlenW(pstr) + 1;
     617      TRACE("add str='%s' "
     618      "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr));
    618619          SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
    619620          n += lstrlenW(pstr) + 1;
    620           pstr += lstrlenW(pstr) + 1;
    621         }
     621      pstr += lstrlenW(pstr) + 1;
     622    }
    622623    }
    623624  /* read filter information */
    624625  if (ofn->lpstrFilter) {
    625         pstr = (LPWSTR) ofn->lpstrFilter;
    626         n = 0;
    627         while(*pstr) {
    628           old_pstr = pstr;
    629           i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
    630                                        (LPARAM)(ofn->lpstrFilter + n) );
    631           n += lstrlenW(pstr) + 1;
    632           pstr += lstrlenW(pstr) + 1;
    633           TRACE("add str='%s' "
    634                   "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr));
    635           SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
    636           n += lstrlenW(pstr) + 1;
    637           pstr += lstrlenW(pstr) + 1;
    638         }
     626    pstr = (LPWSTR) ofn->lpstrFilter;
     627    n = 0;
     628    while(*pstr) {
     629      old_pstr = pstr;
     630      i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
     631                       (LPARAM)(ofn->lpstrFilter + n) );
     632      n += lstrlenW(pstr) + 1;
     633      pstr += lstrlenW(pstr) + 1;
     634      TRACE("add str='%s' "
     635          "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr));
     636      SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
     637      n += lstrlenW(pstr) + 1;
     638      pstr += lstrlenW(pstr) + 1;
     639    }
    639640  }
    640641  /* set default filter */
    641642  if (ofn->nFilterIndex == 0 && ofn->lpstrCustomFilter == NULL)
    642         ofn->nFilterIndex = 1;
    643   SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0);   
     643    ofn->nFilterIndex = 1;
     644  SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0);
    644645  lstrcpynW(tmpstr, FILEDLG_GetFileType(ofn->lpstrCustomFilter,
    645              (LPWSTR)ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE);
    646   TRACE("nFilterIndex = %ld, SetText of edt1 to '%s'\n", 
    647                         ofn->nFilterIndex, debugstr_w(tmpstr));
     646         (LPWSTR)ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE);
     647  TRACE("nFilterIndex = %ld, SetText of edt1 to '%s'\n",
     648            ofn->nFilterIndex, debugstr_w(tmpstr));
    648649  SetDlgItemTextW( hWnd, edt1, tmpstr );
    649650  /* get drive list */
     
    651652  DlgDirListComboBoxW(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE);
    652653  /* read initial directory */
    653   if (ofn->lpstrInitialDir != NULL) 
     654  if (ofn->lpstrInitialDir != NULL)
    654655    {
    655656      int len;
     
    690691      {
    691692          str[0] = 'a' + i;
    692           if(drives & (1 << i)) n++;
     693          if(drives & (1 << i)) n++;
    693694
    694695          if (toupper(str[0]) == toupper(dir[0])) break;
     
    720721/***********************************************************************
    721722 *                              FILEDLG_UpdateResult            [internal]
    722  *      update the displayed file name (with path) 
     723 *      update the displayed file name (with path)
    723724 */
    724725void FILEDLG_UpdateResult(LFSPRIVATE lfs, WCHAR *tmpstr)
     
    747748    if (lfs->ofn16)
    748749    { /* we have to convert to short (8.3) path */
    749         char tmp[1024]; /* MAX_PATHNAME_LEN */
    750         LPOPENFILENAME16 ofn16 = lfs->ofn16;
     750    char tmp[1024]; /* MAX_PATHNAME_LEN */
     751    LPOPENFILENAME16 ofn16 = lfs->ofn16;
    751752        char *dest = MapSL(ofn16->lpstrFile);
    752753        if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
    753754                                  tmp, ofnW->nMaxFile, NULL, NULL ))
    754755            tmp[ofnW->nMaxFile-1] = 0;
    755         GetShortPathNameA(tmp, dest, ofn16->nMaxFile);
    756 
    757         /* the same procedure as every year... */
     756    GetShortPathNameA(tmp, dest, ofn16->nMaxFile);
     757
     758    /* the same procedure as every year... */
    758759        ofn16->nFileOffset = strrchr(dest,'\\') - dest +1;
    759760        ofn16->nFileExtension = 0;
     
    779780/***********************************************************************
    780781 *                              FILEDLG_UpdateFileTitle         [internal]
    781  *      update the displayed file name (without path) 
     782 *      update the displayed file name (without path)
    782783 */
    783784void FILEDLG_UpdateFileTitle(LFSPRIVATE lfs)
     
    785786  LONG lRet;
    786787  LPOPENFILENAMEW ofnW = lfs->ofnW;
    787   if (ofnW->lpstrFileTitle != NULL) 
     788  if (ofnW->lpstrFileTitle != NULL)
    788789  {
    789790    lRet = SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETCURSEL, 0, 0);
     
    825826  pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC);
    826827  SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, lRet,
    827                      (LPARAM)pstr);
     828             (LPARAM)pstr);
    828829  strcpyW( tmpstr, pstr );
    829830  HeapFree(GetProcessHeap(), 0, pstr);
     
    897898    pBeginFileName = strrchrW(path, '\\');
    898899    if (pBeginFileName == NULL)
    899         pBeginFileName = strrchrW(path, ':');
     900    pBeginFileName = strrchrW(path, ':');
    900901
    901902    if (strchrW(path,'*') != NULL || strchrW(path,'?') != NULL)
     
    904905        if (pBeginFileName != NULL)
    905906        {
    906             lstrcpynW(tmpstr2, pBeginFileName + 1, BUFFILE);
    907             *(pBeginFileName + 1) = 0;
    908         }
    909         else
    910         {
    911             strcpyW(tmpstr2, path);
    912             *path = 0;
     907        lstrcpynW(tmpstr2, pBeginFileName + 1, BUFFILE);
     908        *(pBeginFileName + 1) = 0;
     909    }
     910    else
     911    {
     912        strcpyW(tmpstr2, path);
     913        *path = 0;
    913914        }
    914915
     
    997998        lRet = (BOOL)FILEDLG_CallWindowProc(lfs, lfs->fileokstring,
    998999                  0, lfs->lParam );
    999         if (lRet)       
     1000        if (lRet)
    10001001        {
    10011002            *ofnW = ofnsav; /* restore old state */
     
    10091010            LPWSTR str = (LPWSTR)ofnW->lpstrFile;
    10101011            LPWSTR ptr = strrchrW(str, '\\');
    1011             str[lstrlenW(str) + 1] = '\0';
    1012             *ptr = 0;
     1012        str[lstrlenW(str) + 1] = '\0';
     1013        *ptr = 0;
    10131014        }
    10141015    }
     
    10351036                         (LPARAM)pstr);
    10361037    wsprintfW(diskname, FILE_specc, pstr[2]);
    1037     HeapFree(GetProcessHeap(), 0, pstr);   
     1038    HeapFree(GetProcessHeap(), 0, pstr);
    10381039
    10391040    return FILEDLG_Validate( lfs, diskname, cmb2, lRet, TRUE );
     
    10671068 */
    10681069static LRESULT FILEDLG_WMCommand(HWND hWnd, LPARAM lParam, UINT notification,
    1069        UINT control, LFSPRIVATE lfs ) 
     1070       UINT control, LFSPRIVATE lfs )
    10701071{
    10711072    switch (control)
     
    10901091
    10911092        case cmb1: /* file type drop list */
    1092         if (notification == CBN_SELCHANGE) 
     1093        if (notification == CBN_SELCHANGE)
    10931094            return FILEDLG_FileTypeChange( lfs );
    10941095        break;
     
    12151216    if (ofnA->lpstrTitle)
    12161217        str = ofnA->lpstrTitle;
    1217     else 
     1218    else
    12181219        /* Allocates default title (FIXME : get it from resource) */
    12191220        str = open ? defaultopen:defaultsave;
     
    12721273/************************************************************************
    12731274 *                              FILEDLG_DestroyPrivate            [internal]
    1274  *      destroys the private object 
     1275 *      destroys the private object
    12751276 */
    12761277void FILEDLG_DestroyPrivate(LFSPRIVATE lfs)
     
    13111312/************************************************************************
    13121313 *                              FILEDLG_AllocPrivate            [internal]
    1313  *      allocate a private object to hold 32 bits Unicode 
     1314 *      allocate a private object to hold 32 bits Unicode
    13141315 *      structure that will be used throughtout the calls, while
    13151316 *      keeping available the original structures and a few variables
     
    13691370                FILEDLG_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open);
    13701371        }
    1371         else 
     1372        else
    13721373            ret = NULL;
    13731374    }
     
    13901391 * Creates a win31 style dialog box for the user to select a file to open/save.
    13911392 */
    1392 BOOL WINAPI GetFileName31A( 
     1393BOOL WINAPI GetFileName31A(
    13931394                           LPOPENFILENAMEA lpofn, /* addess of structure with data*/
    13941395                           UINT dlgType /* type dialogue : open/save */
     
    14051406    {
    14061407        hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
    1407         bRet = DialogBoxIndirectParamA( hInst, lfs->template, lpofn->hwndOwner, 
     1408        bRet = DialogBoxIndirectParamA( hInst, lfs->template, lpofn->hwndOwner,
    14081409             (DLGPROC) FileOpenDlgProc, (DWORD) lfs);
    14091410        FILEDLG_DestroyPrivate(lfs);
     
    14201421 * Creates a win31 style dialog box for the user to select a file to open/save
    14211422 */
    1422 BOOL WINAPI GetFileName31W( 
     1423BOOL WINAPI GetFileName31W(
    14231424                           LPOPENFILENAMEW lpofn, /* addess of structure with data*/
    14241425                           UINT dlgType /* type dialogue : open/save */
     
    14351436    {
    14361437        hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
    1437         bRet = DialogBoxIndirectParamW( hInst, lfs->template, lpofn->hwndOwner, 
     1438        bRet = DialogBoxIndirectParamW( hInst, lfs->template, lpofn->hwndOwner,
    14381439             (DLGPROC) FileOpenDlgProc, (DWORD) lfs);
    14391440        FILEDLG_DestroyPrivate(lfs);
     
    14531454LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
    14541455                               LPARAM lParam)
    1455 { 
     1456{
    14561457    LFSPRIVATE lfs = (LFSPRIVATE)GetPropA(hWnd,OFN_PROP);
    14571458    DRAWITEMSTRUCT dis;
    1458  
     1459
    14591460    TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam);
    14601461    if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
    14611462        {
    14621463            LRESULT lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
    1463             if (lRet)   
     1464            if (lRet)
    14641465                return lRet;         /* else continue message processing */
    14651466        }
     
    14831484         switch (HIWORD(lParam))
    14841485         {
    1485         case CTLCOLOR_BTN:
    1486              SetTextColor((HDC16)wParam, 0x00000000);
     1486    case CTLCOLOR_BTN:
     1487         SetTextColor((HDC16)wParam, 0x00000000);
    14871488             return hGRAYBrush;
    1488         case CTLCOLOR_STATIC:
     1489    case CTLCOLOR_STATIC:
    14891490             SetTextColor((HDC16)wParam, 0x00000000);
    14901491             return hGRAYBrush;
    1491         }
     1492    }
    14921493      break;
    14931494#endif
     
    15101511   LRESULT  lRet;
    15111512   lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
    1512    if (lRet)   
     1513   if (lRet)
    15131514    return lRet;         /* else continue message processing */
    1514   }             
     1515  }
    15151516  switch (wMsg) {
    15161517   case WM_INITDIALOG:
    15171518      return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
    1518      
     1519
    15191520   case WM_MEASUREITEM:
    15201521      return FILEDLG_WMMeasureItem16(hWnd, wParam, lParam);
    1521    
     1522
    15221523   case WM_DRAWITEM:
    15231524      FILEDLG_MapDrawItemStruct(MapSL(lParam), &dis);
     
    15271528      return FILEDLG_WMCommand(hWnd, lParam, HIWORD(lParam), wParam, lfs);
    15281529  }
    1529  
     1530
    15301531  /*
    15311532  case WM_CTLCOLOR:
     
    15411542   }
    15421543   return FALSE;
    1543    
     1544
    15441545   */
    15451546  return FALSE;
     
    15491550/***********************************************************************
    15501551 *           FileOpenDlgProc                                    [internal]
    1551  *      Used for open and save, in fact.   
     1552 *      Used for open and save, in fact.
    15521553 */
    15531554static LRESULT WINAPI FileOpenDlgProc(HWND hWnd, UINT wMsg,
     
    15611562            LRESULT lRet;
    15621563            lRet  = (BOOL)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
    1563             if (lRet)   
     1564            if (lRet)
    15641565                return lRet;         /* else continue message processing */
    15651566        }
     
    15821583         switch (HIWORD(lParam))
    15831584         {
    1584         case CTLCOLOR_BTN:
    1585              SetTextColor((HDC16)wParam, 0x00000000);
     1585    case CTLCOLOR_BTN:
     1586         SetTextColor((HDC16)wParam, 0x00000000);
    15861587             return hGRAYBrush;
    1587         case CTLCOLOR_STATIC:
     1588    case CTLCOLOR_STATIC:
    15881589             SetTextColor((HDC16)wParam, 0x00000000);
    15891590             return hGRAYBrush;
    1590         }
     1591    }
    15911592      break;
    15921593#endif
     
    15951596}
    15961597
    1597 /* ------------------ APIs ---------------------- */ 
     1598/* ------------------ APIs ---------------------- */
    15981599#ifndef __WIN32OS2__
    15991600/***********************************************************************
     
    16091610 *    unknown, there are some FIXME's left.
    16101611 */
    1611 BOOL16 WINAPI GetOpenFileName16( 
    1612                                 SEGPTR ofn /* [in/out] address of structure with data*/
    1613                                 )
     1612BOOL16 WINAPI GetOpenFileName16(
     1613                SEGPTR ofn /* [in/out] address of structure with data*/
     1614                )
    16141615{
    16151616    HINSTANCE hInst;
     
    16261627        hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
    16271628        ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 6);
    1628         bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner, 
     1629        bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner,
    16291630             (DLGPROC16) ptr, (DWORD) lfs);
    16301631        FILEDLG_DestroyPrivate(lfs);
     
    16471648 *    unknown. There are some FIXME's left.
    16481649 */
    1649 BOOL16 WINAPI GetSaveFileName16( 
    1650                                 SEGPTR ofn /* [in/out] addess of structure with data*/
    1651                                 )
     1650BOOL16 WINAPI GetSaveFileName16(
     1651                SEGPTR ofn /* [in/out] addess of structure with data*/
     1652                )
    16521653{
    16531654    HINSTANCE hInst;
     
    16641665        hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
    16651666        ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 7);
    1666         bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner, 
     1667        bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner,
    16671668             (DLGPROC16) ptr, (DWORD) lfs);
    16681669        FILEDLG_DestroyPrivate(lfs);
    1669     } 
     1670    }
    16701671
    16711672    TRACE("return lpstrFile='%s' !\n", (char *)MapSL(lpofn->lpstrFile));
     
    16851686 */
    16861687BOOL WINAPI GetOpenFileNameA(
    1687         LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
     1688    LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
    16881689{
    16891690    BOOL  newlook = TRUE; /* FIXME: TWEAK_WineLook */
     
    17211722 */
    17221723BOOL WINAPI GetOpenFileNameW(
    1723         LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
     1724    LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
    17241725{
    17251726    BOOL  newlook = TRUE; /* FIXME: TWEAK_WineLook */
     
    17571758 */
    17581759BOOL WINAPI GetSaveFileNameA(
    1759         LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
     1760    LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
    17601761{
    17611762    BOOL  newlook = TRUE; /* FIXME: TWEAK_WineLook */
     
    17751776    {
    17761777        return GetFileDialog95A(ofn, SAVE_DIALOG);
    1777     } 
     1778    }
    17781779    else
    17791780    {
     
    17931794 */
    17941795BOOL WINAPI GetSaveFileNameW(
    1795         LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
     1796    LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
    17961797{
    17971798    BOOL  newlook = TRUE; /* FIXME: TWEAK_WineLook */
     
    18111812    {
    18121813        return GetFileDialog95W(ofn, SAVE_DIALOG);
    1813     } 
     1814    }
    18141815    else
    18151816    {
  • trunk/src/comdlg32/filedlg95.c

    r6300 r6645  
     1/* $Id: filedlg95.c,v 1.24 2001-09-05 12:12:00 bird Exp $ */
    12/*
    23 * COMMDLG - File Open Dialogs Win95 look and feel
    34 *
    45 * FIXME: The whole concept of handling unicode is badly broken.
    5  *      many hook-messages expecting a pointer to a
    6  *      OPENFILENAMEA or W structure. With the current architecture
    7  *      we would have to convert the beast at every call to a hook.
    8  *      we have to find a better solution but if would likely cause
    9  *      a complete rewrite with after we shouldhandle the
    10  *      OPENFILENAME structure without any converting (jsch).
     6 *  many hook-messages expecting a pointer to a
     7 *  OPENFILENAMEA or W structure. With the current architecture
     8 *  we would have to convert the beast at every call to a hook.
     9 *  we have to find a better solution but if would likely cause
     10 *  a complete rewrite with after we shouldhandle the
     11 *  OPENFILENAME structure without any converting (jsch).
    1112 *
    1213 * FIXME: any hook gets a OPENFILENAMEA structure
     
    7778
    7879#define IsHooked(fodInfos) \
    79         ((fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook)
     80    ((fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook)
    8081/***********************************************************************
    8182 * Data structure and global variables
     
    8687  HIMAGELIST hImgList;
    8788  int m_iIndent;      /* Indentation index */
    88   LPITEMIDLIST pidlItem;  /* absolute pidl of the item */ 
     89  LPITEMIDLIST pidlItem;  /* absolute pidl of the item */
    8990
    9091} SFOLDER,*LPSFOLDER;
     
    216217 *      GetFileName95
    217218 *
    218  * Creates an Open common dialog box that lets the user select 
     219 * Creates an Open common dialog box that lets the user select
    219220 * the drive, directory, and the name of a file or set of files to open.
    220221 *
     
    251252        return FALSE;
    252253    }
    253    
     254
    254255    /* old style hook messages */
    255256    if (IsHooked(fodInfos))
     
    260261      fodInfos->HookMsg.sharevistring = RegisterWindowMessageA(SHAREVISTRINGA);
    261262    }
    262    
     263
    263264    lRes = DialogBoxIndirectParamA(COMMDLG_hInstance32,
    264265                                  (LPDLGTEMPLATEA) template,
     
    270271    if( lRes == -1)
    271272        return FALSE;
    272    
     273
    273274    return lRes;
    274275}
     
    291292  LPSTR lpstrSavDir = NULL;
    292293  DWORD dwFlags = 0;
    293  
    294   /* Initialise FileOpenDlgInfos structure*/ 
     294
     295  /* Initialise FileOpenDlgInfos structure*/
    295296  fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos));
    296297  ZeroMemory(fodInfos, sizeof(FileOpenDlgInfos));
    297  
     298
    298299  /* Pass in the original ofn */
    299300  fodInfos->ofnInfos = ofn;
    300  
     301
    301302  /* Save original hInstance value */
    302303  hInstance = ofn->hInstance;
     
    316317  fodInfos->DlgInfos.dwDlgProp = 0;
    317318  fodInfos->DlgInfos.hwndCustomDlg = (HWND)NULL;
    318  
     319
    319320  switch(iDlgType)
    320321  {
     
    400401  FileOpenDlgInfos *fodInfos;
    401402  HINSTANCE hInstance;
    402  
     403
    403404  /* out arguments */
    404405  LPWSTR lpstrFile = NULL;
     
    437438    /* filter is a list...  title\0ext\0......\0\0 */
    438439    s = ofn->lpstrFilter;
    439    
     440
    440441    while (*s) s = s+strlenW(s)+1;
    441442    s++;
     
    520521  }
    521522#endif
    522      
     523
    523524  /* restore saved IN arguments and convert OUT arguments back */
    524525  ofn->Flags = dwFlags;
     
    598599    SetWindowPos(hwndParentDlg, 0, rectParent.left,rectParent.top, (rectParent.right- rectParent.left),
    599600        (rectParent.bottom-rectParent.top),SWP_NOMOVE | SWP_NOZORDER);
    600        
     601
    601602    hwndChild = GetWindow(hwndChildDlg,GW_CHILD);
    602603    if(hwndStc32)
     
    615616        {
    616617          if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
    617                                 continue;
     618                continue;
    618619          GetWindowRect(hwndChild,&rectCtrl);
    619620          MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
    620                                  
     621
    621622          /*
    622623            Check the initial position of the controls relative to the initial
     
    629630          }
    630631          else if (rectCtrl.left >= rectTemp.right)
    631           {
     632      {
    632633            rectCtrl.left += ptMoveCtl.x;
    633           }
     634      }
    634635          else if (rectCtrl.top >= rectTemp.bottom)
    635636          {
    636             rectCtrl.top  += ptMoveCtl.y;
    637           }
    638                                        
    639           SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top, 
    640                                 rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
    641                                 SWP_NOSIZE | SWP_NOZORDER );
     637        rectCtrl.top  += ptMoveCtl.y;
     638      }
     639
     640          SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top,
     641                rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
     642                SWP_NOSIZE | SWP_NOZORDER );
    642643        }
    643644      } while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL);
    644645    }
    645646    hwndChild = GetWindow(hwndParentDlg,GW_CHILD);
    646        
     647
    647648    if(hwndStc32)
    648649    {
     
    665666            rectCtrl.top += ptMoveCtl.y;
    666667
    667             SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top, 
     668            SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top,
    668669                rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
    669670                SWP_NOSIZE |SWP_NOZORDER );
    670671          }
    671672        } while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL);
    672       }         
     673      }
    673674    }
    674675}
     
    686687    {
    687688      case WM_INITDIALOG:
    688       {         
     689      {
    689690        fodInfos = (FileOpenDlgInfos *)lParam;
    690691        lParam = (LPARAM) fodInfos->ofnInfos;
     
    693694        if(fodInfos && IsHooked(fodInfos))
    694695          return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam);
    695         return 0;       
    696       } 
     696        return 0;
     697      }
    697698    }
    698699
    699700    if(fodInfos && IsHooked(fodInfos))
    700       return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam); 
    701 
    702     return DefWindowProcA(hwnd,uMsg,wParam,lParam); 
     701      return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam);
     702
     703    return DefWindowProcA(hwnd,uMsg,wParam,lParam);
    703704}
    704705
     
    736737          COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    737738          return (HWND)NULL;
    738         }
     739        }
    739740      }
    740741
     
    742743      if(hChildDlg)
    743744      {
    744         ShowWindow(hChildDlg,SW_SHOW); 
     745        ShowWindow(hChildDlg,SW_SHOW);
    745746        return hChildDlg;
    746747      }
     
    758759      tmplate.cx = rectHwnd.right-rectHwnd.left;
    759760      tmplate.cy = rectHwnd.bottom-rectHwnd.top;
    760        
     761
    761762      return CreateDialogIndirectParamA(fodInfos->ofnInfos->hInstance,&tmplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
    762763    }
    763764    return (HWND)NULL;
    764765}
    765  
     766
    766767/***********************************************************************
    767768*          SendCustomDlgNotificationMessage
     
    784785    {
    785786        OFNOTIFYA ofnNotify;
    786         HRESULT ret;
     787    HRESULT ret;
    787788        ofnNotify.hdr.hwndFrom=hwndParentDlg;
    788789        ofnNotify.hdr.idFrom=0;
    789790        ofnNotify.hdr.code = uCode;
    790791        ofnNotify.lpOFN = fodInfos->ofnInfos;
    791         TRACE("CALL NOTIFY for %x\n", uCode);
    792         ret = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
    793         TRACE("RET NOTIFY\n");
    794         return ret;
     792    TRACE("CALL NOTIFY for %x\n", uCode);
     793    ret = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
     794    TRACE("RET NOTIFY\n");
     795    return ret;
    795796    }
    796797    return TRUE;
     
    815816            GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath));
    816817            lpstrFileSpec = (LPSTR)PathFindFileNameA(lpstrPath);
    817             if (lpstrFileSpec==lpstrPath) 
    818             {
     818            if (lpstrFileSpec==lpstrPath)
     819        {
    819820                char lpstrCurrentDir[MAX_PATH];
    820821                /* Prepend the current path */
     
    823824                    snprintf((LPSTR)lParam,(int)wParam,"%s\\%s",lpstrCurrentDir,lpstrPath);
    824825                reqSize=strlen(lpstrCurrentDir)+1+strlen(lpstrPath)+1;
    825             } 
    826             else
    827             {
     826            }
     827        else
     828        {
    828829                lstrcpynA((LPSTR)lParam,(LPSTR)lpstrPath,(int)wParam);
    829830                reqSize=strlen(lpstrPath);
     
    833834
    834835        case CDM_GETFOLDERPATH:
    835             SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
     836        SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
    836837            if ((LPSTR)lParam!=NULL)
    837838                lstrcpynA((LPSTR)lParam,lpstrPath,(int)wParam);
     
    839840
    840841        case CDM_GETSPEC:
    841             reqSize=GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath));
     842        reqSize=GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath));
    842843            lpstrFileSpec = (LPSTR)PathFindFileNameA(lpstrPath);
    843844            if ((LPSTR)lParam!=NULL)
     
    846847
    847848        case CDM_SETCONTROLTEXT:
    848             if ( 0 != lParam )
    849                 SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam );
    850             return TRUE;
     849        if ( 0 != lParam )
     850            SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam );
     851        return TRUE;
    851852
    852853        case CDM_HIDECONTROL:
     
    857858    return TRUE;
    858859}
    859  
     860
    860861/***********************************************************************
    861862 *          FileOpenDlgProc95
     
    868869  TRACE("0x%04x 0x%04x\n", hwnd, uMsg);
    869870#endif
    870  
     871
    871872  switch(uMsg)
    872873  {
     
    875876         FileOpenDlgInfos * fodInfos = (FileOpenDlgInfos *)lParam;
    876877
    877          /* Adds the FileOpenDlgInfos in the property list of the dialog
     878     /* Adds the FileOpenDlgInfos in the property list of the dialog
    878879            so it will be easily accessible through a GetPropA(...) */
    879         SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) fodInfos);
    880 
    881          fodInfos->DlgInfos.hwndCustomDlg =
    882            CreateTemplateDialog((FileOpenDlgInfos *)lParam, hwnd);
     880        SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) fodInfos);
     881
     882         fodInfos->DlgInfos.hwndCustomDlg =
     883           CreateTemplateDialog((FileOpenDlgInfos *)lParam, hwnd);
    883884
    884885         FILEDLG95_InitControls(hwnd);
    885886         SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE);
    886         FILEDLG95_FillControls(hwnd, wParam, lParam);
     887        FILEDLG95_FillControls(hwnd, wParam, lParam);
    887888         SendCustomDlgNotificationMessage(hwnd,CDN_SELCHANGE);
    888889         SetWindowPos(fodInfos->DlgInfos.hwndCustomDlg, HWND_BOTTOM,
     
    902903      }
    903904      return FALSE;
    904          
     905
    905906    case WM_GETISHELLBROWSER:
    906907      return FILEDLG95_OnWMGetIShellBrowser(hwnd);
     
    912913    case WM_NOTIFY:
    913914    {
    914         LPNMHDR lpnmh = (LPNMHDR)lParam;
    915         UINT stringId = -1;
    916 
    917         /* set up the button tooltips strings */
    918         if(TTN_GETDISPINFOA == lpnmh->code )
    919         {
    920             LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
    921             switch(lpnmh->idFrom )
    922             {
    923                 /* Up folder button */
    924                 case FCIDM_TB_UPFOLDER:
    925                     stringId = IDS_UPFOLDER;
    926                     break;
    927                 /* New folder button */
    928                 case FCIDM_TB_NEWFOLDER:
    929                     stringId = IDS_NEWFOLDER;
    930                     break;
    931                 /* List option button */
    932                 case FCIDM_TB_SMALLICON:
    933                     stringId = IDS_LISTVIEW;
    934                     break;
    935                 /* Details option button */
    936                 case FCIDM_TB_REPORTVIEW:
    937                     stringId = IDS_REPORTVIEW;
    938                     break;
    939                 /* Desktop button */
    940                 case FCIDM_TB_DESKTOP:
    941                     stringId = IDS_TODESKTOP;
    942                     break;
    943                 default:
    944                     stringId = 0;
    945             }
    946             lpdi->hinst = COMMDLG_hInstance32;
    947             lpdi->lpszText =  (LPSTR) stringId;
    948         }
     915    LPNMHDR lpnmh = (LPNMHDR)lParam;
     916    UINT stringId = -1;
     917
     918    /* set up the button tooltips strings */
     919    if(TTN_GETDISPINFOA == lpnmh->code )
     920    {
     921        LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
     922        switch(lpnmh->idFrom )
     923        {
     924        /* Up folder button */
     925        case FCIDM_TB_UPFOLDER:
     926            stringId = IDS_UPFOLDER;
     927            break;
     928        /* New folder button */
     929        case FCIDM_TB_NEWFOLDER:
     930            stringId = IDS_NEWFOLDER;
     931            break;
     932        /* List option button */
     933        case FCIDM_TB_SMALLICON:
     934            stringId = IDS_LISTVIEW;
     935            break;
     936        /* Details option button */
     937        case FCIDM_TB_REPORTVIEW:
     938            stringId = IDS_REPORTVIEW;
     939            break;
     940        /* Desktop button */
     941        case FCIDM_TB_DESKTOP:
     942            stringId = IDS_TODESKTOP;
     943            break;
     944        default:
     945            stringId = 0;
     946        }
     947        lpdi->hinst = COMMDLG_hInstance32;
     948        lpdi->lpszText =  (LPSTR) stringId;
     949    }
    949950        return FALSE;
    950951    }
     
    978979  {
    979980   { HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR },
    980    { COMDLG32_hInstance, 800 }                  // desktop icon
     981   { COMDLG32_hInstance, 800 }          // desktop icon
    981982  };
    982  
     983
    983984  RECT rectTB;
    984  
     985
    985986  FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
    986987
     
    996997  MapWindowPoints( 0, hwnd,(LPPOINT)&rectTB,2);
    997998
    998   fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, (LPSTR) NULL, 
     999  fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, (LPSTR) NULL,
    9991000        WS_CHILD | WS_GROUP | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NORESIZE,
    1000         0, 0, 150, 26, hwnd, (HMENU) IDC_TOOLBAR, COMMDLG_hInstance32, NULL); 
    1001  
    1002   SetWindowPos(fodInfos->DlgInfos.hwndTB, 0, 
    1003         rectTB.left,rectTB.top, rectTB.right-rectTB.left, rectTB.bottom-rectTB.top,
    1004         SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER );
     1001        0, 0, 150, 26, hwnd, (HMENU) IDC_TOOLBAR, COMMDLG_hInstance32, NULL);
     1002
     1003  SetWindowPos(fodInfos->DlgInfos.hwndTB, 0,
     1004    rectTB.left,rectTB.top, rectTB.right-rectTB.left, rectTB.bottom-rectTB.top,
     1005    SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER );
    10051006
    10061007  SendMessageA(fodInfos->DlgInfos.hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
     
    10121013
    10131014  SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSA, (WPARAM) 9,(LPARAM) &tbb);
    1014   SendMessageA(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0); 
     1015  SendMessageA(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0);
    10151016
    10161017  /* Set the window text with the text specified in the OPENFILENAME structure */
     
    10521053     are hidden and we are not using a custom template */
    10531054  if ( (fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY) &&
    1054        (!(fodInfos->ofnInfos->Flags & 
     1055       (!(fodInfos->ofnInfos->Flags &
    10551056         (OFN_SHOWHELP|OFN_ENABLETEMPLATE|OFN_ENABLETEMPLATEHANDLE))))
    10561057  {
     
    10611062    /* subtract the height of the help button plus the space between
    10621063       the help button and the cancel button to the height of the dialog */
    1063     SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left, 
    1064                  (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom), 
     1064    SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left,
     1065                 (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom),
    10651066                 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
    10661067  }
     
    10831084{
    10841085  LPITEMIDLIST pidlItemId = NULL;
    1085  
     1086
    10861087  FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) lParam;
    10871088
    1088   TRACE("dir=%s file=%s\n", 
     1089  TRACE("dir=%s file=%s\n",
    10891090  fodInfos->ofnInfos->lpstrInitialDir, fodInfos->ofnInfos->lpstrFile);
    10901091
     
    11871188  /* Do not use the listview selection anymore */
    11881189  fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW;
    1189   return 0; 
     1190  return 0;
    11901191}
    11911192
     
    12041205  SetWindowLongA(hwnd,DWL_MSGRESULT,(LONG)fodInfos->Shell.FOIShellBrowser);
    12051206
    1206   return TRUE; 
     1207  return TRUE;
    12071208}
    12081209
     
    12101211/***********************************************************************
    12111212 *      FILEDLG95_OnOpenMultipleFiles
    1212  *     
     1213 *
    12131214 * Handles the opening of multiple files.
    12141215 *
     
    12271228  lpstrFile = fodInfos->ofnInfos->lpstrFile;
    12281229  lpstrFile[0] = '\0';
    1229  
     1230
    12301231  SHGetPathFromIDListA( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
    12311232
     
    12331234      ( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST))
    12341235  {
    1235     LPSTR lpstrTemp = lpstrFileList; 
     1236    LPSTR lpstrTemp = lpstrFileList;
    12361237
    12371238    for ( nCount = 0; nCount < nFileCount; nCount++ )
     
    12581259        return FALSE;
    12591260      }
    1260  
     1261
    12611262      /* move to the next file in the list of files */
    12621263      lpstrTemp += strlen(lpstrTemp) + 1;
     
    12811282 *
    12821283 * Ok button WM_COMMAND message handler
    1283  * 
     1284 *
    12841285 * If the function succeeds, the return value is nonzero.
    12851286 */
     
    13221323      return FALSE;
    13231324  }
    1324  
     1325
    13251326  if(nFileCount > 1)
    13261327  {
     
    13811382  to a folder if the path points to a directory or the last
    13821383  valid element is a directory.
    1383  
     1384
    13841385  valid variables:
    13851386    lpstrPathAndFile: cleaned up path
     
    14311432                               lpwstrTemp, sizeof(lpwstrTemp)/sizeof(WCHAR) );
    14321433
    1433         /* if the last element is a wildcard do a search */
     1434    /* if the last element is a wildcard do a search */
    14341435        if(strpbrk(lpszTemp1, "*?") != NULL)
    14351436        {
    1436           nOpenAction = ONOPEN_SEARCH;
    1437           break;
    1438         }
     1437      nOpenAction = ONOPEN_SEARCH;
     1438      break;
     1439    }
    14391440      }
    14401441      lpszTemp1 = lpszTemp;
     
    14641465          TRACE("value\n");
    14651466
    1466           /* end dialog, return value */
     1467      /* end dialog, return value */
    14671468          nOpenAction = ONOPEN_OPEN;
    1468           break;
     1469      break;
    14691470        }
    1470         COMDLG32_SHFree(pidl);
    1471         pidl = NULL;
     1471    COMDLG32_SHFree(pidl);
     1472    pidl = NULL;
    14721473      }
    14731474      else
    14741475      {
    1475         if(*lpszTemp)   /* points to trailing null for last path element */
     1476    if(*lpszTemp)   /* points to trailing null for last path element */
    14761477        {
    1477           if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST)
    1478           {
     1478      if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST)
     1479      {
    14791480            FILEDLG95_OnOpenMessage(hwnd, 0, IDS_PATHNOTEXISTING);
    1480             break;
    1481           }
    1482         }
     1481        break;
     1482      }
     1483    }
    14831484        else
    1484         {
     1485    {
    14851486          if(fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST)
    1486           {
     1487      {
    14871488            FILEDLG95_OnOpenMessage(hwnd, 0, IDS_FILENOTEXISTING);
    1488             break;
    1489           }
    1490         }
    1491         /* change to the current folder */
     1489        break;
     1490      }
     1491    }
     1492    /* change to the current folder */
    14921493        nOpenAction = ONOPEN_OPEN;
    1493         break;
     1494    break;
    14941495      }
    14951496    }
     
    15271528        /* replace the current filter */
    15281529        if(fodInfos->ShellInfos.lpstrCurrentFilter)
    1529           MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
     1530      MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
    15301531        len = MultiByteToWideChar( CP_ACP, 0, lpszTemp, -1, NULL, 0 );
    15311532        fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc(len * sizeof(WCHAR));
     
    15411542      TRACE("ONOPEN_BROWSE\n");
    15421543      {
    1543         IPersistFolder2 * ppf2;
     1544    IPersistFolder2 * ppf2;
    15441545        if(SUCCEEDED(IShellFolder_QueryInterface( lpsf, &IID_IPersistFolder2, (LPVOID*)&ppf2)))
    15451546        {
     
    15471548          IPersistFolder2_GetCurFolder(ppf2, &pidlCurrent);
    15481549          IPersistFolder2_Release(ppf2);
    1549           if( ! COMDLG32_PIDL_ILIsEqual(pidlCurrent, fodInfos->ShellInfos.pidlAbsCurrent))
    1550           {
    1551             IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE);
    1552           }
    1553           else if( nOpenAction == ONOPEN_SEARCH )
    1554           {
     1550      if( ! COMDLG32_PIDL_ILIsEqual(pidlCurrent, fodInfos->ShellInfos.pidlAbsCurrent))
     1551      {
     1552        IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE);
     1553      }
     1554      else if( nOpenAction == ONOPEN_SEARCH )
     1555      {
    15551556            IShellView_Refresh(fodInfos->Shell.FOIShellView);
    1556           }
     1557      }
    15571558          COMDLG32_SHFree(pidlCurrent);
    15581559        }
     
    15631564      TRACE("ONOPEN_OPEN %s\n", lpstrPathAndFile);
    15641565      {
    1565         /* add default extension */
    1566         if (fodInfos->ofnInfos->lpstrDefExt)
    1567         {
    1568           if (! *PathFindExtensionA(lpstrPathAndFile))
    1569           {
    1570             strcat(lpstrPathAndFile, ".");
    1571             strcat(lpstrPathAndFile, fodInfos->ofnInfos->lpstrDefExt);
    1572           }
    1573         }
     1566    /* add default extension */
     1567    if (fodInfos->ofnInfos->lpstrDefExt)
     1568    {
     1569      if (! *PathFindExtensionA(lpstrPathAndFile))
     1570      {
     1571        strcat(lpstrPathAndFile, ".");
     1572        strcat(lpstrPathAndFile, fodInfos->ofnInfos->lpstrDefExt);
     1573      }
     1574    }
    15741575
    15751576        /* Check that the size of the file does not exceed buffer size.
     
    15791580        {
    15801581          LPSTR lpszTemp;
    1581          
     1582
    15821583          /* fill destination buffer */
    15831584          strcpy(fodInfos->ofnInfos->lpstrFile, lpstrPathAndFile);
     
    15891590          lpszTemp = PathFindFileNameA(lpstrPathAndFile);
    15901591          fodInfos->ofnInfos->nFileOffset = lpszTemp - lpstrPathAndFile;
    1591  
     1592
    15921593          /* set extension offset */
    15931594          lpszTemp = PathFindExtensionA(lpstrPathAndFile);
    15941595          fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? lpszTemp - lpstrPathAndFile + 1 : 0;
    1595    
     1596
    15961597          /* set the lpstrFileTitle */
    15971598          if(fodInfos->ofnInfos->lpstrFileTitle)
    1598           {
     1599      {
    15991600            LPSTR lpstrFileTitle = PathFindFileNameA(lpstrPathAndFile);
    1600             strncpy(fodInfos->ofnInfos->lpstrFileTitle, lpstrFileTitle, fodInfos->ofnInfos->nMaxFileTitle);
    1601           }
     1601        strncpy(fodInfos->ofnInfos->lpstrFileTitle, lpstrFileTitle, fodInfos->ofnInfos->nMaxFileTitle);
     1602      }
    16021603
    16031604          /* ask the hook if we can close */
    16041605          if(IsHooked(fodInfos))
    1605           {
    1606             /* FIXME we are sending ASCII-structures. Does not work with NT */
    1607             /* first old style */
    1608             TRACE("---\n");
     1606      {
     1607        /* FIXME we are sending ASCII-structures. Does not work with NT */
     1608        /* first old style */
     1609        TRACE("---\n");
    16091610            CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,
    16101611                            fodInfos->DlgInfos.hwndCustomDlg,
    16111612                            fodInfos->HookMsg.fileokstring, 0, (LPARAM)fodInfos->ofnInfos);
    1612             if (GetWindowLongA(hwnd, DWL_MSGRESULT))
    1613             {
    1614               TRACE("cancled\n");
    1615               ret = FALSE;
    1616               goto ret;
    1617             }
    1618           }
     1613        if (GetWindowLongA(hwnd, DWL_MSGRESULT))
     1614        {
     1615          TRACE("cancled\n");
     1616          ret = FALSE;
     1617          goto ret;
     1618        }
     1619      }
    16191620
    16201621          TRACE("close\n");
    1621           FILEDLG95_Clean(hwnd);
     1622      FILEDLG95_Clean(hwnd);
    16221623          ret = EndDialog(hwnd, TRUE);
    1623         }
    1624         else
     1624    }
     1625    else
    16251626        {
    16261627          /* FIXME set error FNERR_BUFFERTOSMALL */
     
    16501651
    16511652  /*
    1652    * Initialisation of the FileOpenDialogInfos structure 
     1653   * Initialisation of the FileOpenDialogInfos structure
    16531654   */
    16541655
     
    16611662  if (!(fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT))
    16621663  {
    1663      fodInfos->ShellInfos.folderSettings.fFlags |= FWF_SINGLESEL; 
     1664     fodInfos->ShellInfos.folderSettings.fFlags |= FWF_SINGLESEL;
    16641665  }
    16651666  fodInfos->ShellInfos.folderSettings.fFlags |= FWF_AUTOARRANGE | FWF_ALIGNLEFT;
     
    16711672
    16721673  /* Construct the IShellBrowser interface */
    1673   fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd); 
    1674    
     1674  fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd);
     1675
    16751676  return NOERROR;
    16761677}
     
    16901691
    16911692  if(SUCCEEDED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView,
    1692                                         SVGIO_BACKGROUND,
    1693                                         &IID_IContextMenu,
    1694                                         (LPVOID*)&pcm)))
     1693                    SVGIO_BACKGROUND,
     1694                    &IID_IContextMenu,
     1695                    (LPVOID*)&pcm)))
    16951696  {
    16961697    CMINVOKECOMMANDINFO ci;
     
    17391740  LPITEMIDLIST pidl;
    17401741  HRESULT hres;
    1741  
     1742
    17421743  TRACE("\n");
    17431744
     
    17721773 *      FILEDLG95_FILETYPE_Init
    17731774 *
    1774  * Initialisation of the file type combo box 
     1775 * Initialisation of the file type combo box
    17751776 */
    17761777static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
     
    17821783  if(fodInfos->ofnInfos->lpstrFilter)
    17831784  {
    1784     int nFilters = 0;   /* number of filters */
     1785    int nFilters = 0;   /* number of filters */
    17851786    LPSTR lpstrFilter;
    17861787    LPCSTR lpstrPos = fodInfos->ofnInfos->lpstrFilter;
     
    17881789    for(;;)
    17891790    {
    1790       /* filter is a list...  title\0ext\0......\0\0 
     1791      /* filter is a list...  title\0ext\0......\0\0
    17911792       * Set the combo item text to the title and the item data
    17921793       *  to the ext
     
    17961797
    17971798      /* Get the title */
    1798       if(! *lpstrPos) break;    /* end */
     1799      if(! *lpstrPos) break;    /* end */
    17991800      lpstrDisplay = lpstrPos;
    18001801      lpstrPos += strlen(lpstrPos) + 1;
    18011802
    18021803      /* Copy the extensions */
    1803       if (! *lpstrPos) return E_FAIL;   /* malformed filter */
     1804      if (! *lpstrPos) return E_FAIL;   /* malformed filter */
    18041805      if (!(lpstrExt = (LPSTR) MemAlloc(strlen(lpstrPos)+1))) return E_FAIL;
    18051806      strcpy(lpstrExt,lpstrPos);
    18061807      lpstrPos += strlen(lpstrPos) + 1;
    1807            
     1808
    18081809      /* Add the item at the end of the combo */
    18091810      CBAddString(fodInfos->DlgInfos.hwndFileTypeCB, lpstrDisplay);
     
    18161817     * FIXME: lpstrCustomFilter not handled at all
    18171818     */
    1818  
     1819
    18191820    /* set default filter index */
    18201821    if(fodInfos->ofnInfos->nFilterIndex == 0 && fodInfos->ofnInfos->lpstrCustomFilter == NULL)
     
    18241825    if ( fodInfos->ofnInfos->nFilterIndex > nFilters )
    18251826      fodInfos->ofnInfos->nFilterIndex = nFilters;
    1826  
     1827
    18271828    /* Set the current index selection. */
    18281829    CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, fodInfos->ofnInfos->nFilterIndex-1);
    1829  
     1830
    18301831    /* Get the corresponding text string from the combo box. */
    18311832    lpstrFilter = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
     
    18331834
    18341835    if ((INT)lpstrFilter == CB_ERR)  /* control is empty */
    1835       lpstrFilter = NULL;       
     1836      lpstrFilter = NULL;
    18361837
    18371838    if(lpstrFilter)
    18381839    {
    18391840      DWORD len;
    1840       _strlwr(lpstrFilter);     /* lowercase */
     1841      _strlwr(lpstrFilter); /* lowercase */
    18411842      len = MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1, NULL, 0 );
    18421843      fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) );
     
    19421943
    19431944}
    1944    
     1945
    19451946/***********************************************************************
    19461947 *      FILEDLG95_LOOKIN_Init
    19471948 *
    1948  * Initialisation of the look in combo box 
     1949 * Initialisation of the look in combo box
    19491950 */
    19501951static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo)
    19511952{
    1952   IShellFolder  *psfRoot, *psfDrives;
    1953   IEnumIDList   *lpeRoot, *lpeDrives;
    1954   LPITEMIDLIST  pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp;
     1953  IShellFolder  *psfRoot, *psfDrives;
     1954  IEnumIDList   *lpeRoot, *lpeDrives;
     1955  LPITEMIDLIST  pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp;
    19551956
    19561957  LookInInfos *liInfos = MemAlloc(sizeof(LookInInfos));
     
    19821983      while (S_OK == IEnumIDList_Next(lpeRoot, 1, &pidlTmp, NULL))
    19831984      {
    1984         FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
    1985 
    1986         /* special handling for CSIDL_DRIVES */
    1987         if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives))
    1988         {
    1989           if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives)))
    1990           {
    1991             /* enumerate the drives */
    1992             if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives)))
    1993             {
    1994               while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL))
    1995               {
    1996                 pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1);
    1997                 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND);
    1998                 COMDLG32_SHFree(pidlAbsTmp);
    1999                 COMDLG32_SHFree(pidlTmp1);
    2000               }
    2001               IEnumIDList_Release(lpeDrives);
    2002             }
    2003             IShellFolder_Release(psfDrives);
    2004           }
    2005         }
     1985    FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
     1986
     1987    /* special handling for CSIDL_DRIVES */
     1988    if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives))
     1989    {
     1990      if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives)))
     1991      {
     1992        /* enumerate the drives */
     1993        if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives)))
     1994        {
     1995          while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL))
     1996          {
     1997            pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1);
     1998            FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND);
     1999            COMDLG32_SHFree(pidlAbsTmp);
     2000            COMDLG32_SHFree(pidlTmp1);
     2001          }
     2002          IEnumIDList_Release(lpeDrives);
     2003        }
     2004        IShellFolder_Release(psfDrives);
     2005      }
     2006    }
    20062007        COMDLG32_SHFree(pidlTmp);
    20072008      }
     
    20492050  {
    20502051    ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
    2051                                                0,   
    2052                                                &sfi,   
    2053                                                sizeof (SHFILEINFOA),   
    2054                                                SHGFI_PIDL | SHGFI_SMALLICON |   
    2055                                                SHGFI_OPENICON | SHGFI_SYSICONINDEX    | 
    2056                                                SHGFI_DISPLAYNAME );   
     2052                                               0,
     2053                                               &sfi,
     2054                                               sizeof (SHFILEINFOA),
     2055                                               SHGFI_PIDL | SHGFI_SMALLICON |
     2056                                               SHGFI_OPENICON | SHGFI_SYSICONINDEX    |
     2057                                               SHGFI_DISPLAYNAME );
    20572058  }
    20582059  else
    20592060  {
    20602061    ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
    2061                                                   0, 
    2062                                                   &sfi, 
     2062                                                  0,
     2063                                                  &sfi,
    20632064                                                  sizeof (SHFILEINFOA),
    2064                                                   SHGFI_PIDL | SHGFI_SMALLICON | 
    2065                                                   SHGFI_SYSICONINDEX | 
     2065                                                  SHGFI_PIDL | SHGFI_SMALLICON |
     2066                                                  SHGFI_SYSICONINDEX |
    20662067                                                  SHGFI_DISPLAYNAME);
    20672068  }
     
    20862087    iIndentation = 0;
    20872088    ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
    2088                                                 0, 
    2089                                                 &sfi, 
    2090                                                 sizeof (SHFILEINFOA), 
    2091                                                 SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON 
     2089                                                0,
     2090                                                &sfi,
     2091                                                sizeof (SHFILEINFOA),
     2092                                                SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON
    20922093                                                | SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME  );
    20932094
     
    21092110  rectText.left = rectIcon.right;
    21102111  rectText.top =
    2111           (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - tm.tmHeight) / 2;
     2112      (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - tm.tmHeight) / 2;
    21122113  rectText.right = pDIStruct->rcItem.right + XTEXTOFFSET;
    21132114  rectText.bottom =
    2114           (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + tm.tmHeight) / 2;
    2115  
     2115      (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + tm.tmHeight) / 2;
     2116
    21162117  /* Draw the icon from the image list */
    21172118  ImageList_Draw(ilItemImage,
    21182119                 sfi.iIcon,
    2119                  pDIStruct->hDC, 
    2120                  rectIcon.left, 
    2121                  rectIcon.top, 
    2122                  ILD_TRANSPARENT ); 
     2120                 pDIStruct->hDC,
     2121                 rectIcon.left,
     2122                 rectIcon.top,
     2123                 ILD_TRANSPARENT );
    21232124
    21242125  /* Draw the associated text */
     
    21472148    {
    21482149      LPSFOLDER tmpFolder;
    2149       int iItem; 
     2150      int iItem;
    21502151
    21512152      iItem = CBGetCurSel(fodInfos->DlgInfos.hwndLookInCB);
     
    21532154      if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,
    21542155                                               iItem)))
    2155         return FALSE;
     2156    return FALSE;
    21562157
    21572158
     
    21642165      break;
    21652166    }
    2166      
     2167
    21672168  }
    21682169  return FALSE;
     
    21892190  if(!(liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr)))
    21902191    return -1;
    2191    
     2192
    21922193  tmpFolder = MemAlloc(sizeof(SFOLDER));
    21932194  tmpFolder->m_iIndent = 0;
     
    22042205  if(tmpFolder->m_iIndent > liInfos->iMaxIndentation)
    22052206    liInfos->iMaxIndentation = tmpFolder->m_iIndent;
    2206  
     2207
    22072208  sfi.dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
    22082209  SHGetFileInfoA((LPSTR)pidl,
     
    22102211                  &sfi,
    22112212                  sizeof(sfi),
    2212                   SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX 
     2213                  SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX
    22132214                  | SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED);
    22142215
     
    22182219  {
    22192220    int iItemID;
    2220  
     2221
    22212222    TRACE("-- Add %s at %u\n", sfi.szDisplayName, tmpFolder->m_iIndent);
    22222223
     
    22442245 *      FILEDLG95_LOOKIN_InsertItemAfterParent
    22452246 *
    2246  * Insert an item below its parent 
     2247 * Insert an item below its parent
    22472248 */
    22482249static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl)
    22492250{
    2250  
     2251
    22512252  LPITEMIDLIST pidlParent = GetParentPidl(pidl);
    22522253  int iParentPos;
     
    23032304    }
    23042305  }
    2305  
     2306
    23062307  CBSetCurSel(hwnd,iItemPos);
    23072308  liInfos->uSelectedItem = iItemPos;
     
    24212422    if (nFileSelected >= 1)
    24222423    {
    2423       nLength += 3;     /* first and last quotes, trailing \0 */
     2424      nLength += 3; /* first and last quotes, trailing \0 */
    24242425      for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
    24252426      {
    24262427        pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, nFileToOpen+1 );
    2427    
     2428
    24282429        if (pidl)
    2429         {
     2430    {
    24302431          /* get the total length of the selected file names*/
    24312432          lpstrTemp[0] = '\0';
     
    24332434
    24342435          if ( ! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl) ) /* Ignore folders */
    2435           {
     2436      {
    24362437            nLength += strlen( lpstrTemp ) + 3;
    24372438            nFiles++;
    2438           }
     2439      }
    24392440          COMDLG32_SHFree( pidl );
    2440         }
     2441    }
    24412442      }
    24422443    }
     
    24562457
    24572458        if (pidl)
    2458         {
    2459           /* get the file name */
     2459    {
     2460      /* get the file name */
    24602461          lpstrTemp[0] = '\0';
    24612462          GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER, lpstrTemp );
    24622463
    24632464          if (! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl)) /* Ignore folders */
    2464           {
     2465      {
    24652466            if ( nFiles > 1)
    2466             {
     2467        {
    24672468              *lpstrCurrFile++ =  '\"';
    24682469              strcpy( lpstrCurrFile, lpstrTemp );
     
    24702471              strcpy( lpstrCurrFile, "\" " );
    24712472              lpstrCurrFile += 2;
    2472             }
    2473             else
    2474             {
     2473        }
     2474        else
     2475        {
    24752476              strcpy( lpstrAllFile, lpstrTemp );
    2476             }
    2477           }
     2477        }
     2478      }
    24782479          COMDLG32_SHFree( (LPVOID) pidl );
    2479         }
     2480    }
    24802481      }
    24812482    }
     
    24952496static HRESULT COMDLG32_StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
    24962497{
    2497         switch (src->uType)
    2498         {
    2499           case STRRET_WSTR:
    2500             WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
    2501             COMDLG32_SHFree(src->u.pOleStr);
    2502             break;
    2503 
    2504           case STRRET_CSTRA:
    2505             lstrcpynA((LPSTR)dest, src->u.cStr, len);
    2506             break;
    2507 
    2508           case STRRET_OFFSETA:
    2509             lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
    2510             break;
    2511 
    2512           default:
    2513             FIXME("unknown type!\n");
    2514             if (len)
    2515             {
    2516               *(LPSTR)dest = '\0';
    2517             }
    2518             return(FALSE);
    2519         }
    2520         return S_OK;
     2498    switch (src->uType)
     2499    {
     2500      case STRRET_WSTR:
     2501        WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
     2502        COMDLG32_SHFree(src->u.pOleStr);
     2503        break;
     2504
     2505      case STRRET_CSTRA:
     2506        lstrcpynA((LPSTR)dest, src->u.cStr, len);
     2507        break;
     2508
     2509      case STRRET_OFFSETA:
     2510        lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
     2511        break;
     2512
     2513      default:
     2514        FIXME("unknown type!\n");
     2515        if (len)
     2516        {
     2517          *(LPSTR)dest = '\0';
     2518        }
     2519        return(FALSE);
     2520    }
     2521    return S_OK;
    25212522}
    25222523
     
    25282529int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPSTR * lpstrFileList, UINT * sizeUsed)
    25292530{
    2530         FileOpenDlgInfos *fodInfos  = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
    2531         UINT nStrCharCount = 0; /* index in src buffer */
    2532         UINT nFileIndex = 0;    /* index in dest buffer */
    2533         UINT nFileCount = 0;    /* number of files */
    2534         UINT nStrLen = 0;       /* length of string in edit control */
    2535         LPSTR lpstrEdit;        /* buffer for string from edit control */
    2536 
    2537         TRACE("\n");
    2538 
    2539         /* get the filenames from the edit control */
    2540         nStrLen = SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0);
    2541         lpstrEdit = MemAlloc(nStrLen+1);
    2542         GetDlgItemTextA(hwnd, IDC_FILENAME, lpstrEdit, nStrLen+1);
    2543 
    2544         TRACE("nStrLen=%u str=%s\n", nStrLen, lpstrEdit);
    2545        
    2546         /* we might get single filename without any '"',
    2547         * so we need nStrLen + terminating \0 + end-of-list \0 */
    2548         *lpstrFileList = MemAlloc(nStrLen+2);
    2549         *sizeUsed = 0;
    2550 
    2551         /* build 0-delimited file list from filenames */
    2552         while ( nStrCharCount <= nStrLen )
    2553         {
    2554           if ( lpstrEdit[nStrCharCount]=='"' )
    2555           {
    2556             nStrCharCount++;
    2557             while ((lpstrEdit[nStrCharCount]!='"') && (nStrCharCount <= nStrLen))
    2558             {
    2559               (*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount];
    2560               (*sizeUsed)++;
    2561               nStrCharCount++;
    2562             }
    2563             (*lpstrFileList)[nFileIndex++] = '\0';
    2564             (*sizeUsed)++;
    2565             nFileCount++;
    2566           }
    2567           nStrCharCount++;
    2568         }
    2569 
    2570         /* single, unquoted string */
    2571         if ((nStrLen > 0) && (*sizeUsed == 0) )
    2572         {
    2573           strcpy(*lpstrFileList, lpstrEdit);
    2574           nFileIndex = strlen(lpstrEdit) + 1;
    2575           (*sizeUsed) = nFileIndex;
    2576           nFileCount = 1;
    2577         }
    2578 
    2579         /* trailing \0 */
    2580         (*lpstrFileList)[nFileIndex] = '\0';
    2581         (*sizeUsed)++;
    2582 
    2583         MemFree(lpstrEdit);
    2584         return nFileCount;
     2531    FileOpenDlgInfos *fodInfos  = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
     2532    UINT nStrCharCount = 0; /* index in src buffer */
     2533    UINT nFileIndex = 0;    /* index in dest buffer */
     2534    UINT nFileCount = 0;    /* number of files */
     2535    UINT nStrLen = 0;   /* length of string in edit control */
     2536    LPSTR lpstrEdit;    /* buffer for string from edit control */
     2537
     2538    TRACE("\n");
     2539
     2540    /* get the filenames from the edit control */
     2541    nStrLen = SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0);
     2542    lpstrEdit = MemAlloc(nStrLen+1);
     2543    GetDlgItemTextA(hwnd, IDC_FILENAME, lpstrEdit, nStrLen+1);
     2544
     2545    TRACE("nStrLen=%u str=%s\n", nStrLen, lpstrEdit);
     2546
     2547    /* we might get single filename without any '"',
     2548    * so we need nStrLen + terminating \0 + end-of-list \0 */
     2549    *lpstrFileList = MemAlloc(nStrLen+2);
     2550    *sizeUsed = 0;
     2551
     2552    /* build 0-delimited file list from filenames */
     2553    while ( nStrCharCount <= nStrLen )
     2554    {
     2555      if ( lpstrEdit[nStrCharCount]=='"' )
     2556      {
     2557        nStrCharCount++;
     2558        while ((lpstrEdit[nStrCharCount]!='"') && (nStrCharCount <= nStrLen))
     2559        {
     2560          (*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount];
     2561          (*sizeUsed)++;
     2562          nStrCharCount++;
     2563        }
     2564        (*lpstrFileList)[nFileIndex++] = '\0';
     2565        (*sizeUsed)++;
     2566        nFileCount++;
     2567      }
     2568      nStrCharCount++;
     2569    }
     2570
     2571    /* single, unquoted string */
     2572    if ((nStrLen > 0) && (*sizeUsed == 0) )
     2573    {
     2574      strcpy(*lpstrFileList, lpstrEdit);
     2575      nFileIndex = strlen(lpstrEdit) + 1;
     2576      (*sizeUsed) = nFileIndex;
     2577      nFileCount = 1;
     2578    }
     2579
     2580    /* trailing \0 */
     2581    (*lpstrFileList)[nFileIndex] = '\0';
     2582    (*sizeUsed)++;
     2583
     2584    MemFree(lpstrEdit);
     2585    return nFileCount;
    25852586}
    25862587
     
    26252626LPITEMIDLIST GetPidlFromDataObject ( IDataObject *doSelected, UINT nPidlIndex)
    26262627{
    2627      
     2628
    26282629    STGMEDIUM medium;
    26292630    FORMATETC formatetc;
    26302631    LPITEMIDLIST pidl = NULL;
    2631    
     2632
    26322633    TRACE("sv=%p index=%u\n", doSelected, nPidlIndex);
    2633    
     2634
    26342635    /* Set the FORMATETC structure*/
    26352636    SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLIST), TYMED_HGLOBAL);
     
    26852686 *      GetName
    26862687 *
    2687  * Get the pidl's display name (relative to folder) and 
     2688 * Get the pidl's display name (relative to folder) and
    26882689 * put it in lpstrFileName.
    2689  * 
     2690 *
    26902691 * Return NOERROR on success,
    26912692 * E_FAIL otherwise
     
    27192720 *      GetShellFolderFromPidl
    27202721 *
    2721  * pidlRel is the item pidl relative 
     2722 * pidlRel is the item pidl relative
    27222723 * Return the IShellFolder of the absolute pidl
    27232724 */
     
    27352736      if(SUCCEEDED(IShellFolder_BindToObject(psfParent, pidlAbs, NULL, &IID_IShellFolder, (LPVOID*)&psf)))
    27362737      {
    2737         IShellFolder_Release(psfParent);
     2738    IShellFolder_Release(psfParent);
    27382739        return psf;
    27392740      }
     
    27552756
    27562757  TRACE("%p\n", pidl);
    2757  
     2758
    27582759  pidlParent = COMDLG32_PIDL_ILClone(pidl);
    27592760  COMDLG32_PIDL_ILRemoveLastID(pidlParent);
    2760      
     2761
    27612762  return pidlParent;
    27622763}
     
    27652766 *      GetPidlFromName
    27662767 *
    2767  * returns the pidl of the file name relative to folder 
     2768 * returns the pidl of the file name relative to folder
    27682769 * NULL if an error occurred
    27692770 */
     
    27792780  if(!*lpcstrFileName) return NULL;
    27802781
    2781   MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,lpcstrFileName,-1,(LPWSTR)lpwstrDirName,MAX_PATH); 
     2782  MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,lpcstrFileName,-1,(LPWSTR)lpwstrDirName,MAX_PATH);
    27822783
    27832784  if(!lpsf)
     
    27892790  else
    27902791  {
    2791     IShellFolder_ParseDisplayName(lpsf, 0, NULL, (LPWSTR)lpwstrDirName, &ulEaten, &pidl, NULL); 
     2792    IShellFolder_ParseDisplayName(lpsf, 0, NULL, (LPWSTR)lpwstrDirName, &ulEaten, &pidl, NULL);
    27922793  }
    27932794  return pidl;
     
    27982799BOOL IsPidlFolder (LPSHELLFOLDER psf, LPITEMIDLIST pidl)
    27992800{
    2800         ULONG uAttr  = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
    2801         HRESULT ret;
    2802        
    2803         TRACE("%p, %p\n", psf, pidl);
    2804        
    2805         ret = IShellFolder_GetAttributesOf( psf, 1, &pidl, &uAttr );
    2806        
    2807         TRACE("-- 0x%08lx 0x%08lx\n", uAttr, ret);
    2808         /* see documentation shell 4.1*/
     2801    ULONG uAttr  = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
     2802    HRESULT ret;
     2803
     2804    TRACE("%p, %p\n", psf, pidl);
     2805
     2806    ret = IShellFolder_GetAttributesOf( psf, 1, &pidl, &uAttr );
     2807
     2808    TRACE("-- 0x%08lx 0x%08lx\n", uAttr, ret);
     2809    /* see documentation shell 4.1*/
    28092810        return uAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER);
    28102811}
     
    28412842
    28422843  return bBrowseSelFolder;
    2843 } 
     2844}
    28442845
    28452846/*
  • trunk/src/comdlg32/filedlgbrowser.c

    r5583 r6645  
     1/* $Id: filedlgbrowser.c,v 1.9 2001-09-05 12:12:01 bird Exp $ */
    12/*
    23 *  Implementation of IShellBrowser for the File Open common dialog
    3  * 
     4 *
    45 *
    56 */
     
    5960*   External Prototypes
    6061*/
    61 extern const char *FileOpenDlgInfosStr; 
     62extern const char *FileOpenDlgInfosStr;
    6263
    6364extern HRESULT          GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
     
    9192static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
    9293{
    93         TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
    94 
    95         switch (src->uType)
    96         {
    97           case STRRET_WSTR:
    98             lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
    99             COMDLG32_SHFree(src->u.pOleStr);
    100             break;
    101 
    102           case STRRET_CSTRA:
     94    TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
     95
     96    switch (src->uType)
     97    {
     98      case STRRET_WSTR:
     99        lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
     100        COMDLG32_SHFree(src->u.pOleStr);
     101        break;
     102
     103      case STRRET_CSTRA:
    103104            if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len ))
    104105                ((LPWSTR)dest)[len-1] = 0;
    105             break;
    106 
    107           case STRRET_OFFSETA:
    108             if (pidl)
    109             {
     106        break;
     107
     108      case STRRET_OFFSETA:
     109        if (pidl)
     110        {
    110111                if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
    111112                                                 -1, (LPWSTR)dest, len ))
    112113                    ((LPWSTR)dest)[len-1] = 0;
    113             }
    114             break;
    115 
    116           default:
    117             FIXME("unknown type!\n");
    118             if (len)
    119             { *(LPWSTR)dest = '\0';
    120             }
    121             return(FALSE);
    122         }
    123         return S_OK;
     114        }
     115        break;
     116
     117      default:
     118        FIXME("unknown type!\n");
     119        if (len)
     120        { *(LPWSTR)dest = '\0';
     121        }
     122        return(FALSE);
     123    }
     124    return S_OK;
    124125}
    125126
    126127/*
    127  *      IShellBrowser
     128 *  IShellBrowser
    128129 */
    129  
     130
    130131/**************************************************************************
    131132*  IShellBrowserImpl_Construct
     
    158159*/
    159160HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
    160                                             REFIID riid, 
     161                                            REFIID riid,
    161162                                            LPVOID *ppvObj)
    162163{
     
    168169
    169170    if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
    170     { *ppvObj = This; 
     171    { *ppvObj = This;
    171172    }
    172173    else if(IsEqualIID(riid, &IID_IOleWindow))  /*IOleWindow*/
     
    215216    TRACE("(%p)\n", This);
    216217
    217     if (!--(This->ref)) 
    218     { 
     218    if (!--(This->ref))
     219    {
    219220      HeapFree(GetProcessHeap(),0, This);
    220221      return 0;
     
    235236*
    236237*  Note : We will never be window less in the File Open dialog
    237 * 
    238 */
    239 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface, 
     238*
     239*/
     240HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
    240241                                           HWND * phwnd)
    241242{
     
    249250    *phwnd = This->hwndOwner;
    250251
    251     return (*phwnd) ? S_OK : E_UNEXPECTED; 
     252    return (*phwnd) ? S_OK : E_UNEXPECTED;
    252253
    253254}
     
    276277*  See Windows documentation on IShellBrowser::BrowseObject for more details
    277278*
    278 *  This function will override user specified flags and will always 
    279 *  use SBSP_DEFBROWSER and SBSP_DEFMODE. 
    280 */
    281 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface, 
    282                                               LPCITEMIDLIST pidl, 
     279*  This function will override user specified flags and will always
     280*  use SBSP_DEFBROWSER and SBSP_DEFMODE.
     281*/
     282HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
     283                                              LPCITEMIDLIST pidl,
    283284                                              UINT wFlags)
    284285{
     
    301302    if(wFlags & SBSP_RELATIVE)
    302303    {
    303        
     304
    304305        /* SBSP_RELATIVE  A relative pidl (relative from the current folder) */
    305306        if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
     
    307308        {
    308309            ERR("bind to object failed\n");
    309             return hRes;
     310        return hRes;
    310311        }
    311312        /* create an absolute pidl */
     
    326327        psfTmp = GetShellFolderFromPidl(pidlTmp);
    327328    }
    328    
     329
    329330    if(!psfTmp)
    330331    {
     
    333334    }
    334335
    335     /* If the pidl to browse to is equal to the actual pidl ... 
     336    /* If the pidl to browse to is equal to the actual pidl ...
    336337       do nothing and pretend you did it*/
    337338    if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
    338339    {
    339340        IShellFolder_Release(psfTmp);
    340         COMDLG32_SHFree(pidlTmp);
     341    COMDLG32_SHFree(pidlTmp);
    341342        TRACE("keep current folder\n");
    342343        return NOERROR;
     
    395396
    396397    /* changes the tab order of the ListView to reflect the window's File Dialog */
    397     hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN); 
     398    hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
    398399    SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
    399400
     
    402403      SetFocus(fodInfos->ShellInfos.hwndView);
    403404
    404     return hRes; 
     405    return hRes;
    405406error:
    406407    ERR("Failed with error 0x%08lx\n", hRes);
     
    411412*  IShellBrowserImpl_EnableModelessSB
    412413*/
    413 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,   
     414HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
    414415                                              BOOL fEnable)
    415                                              
     416
    416417{
    417418    ICOM_THIS(IShellBrowserImpl, iface);
     
    426427*  IShellBrowserImpl_GetControlWindow
    427428*/
    428 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,   
    429                                               UINT id,   
     429HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
     430                                              UINT id,
    430431                                              HWND *lphwnd)
    431                                              
     432
    432433{
    433434    ICOM_THIS(IShellBrowserImpl, iface);
     
    442443*/
    443444HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
    444                                                 DWORD grfMode,   
     445                                                DWORD grfMode,
    445446                                                LPSTREAM *ppStrm)
    446                                              
     447
    447448{
    448449    ICOM_THIS(IShellBrowserImpl, iface);
     
    452453    /* Feature not implemented */
    453454    return E_NOTIMPL;
    454 }       
     455}
    455456/**************************************************************************
    456457*  IShellBrowserImpl_InsertMenusSB
     
    459460                                           HMENU hmenuShared,
    460461                                           LPOLEMENUGROUPWIDTHS lpMenuWidths)
    461                                              
     462
    462463{
    463464    ICOM_THIS(IShellBrowserImpl, iface);
     
    473474HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
    474475                                                IShellView *ppshv)
    475                                              
    476 {
    477     ICOM_THIS(IShellBrowserImpl, iface);
    478 
    479     TRACE("(%p)\n", This);
    480 
    481     /* Feature not implemented */
    482     return E_NOTIMPL;
    483 }   
     476
     477{
     478    ICOM_THIS(IShellBrowserImpl, iface);
     479
     480    TRACE("(%p)\n", This);
     481
     482    /* Feature not implemented */
     483    return E_NOTIMPL;
     484}
    484485/**************************************************************************
    485486*  IShellBrowserImpl_QueryActiveShellView
     
    487488HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
    488489                                                  IShellView **ppshv)
    489                                              
     490
    490491{
    491492    ICOM_THIS(IShellBrowserImpl, iface);
     
    503504    IShellView_AddRef(fodInfos->Shell.FOIShellView);
    504505    return NOERROR;
    505 }   
     506}
    506507/**************************************************************************
    507508*  IShellBrowserImpl_RemoveMenusSB
     
    509510HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
    510511                                           HMENU hmenuShared)
    511                                              
    512 {
    513     ICOM_THIS(IShellBrowserImpl, iface);
    514 
    515     TRACE("(%p)\n", This);
    516 
    517     /* Feature not implemented */
    518     return E_NOTIMPL;
    519 }   
     512
     513{
     514    ICOM_THIS(IShellBrowserImpl, iface);
     515
     516    TRACE("(%p)\n", This);
     517
     518    /* Feature not implemented */
     519    return E_NOTIMPL;
     520}
    520521/**************************************************************************
    521522*  IShellBrowserImpl_SendControlMsg
    522523*/
    523 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,   
    524                                             UINT id,   
    525                                             UINT uMsg,   
    526                                             WPARAM wParam,   
     524HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
     525                                            UINT id,
     526                                            UINT uMsg,
     527                                            WPARAM wParam,
    527528                                            LPARAM lParam,
    528529                                            LRESULT *pret)
    529                                              
     530
    530531{
    531532    ICOM_THIS(IShellBrowserImpl, iface);
    532533    LRESULT lres;
    533    
     534
    534535    TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
    535536
     
    538539      case FCW_TOOLBAR:
    539540        lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
    540         break;
     541    break;
    541542      default:
    542543        FIXME("ctrl id: %x\n", id);
     
    550551*/
    551552HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
    552                                        HMENU hmenuShared,   
     553                                       HMENU hmenuShared,
    553554                                       HOLEMENU holemenuReserved,
    554555                                       HWND hwndActiveObject)
    555                                              
    556 {
    557     ICOM_THIS(IShellBrowserImpl, iface);
    558 
    559     TRACE("(%p)\n", This);
    560 
    561     /* Feature not implemented */
    562     return E_NOTIMPL;
    563 }   
     556
     557{
     558    ICOM_THIS(IShellBrowserImpl, iface);
     559
     560    TRACE("(%p)\n", This);
     561
     562    /* Feature not implemented */
     563    return E_NOTIMPL;
     564}
    564565/**************************************************************************
    565566*  IShellBrowserImpl_SetStatusTextSB
     
    567568HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
    568569                                             LPCOLESTR lpszStatusText)
    569                                              
    570 {
    571     ICOM_THIS(IShellBrowserImpl, iface);
    572 
    573     TRACE("(%p)\n", This);
    574 
    575     /* Feature not implemented */
    576     return E_NOTIMPL;
    577 }   
     570
     571{
     572    ICOM_THIS(IShellBrowserImpl, iface);
     573
     574    TRACE("(%p)\n", This);
     575
     576    /* Feature not implemented */
     577    return E_NOTIMPL;
     578}
    578579/**************************************************************************
    579580*  IShellBrowserImpl_SetToolbarItems
    580581*/
    581582HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
    582                                              LPTBBUTTON lpButtons,   
    583                                              UINT nButtons,   
     583                                             LPTBBUTTON lpButtons,
     584                                             UINT nButtons,
    584585                                             UINT uFlags)
    585                                              
    586 {
    587     ICOM_THIS(IShellBrowserImpl, iface);
    588 
    589     TRACE("(%p)\n", This);
    590 
    591     /* Feature not implemented */
    592     return E_NOTIMPL;
    593 }   
     586
     587{
     588    ICOM_THIS(IShellBrowserImpl, iface);
     589
     590    TRACE("(%p)\n", This);
     591
     592    /* Feature not implemented */
     593    return E_NOTIMPL;
     594}
    594595/**************************************************************************
    595596*  IShellBrowserImpl_TranslateAcceleratorSB
    596597*/
    597598HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
    598                                                     LPMSG lpmsg,   
     599                                                    LPMSG lpmsg,
    599600                                                    WORD wID)
    600                                              
     601
    601602{
    602603    ICOM_THIS(IShellBrowserImpl, iface);
     
    644645*/
    645646HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
    646         ICommDlgBrowser *iface,
    647         REFIID riid,
    648         LPVOID *ppvObj)
     647    ICommDlgBrowser *iface,
     648    REFIID riid,
     649    LPVOID *ppvObj)
    649650{
    650651    _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
     
    693694    TRACE("(%p)\n", This);
    694695
    695     fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr); 
    696    
     696    fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
     697
    697698    /* If the selected object is not a folder, send a IDOK command to parent window */
    698699    if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
     
    702703        ULONG  ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
    703704        IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
    704         if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
    705         {
     705    if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
     706    {
    706707          hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
    707         }
     708    }
    708709        else
    709         {
     710    {
    710711          /* Tell the dialog that the user selected a file */
    711           hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
    712         }
     712      hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
     713    }
    713714
    714715        /* Free memory used by pidl */
     
    737738        case CDBOSC_SETFOCUS:
    738739             /* FIXME: Reset the default button.
    739                 This should be taken care of by defdlg. If control
    740                 other than button receives focus the default button
    741                 should be restored. */
     740            This should be taken care of by defdlg. If control
     741            other than button receives focus the default button
     742            should be restored. */
    742743             SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
    743744
    744745            break;
    745         case CDBOSC_KILLFOCUS: 
    746             {
    747                 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
    748                 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
    749                     SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
     746        case CDBOSC_KILLFOCUS:
     747        {
     748        FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
     749        if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
     750            SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
    750751            }
    751752            break;
     
    753754            return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
    754755        case CDBOSC_RENAME:
    755             /* nothing to do */
     756        /* nothing to do */
    756757            break;
    757758    }
    758759
    759     return NOERROR;     
     760    return NOERROR;
    760761}
    761762
     
    763764*  IShellBrowserImpl_ICommDlgBrowser_IncludeObject
    764765*/
    765 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface, 
     766HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
    766767                                                               IShellView * ppshv,
    767768                                                               LPCITEMIDLIST pidl)
     
    780781    ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
    781782    IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
    782    
     783
    783784    if( (ulAttr & SFGAO_HIDDEN)                                         /* hidden */
    784785      | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
     
    786787
    787788    /* always include directorys and links */
    788     if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK)) 
     789    if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
    789790        return S_OK;
    790791
     
    797798      if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
    798799      {
    799           if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
     800      if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
    800801          return S_OK;
    801802      }
     
    807808/**************************************************************************
    808809*  IShellBrowserImpl_ICommDlgBrowser_OnSelChange
    809 */ 
     810*/
    810811HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
    811812{
     
    816817    fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
    817818    TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
    818    
     819
    819820    /* release old selections */
    820821    if (fodInfos->Shell.FOIDataObject)
    821822      IDataObject_Release(fodInfos->Shell.FOIDataObject);
    822    
     823
    823824    /* get a new DataObject from the ShellView */
    824825    if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
    825826                              &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
    826827      return E_FAIL;
    827                                          
     828
    828829    FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
    829830
     
    856857*/
    857858HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
    858         IServiceProvider *iface,
    859         REFIID riid,
    860         LPVOID *ppvObj)
     859    IServiceProvider *iface,
     860    REFIID riid,
     861    LPVOID *ppvObj)
    861862{
    862863    _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
     
    895896*
    896897* NOTES
    897 *  the w2k shellview asks for 
     898*  the w2k shellview asks for
    898899*   guidService = SID_STopLevelBrowser
    899900*   riid = IShellBrowser
     
    904905
    905906HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
    906         IServiceProvider * iface,
    907         REFGUID guidService,
    908         REFIID riid,
    909         void** ppv)
     907    IServiceProvider * iface,
     908    REFGUID guidService,
     909    REFIID riid,
     910    void** ppv)
    910911{
    911912    _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
  • trunk/src/comdlg32/filetitle.c

    r4511 r6645  
     1/* $Id: filetitle.c,v 1.5 2001-09-05 12:12:01 bird Exp $ */
    12/*
    23 * COMMDLG - File Dialogs
     
    1314#include "debugtools.h"
    1415
    15 #include "heap.h"       /* Has to go */
     16#include "heap.h"   /* Has to go */
    1617
    1718DEFAULT_DEBUG_CHANNEL(commdlg)
     
    2021
    2122/***********************************************************************
    22  *      GetFileTitleA           (COMDLG32.8)
     23 *  GetFileTitleA       (COMDLG32.8)
    2324 *
    2425 */
    2526short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
    2627{
    27         int i, len;
     28    int i, len;
    2829
    29         TRACE("(%p %p %d); \n", lpFile, lpTitle, cbBuf);
     30    TRACE("(%p %p %d); \n", lpFile, lpTitle, cbBuf);
    3031
    31         if(lpFile == NULL || lpTitle == NULL)
    32                 return -1;
     32    if(lpFile == NULL || lpTitle == NULL)
     33        return -1;
    3334
    34         len = strlen(lpFile);
     35    len = strlen(lpFile);
    3536
    36         if (len == 0)
    37                 return -1;
     37    if (len == 0)
     38        return -1;
    3839
    39         if(strpbrk(lpFile, "*[]"))
    40                 return -1;
     40    if(strpbrk(lpFile, "*[]"))
     41        return -1;
    4142
    42         len--;
     43    len--;
    4344
    44         if(lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
    45                 return -1;
     45    if(lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
     46        return -1;
    4647
    47         for(i = len; i >= 0; i--)
    48         {
    49                 if (lpFile[i] == '/' ||  lpFile[i] == '\\' ||  lpFile[i] == ':')
    50                 {
    51                         i++;
    52                         break;
    53                 }
    54         }
     48    for(i = len; i >= 0; i--)
     49    {
     50        if (lpFile[i] == '/' ||  lpFile[i] == '\\' ||  lpFile[i] == ':')
     51        {
     52            i++;
     53            break;
     54        }
     55    }
    5556
    56         if(i == -1)
    57                 i++;
     57    if(i == -1)
     58        i++;
    5859
    59         TRACE("---> '%s' \n", &lpFile[i]);
    60    
    61         len = strlen(lpFile+i)+1;
    62         if(cbBuf < len)
    63                 return len;
     60    TRACE("---> '%s' \n", &lpFile[i]);
    6461
    65         strncpy(lpTitle, &lpFile[i], len);
    66         return 0;
     62    len = strlen(lpFile+i)+1;
     63    if(cbBuf < len)
     64        return len;
     65
     66    strncpy(lpTitle, &lpFile[i], len);
     67    return 0;
    6768}
    6869
    6970
    7071/***********************************************************************
    71  *      GetFileTitleW           (COMDLG32.9)
     72 *  GetFileTitleW       (COMDLG32.9)
    7273 *
    7374 */
    7475short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, UINT cbBuf)
    7576{
    76         LPSTR file = HEAP_strdupWtoA(GetProcessHeap(), 0, lpFile);      /* Has to go */
    77         LPSTR title = HeapAlloc(GetProcessHeap(), 0, cbBuf);
    78         short   ret;
     77    LPSTR file = HEAP_strdupWtoA(GetProcessHeap(), 0, lpFile);  /* Has to go */
     78    LPSTR title = HeapAlloc(GetProcessHeap(), 0, cbBuf);
     79    short   ret;
    7980
    80         ret = GetFileTitleA(file, title, cbBuf);
     81    ret = GetFileTitleA(file, title, cbBuf);
    8182
    82         lstrcpynAtoW(lpTitle, title, cbBuf);
    83         HeapFree(GetProcessHeap(), 0, file);
    84         HeapFree(GetProcessHeap(), 0, title);
    85         return ret;
     83    lstrcpynAtoW(lpTitle, title, cbBuf);
     84    HeapFree(GetProcessHeap(), 0, file);
     85    HeapFree(GetProcessHeap(), 0, title);
     86    return ret;
    8687}
    8788
     
    8990#ifndef __WIN32OS2__
    9091/***********************************************************************
    91  *      GetFileTitle16          (COMMDLG.27)
     92 *  GetFileTitle16      (COMMDLG.27)
    9293 */
    9394short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf)
    9495{
    95         return GetFileTitleA(lpFile, lpTitle, cbBuf);
     96    return GetFileTitleA(lpFile, lpTitle, cbBuf);
    9697}
    9798#endif
  • trunk/src/comdlg32/finddlg32.c

    r5588 r6645  
     1/* $Id: finddlg32.c,v 1.4 2001-09-05 12:12:01 bird Exp $ */
    12/*
    23 *  Common Dialog Boxes interface (32 bit)
     
    2425/*-----------------------------------------------------------------------*/
    2526
    26 static UINT             FindReplaceMessage;
    27 static UINT             HelpMessage;
    28 
    29 #define FR_MASK (FR_DOWN | FR_MATCHCASE | FR_WHOLEWORD | FR_REPLACEALL | FR_REPLACE | FR_FINDNEXT | FR_DIALOGTERM)
     27static UINT     FindReplaceMessage;
     28static UINT     HelpMessage;
     29
     30#define FR_MASK (FR_DOWN | FR_MATCHCASE | FR_WHOLEWORD | FR_REPLACEALL | FR_REPLACE | FR_FINDNEXT | FR_DIALOGTERM)
    3031/* CRITICAL_SECTION COMDLG32_CritSect; */
    3132
     
    4950
    5051/***********************************************************************
    51  *      COMDLG32_FR_GetFlags                    [internal]
     52 *  COMDLG32_FR_GetFlags            [internal]
    5253 * Returns the button state that needs to be reported to the caller.
    53  *      RETURNS
    54  *              Current state of check and radio buttons
     54 *  RETURNS
     55 *      Current state of check and radio buttons
    5556 */
    5657static DWORD COMDLG32_FR_GetFlags(HWND hDlgWnd)
    5758{
    58         DWORD flags = 0;
    59         if(IsDlgButtonChecked(hDlgWnd, rad2) == BST_CHECKED)
    60                 flags |= FR_DOWN;
    61         if(IsDlgButtonChecked(hDlgWnd, chx1) == BST_CHECKED)
    62                 flags |= FR_WHOLEWORD;
    63         if(IsDlgButtonChecked(hDlgWnd, chx2) == BST_CHECKED)
    64                 flags |= FR_MATCHCASE;
     59    DWORD flags = 0;
     60    if(IsDlgButtonChecked(hDlgWnd, rad2) == BST_CHECKED)
     61            flags |= FR_DOWN;
     62    if(IsDlgButtonChecked(hDlgWnd, chx1) == BST_CHECKED)
     63            flags |= FR_WHOLEWORD;
     64    if(IsDlgButtonChecked(hDlgWnd, chx2) == BST_CHECKED)
     65            flags |= FR_MATCHCASE;
    6566        return flags;
    6667}
    6768
    6869/***********************************************************************
    69  *      COMDLG32_FR_HandleWMCommand             [internal]
     70 *  COMDLG32_FR_HandleWMCommand     [internal]
    7071 * Handle WM_COMMAND messages...
    7172 */
    7273static void COMDLG32_FR_HandleWMCommand(HWND hDlgWnd, COMDLG32_FR_Data *pData, int Id, int NotifyCode)
    7374{
    74         DWORD flag;
    75 
    76         pData->user_fr.fra->Flags &= ~FR_MASK;  /* Clear return flags */
    77         if(pData->fr.Flags & FR_WINE_REPLACE)   /* Replace always goes down... */
    78                 pData->user_fr.fra->Flags |= FR_DOWN;
    79 
    80         if(NotifyCode == BN_CLICKED)
    81         {
    82                 switch(Id)
    83                 {
    84                 case IDOK: /* Find Next */
    85                         if(GetDlgItemTextA(hDlgWnd, edt1, pData->fr.lpstrFindWhat, pData->fr.wFindWhatLen) > 0)
     75    DWORD flag;
     76
     77    pData->user_fr.fra->Flags &= ~FR_MASK;  /* Clear return flags */
     78    if(pData->fr.Flags & FR_WINE_REPLACE)   /* Replace always goes down... */
     79        pData->user_fr.fra->Flags |= FR_DOWN;
     80
     81    if(NotifyCode == BN_CLICKED)
     82        {
     83            switch(Id)
     84        {
     85        case IDOK: /* Find Next */
     86            if(GetDlgItemTextA(hDlgWnd, edt1, pData->fr.lpstrFindWhat, pData->fr.wFindWhatLen) > 0)
    8687                        {
    87                                 pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_FINDNEXT;
     88                pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_FINDNEXT;
    8889                                if(pData->fr.Flags & FR_WINE_UNICODE)
    8990                                {
     
    9495                                else
    9596                                {
    96                                         strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat);
     97                                    strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat);
    9798                                }
    98                                 SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
     99                SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
    99100                        }
    100                         break;
    101 
    102                 case IDCANCEL:
    103                         pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_DIALOGTERM;
    104                         SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
    105                         DestroyWindow(hDlgWnd);
    106                         break;
     101            break;
     102
     103        case IDCANCEL:
     104            pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_DIALOGTERM;
     105            SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
     106                    DestroyWindow(hDlgWnd);
     107            break;
    107108
    108109                case psh2: /* Replace All */
    109                         flag = FR_REPLACEALL;
     110                    flag = FR_REPLACEALL;
    110111                        goto Replace;
    111112
    112113                case psh1: /* Replace */
    113                         flag = FR_REPLACE;
     114                    flag = FR_REPLACE;
    114115Replace:
    115                         if((pData->fr.Flags & FR_WINE_REPLACE)
     116            if((pData->fr.Flags & FR_WINE_REPLACE)
    116117                        && GetDlgItemTextA(hDlgWnd, edt1, pData->fr.lpstrFindWhat, pData->fr.wFindWhatLen) > 0)
    117118                        {
    118                                 pData->fr.lpstrReplaceWith[0] = 0; /* In case the next GetDlgItemText Fails */
    119                                 GetDlgItemTextA(hDlgWnd, edt2, pData->fr.lpstrReplaceWith, pData->fr.wReplaceWithLen);
    120                                 pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | flag;
     119                pData->fr.lpstrReplaceWith[0] = 0; /* In case the next GetDlgItemText Fails */
     120                GetDlgItemTextA(hDlgWnd, edt2, pData->fr.lpstrReplaceWith, pData->fr.wReplaceWithLen);
     121                pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | flag;
    121122                                if(pData->fr.Flags & FR_WINE_UNICODE)
    122123                                {
     
    130131                                else
    131132                                {
    132                                         strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat);
    133                                         strcpy(pData->user_fr.fra->lpstrReplaceWith, pData->fr.lpstrReplaceWith);
     133                                    strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat);
     134                                    strcpy(pData->user_fr.fra->lpstrReplaceWith, pData->fr.lpstrReplaceWith);
    134135                                }
    135                                 SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
     136                SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
    136137                        }
    137                         break;
    138 
    139                 case pshHelp:
    140                         pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd);
    141                         SendMessageA(pData->fr.hwndOwner, HelpMessage, (WPARAM)hDlgWnd, (LPARAM)pData->user_fr.fra);
    142                         break;
     138            break;
     139
     140        case pshHelp:
     141            pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd);
     142            SendMessageA(pData->fr.hwndOwner, HelpMessage, (WPARAM)hDlgWnd, (LPARAM)pData->user_fr.fra);
     143            break;
    143144                }
    144145        }
    145146        else if(NotifyCode == EN_CHANGE && Id == edt1)
    146         {
    147                 BOOL enable = SendDlgItemMessageA(hDlgWnd, edt1, WM_GETTEXTLENGTH, 0, 0) > 0;
    148                 EnableWindow(GetDlgItem(hDlgWnd, IDOK), enable);
     147    {
     148        BOOL enable = SendDlgItemMessageA(hDlgWnd, edt1, WM_GETTEXTLENGTH, 0, 0) > 0;
     149        EnableWindow(GetDlgItem(hDlgWnd, IDOK), enable);
    149150                if(pData->fr.Flags & FR_WINE_REPLACE)
    150151                {
    151                         EnableWindow(GetDlgItem(hDlgWnd, psh1), enable);
    152                         EnableWindow(GetDlgItem(hDlgWnd, psh2), enable);
     152            EnableWindow(GetDlgItem(hDlgWnd, psh1), enable);
     153            EnableWindow(GetDlgItem(hDlgWnd, psh2), enable);
    153154                }
    154         }
    155 }
    156 
    157 /***********************************************************************
    158  *      COMDLG32_FindReplaceDlgProc             [internal]
     155    }
     156}
     157
     158/***********************************************************************
     159 *  COMDLG32_FindReplaceDlgProc     [internal]
    159160 * [Find/Replace]Text32[A/W] window procedure.
    160161 */
    161162static BOOL CALLBACK COMDLG32_FindReplaceDlgProc(HWND hDlgWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
    162163{
    163         COMDLG32_FR_Data *pdata = (COMDLG32_FR_Data *)GetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom);
    164         BOOL retval = TRUE;;
    165 
    166         if(iMsg == WM_INITDIALOG)
     164    COMDLG32_FR_Data *pdata = (COMDLG32_FR_Data *)GetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom);
     165    BOOL retval = TRUE;;
     166
     167    if(iMsg == WM_INITDIALOG)
    167168        {
    168169                pdata = (COMDLG32_FR_Data *)lParam;
    169                 if(!SetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom, (HANDLE)pdata))
     170            if(!SetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom, (HANDLE)pdata))
    170171                {
    171                         ERR("Could not Set prop; invent a gracefull exit?...\n");
    172                         DestroyWindow(hDlgWnd);
     172            ERR("Could not Set prop; invent a gracefull exit?...\n");
     173                    DestroyWindow(hDlgWnd);
    173174                        return FALSE;
    174175                }
    175                 SendDlgItemMessageA(hDlgWnd, edt1, EM_SETLIMITTEXT, (WPARAM)pdata->fr.wFindWhatLen, 0);
    176                 SendDlgItemMessageA(hDlgWnd, edt1, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrFindWhat);
     176            SendDlgItemMessageA(hDlgWnd, edt1, EM_SETLIMITTEXT, (WPARAM)pdata->fr.wFindWhatLen, 0);
     177            SendDlgItemMessageA(hDlgWnd, edt1, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrFindWhat);
    177178                if(pdata->fr.Flags & FR_WINE_REPLACE)
    178179                {
    179                         SendDlgItemMessageA(hDlgWnd, edt2, EM_SETLIMITTEXT, (WPARAM)pdata->fr.wReplaceWithLen, 0);
    180                         SendDlgItemMessageA(hDlgWnd, edt2, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrReplaceWith);
     180                SendDlgItemMessageA(hDlgWnd, edt2, EM_SETLIMITTEXT, (WPARAM)pdata->fr.wReplaceWithLen, 0);
     181                SendDlgItemMessageA(hDlgWnd, edt2, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrReplaceWith);
    181182                }
    182183
    183                 if(!(pdata->fr.Flags & FR_SHOWHELP))
    184                         ShowWindow(GetDlgItem(hDlgWnd, pshHelp), SW_HIDE);
    185                 if(pdata->fr.Flags & FR_HIDEUPDOWN)
    186                 {
    187                         ShowWindow(GetDlgItem(hDlgWnd, rad1), SW_HIDE);
    188                         ShowWindow(GetDlgItem(hDlgWnd, rad2), SW_HIDE);
    189                         ShowWindow(GetDlgItem(hDlgWnd, grp1), SW_HIDE);
    190                 }
    191                 else if(pdata->fr.Flags & FR_NOUPDOWN)
    192                 {
    193                         EnableWindow(GetDlgItem(hDlgWnd, rad1), FALSE);
    194                         EnableWindow(GetDlgItem(hDlgWnd, rad2), FALSE);
    195                         EnableWindow(GetDlgItem(hDlgWnd, grp1), FALSE);
    196                 }
     184            if(!(pdata->fr.Flags & FR_SHOWHELP))
     185            ShowWindow(GetDlgItem(hDlgWnd, pshHelp), SW_HIDE);
     186            if(pdata->fr.Flags & FR_HIDEUPDOWN)
     187            {
     188            ShowWindow(GetDlgItem(hDlgWnd, rad1), SW_HIDE);
     189            ShowWindow(GetDlgItem(hDlgWnd, rad2), SW_HIDE);
     190            ShowWindow(GetDlgItem(hDlgWnd, grp1), SW_HIDE);
     191            }
     192            else if(pdata->fr.Flags & FR_NOUPDOWN)
     193            {
     194            EnableWindow(GetDlgItem(hDlgWnd, rad1), FALSE);
     195            EnableWindow(GetDlgItem(hDlgWnd, rad2), FALSE);
     196            EnableWindow(GetDlgItem(hDlgWnd, grp1), FALSE);
     197            }
    197198                else
    198199                {
    199                         SendDlgItemMessageA(hDlgWnd, rad1, BM_SETCHECK, pdata->fr.Flags & FR_DOWN ? 0 : BST_CHECKED, 0);
    200                         SendDlgItemMessageA(hDlgWnd, rad2, BM_SETCHECK, pdata->fr.Flags & FR_DOWN ? BST_CHECKED : 0, 0);
     200            SendDlgItemMessageA(hDlgWnd, rad1, BM_SETCHECK, pdata->fr.Flags & FR_DOWN ? 0 : BST_CHECKED, 0);
     201            SendDlgItemMessageA(hDlgWnd, rad2, BM_SETCHECK, pdata->fr.Flags & FR_DOWN ? BST_CHECKED : 0, 0);
    201202                }
    202203
    203                 if(pdata->fr.Flags & FR_HIDEMATCHCASE)
    204                         ShowWindow(GetDlgItem(hDlgWnd, chx2), SW_HIDE);
    205                 else if(pdata->fr.Flags & FR_NOMATCHCASE)
    206                         EnableWindow(GetDlgItem(hDlgWnd, chx2), FALSE);
     204            if(pdata->fr.Flags & FR_HIDEMATCHCASE)
     205            ShowWindow(GetDlgItem(hDlgWnd, chx2), SW_HIDE);
     206            else if(pdata->fr.Flags & FR_NOMATCHCASE)
     207            EnableWindow(GetDlgItem(hDlgWnd, chx2), FALSE);
    207208                else
    208                         SendDlgItemMessageA(hDlgWnd, chx2, BM_SETCHECK, pdata->fr.Flags & FR_MATCHCASE ? BST_CHECKED : 0, 0);
    209 
    210                 if(pdata->fr.Flags & FR_HIDEWHOLEWORD)
    211                         ShowWindow(GetDlgItem(hDlgWnd, chx1), SW_HIDE);
    212                 else if(pdata->fr.Flags & FR_NOWHOLEWORD)
    213                         EnableWindow(GetDlgItem(hDlgWnd, chx1), FALSE);
     209            SendDlgItemMessageA(hDlgWnd, chx2, BM_SETCHECK, pdata->fr.Flags & FR_MATCHCASE ? BST_CHECKED : 0, 0);
     210
     211            if(pdata->fr.Flags & FR_HIDEWHOLEWORD)
     212            ShowWindow(GetDlgItem(hDlgWnd, chx1), SW_HIDE);
     213            else if(pdata->fr.Flags & FR_NOWHOLEWORD)
     214            EnableWindow(GetDlgItem(hDlgWnd, chx1), FALSE);
    214215                else
    215                         SendDlgItemMessageA(hDlgWnd, chx1, BM_SETCHECK, pdata->fr.Flags & FR_WHOLEWORD ? BST_CHECKED : 0, 0);
    216 
    217                 /* We did the init here, now call the hook if requested */
    218 
    219                 /* We do not do ShowWindow if hook exists and is FALSE  */
    220                 /*   per MSDN Article Q96135                            */
    221                 if((pdata->fr.Flags & FR_ENABLEHOOK)
    222                      && ! pdata->fr.lpfnHook(hDlgWnd, iMsg, wParam, (LPARAM) &pdata->fr))
    223                         return TRUE;
    224                 ShowWindow(hDlgWnd, SW_SHOWNORMAL);
    225                 UpdateWindow(hDlgWnd);
     216            SendDlgItemMessageA(hDlgWnd, chx1, BM_SETCHECK, pdata->fr.Flags & FR_WHOLEWORD ? BST_CHECKED : 0, 0);
     217
     218        /* We did the init here, now call the hook if requested */
     219
     220        /* We do not do ShowWindow if hook exists and is FALSE  */
     221        /*   per MSDN Article Q96135                            */
     222                if((pdata->fr.Flags & FR_ENABLEHOOK)
     223                 && ! pdata->fr.lpfnHook(hDlgWnd, iMsg, wParam, (LPARAM) &pdata->fr))
    226224                return TRUE;
    227         }
    228 
    229         if(pdata && (pdata->fr.Flags & FR_ENABLEHOOK))
    230         {
    231                 retval = pdata->fr.lpfnHook(hDlgWnd, iMsg, wParam, lParam);
    232         }
    233         else
    234                 retval = FALSE;
    235 
    236         if(pdata && !retval)
    237         {
    238                 retval = TRUE;
    239                 switch(iMsg)
    240                 {
    241                 case WM_COMMAND:
    242                         COMDLG32_FR_HandleWMCommand(hDlgWnd, pdata, LOWORD(wParam), HIWORD(wParam));
    243                         break;
    244 
    245                 case WM_CLOSE:
    246                         COMDLG32_FR_HandleWMCommand(hDlgWnd, pdata, IDCANCEL, BN_CLICKED);
    247                         break;
    248 
    249                 case WM_HELP:
    250                         /* Heeeeelp! */
    251                         FIXME("Got WM_HELP. Who is gonna supply it?\n");
    252                         break;
    253 
    254                 case WM_CONTEXTMENU:
    255                         /* Heeeeelp! */
    256                         FIXME("Got WM_CONTEXTMENU. Who is gonna supply it?\n");
    257                         break;
    258                 /* FIXME: Handle F1 help */
    259 
    260                 default:
    261                         retval = FALSE; /* We did not handle the message */
    262                 }
     225        ShowWindow(hDlgWnd, SW_SHOWNORMAL);
     226        UpdateWindow(hDlgWnd);
     227                return TRUE;
     228        }
     229
     230    if(pdata && (pdata->fr.Flags & FR_ENABLEHOOK))
     231    {
     232        retval = pdata->fr.lpfnHook(hDlgWnd, iMsg, wParam, lParam);
     233    }
     234    else
     235        retval = FALSE;
     236
     237        if(pdata && !retval)
     238        {
     239            retval = TRUE;
     240        switch(iMsg)
     241            {
     242            case WM_COMMAND:
     243            COMDLG32_FR_HandleWMCommand(hDlgWnd, pdata, LOWORD(wParam), HIWORD(wParam));
     244                    break;
     245
     246            case WM_CLOSE:
     247            COMDLG32_FR_HandleWMCommand(hDlgWnd, pdata, IDCANCEL, BN_CLICKED);
     248                break;
     249
     250            case WM_HELP:
     251                /* Heeeeelp! */
     252                FIXME("Got WM_HELP. Who is gonna supply it?\n");
     253                    break;
     254
     255            case WM_CONTEXTMENU:
     256                /* Heeeeelp! */
     257                FIXME("Got WM_CONTEXTMENU. Who is gonna supply it?\n");
     258                    break;
     259        /* FIXME: Handle F1 help */
     260
     261            default:
     262                retval = FALSE; /* We did not handle the message */
     263            }
    263264        }
    264265
     
    269270        if(iMsg == WM_DESTROY)
    270271        {
    271                 RemovePropA(hDlgWnd, (LPSTR)COMDLG32_Atom);
    272                 HeapFree(GetProcessHeap(), 0, pdata);
     272            RemovePropA(hDlgWnd, (LPSTR)COMDLG32_Atom);
     273            HeapFree(GetProcessHeap(), 0, pdata);
    273274        }
    274275
     
    277278
    278279/***********************************************************************
    279  *      COMDLG32_FR_CheckPartial                [internal]
     280 *  COMDLG32_FR_CheckPartial        [internal]
    280281 * Check various fault conditions in the supplied parameters that
    281282 * cause an extended error to be reported.
    282  *      RETURNS
    283  *              TRUE: Success
    284  *              FALSE: Failure
     283 *  RETURNS
     284 *      TRUE: Success
     285 *      FALSE: Failure
    285286 */
    286287static BOOL COMDLG32_FR_CheckPartial(
    287         LPFINDREPLACEA pfr,     /* [in] Find structure */
    288         BOOL Replace            /* [in] True if called as replace */
     288    LPFINDREPLACEA pfr, /* [in] Find structure */
     289        BOOL Replace        /* [in] True if called as replace */
    289290) {
    290         if(!pfr)
    291         {
    292                 COMDLG32_SetCommDlgExtendedError(CDERR_GENERALCODES);
    293                 return FALSE;
    294         }
     291    if(!pfr)
     292        {
     293            COMDLG32_SetCommDlgExtendedError(CDERR_GENERALCODES);
     294                return FALSE;
     295    }
    295296
    296297        if(pfr->lStructSize != sizeof(FINDREPLACEA))
    297298        {
    298                 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
    299                 return FALSE;
     299            COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
     300            return FALSE;
    300301        }
    301302
    302303        if(!IsWindow(pfr->hwndOwner))
    303304        {
    304                 COMDLG32_SetCommDlgExtendedError(CDERR_DIALOGFAILURE);
    305                 return FALSE;
    306         }
    307 
    308         if((pfr->wFindWhatLen < 1 || !pfr->lpstrFindWhat)
     305            COMDLG32_SetCommDlgExtendedError(CDERR_DIALOGFAILURE);
     306            return FALSE;
     307        }
     308
     309    if((pfr->wFindWhatLen < 1 || !pfr->lpstrFindWhat)
    309310        ||(Replace && (pfr->wReplaceWithLen < 1 || !pfr->lpstrReplaceWith)))
    310311        {
    311                 COMDLG32_SetCommDlgExtendedError(FRERR_BUFFERLENGTHZERO);
    312                 return FALSE;
    313         }
    314 
    315         if((FindReplaceMessage = RegisterWindowMessageA(FINDMSGSTRINGA)) == 0)
    316         {
    317                 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
    318                 return FALSE;
    319         }
    320         if((HelpMessage = RegisterWindowMessageA(HELPMSGSTRINGA)) == 0)
    321         {
    322                 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
     312            COMDLG32_SetCommDlgExtendedError(FRERR_BUFFERLENGTHZERO);
     313                return FALSE;
     314        }
     315
     316    if((FindReplaceMessage = RegisterWindowMessageA(FINDMSGSTRINGA)) == 0)
     317        {
     318            COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
     319                return FALSE;
     320        }
     321    if((HelpMessage = RegisterWindowMessageA(HELPMSGSTRINGA)) == 0)
     322        {
     323            COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
    323324                return FALSE;
    324325        }
     
    326327        if((pfr->Flags & FR_ENABLEHOOK) && !pfr->lpfnHook)
    327328        {
    328                 COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK);
     329            COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK);
    329330                return FALSE;
    330331        }
     
    332333        if((pfr->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE)) && !pfr->hInstance)
    333334        {
    334                 COMDLG32_SetCommDlgExtendedError(CDERR_NOHINSTANCE);
     335            COMDLG32_SetCommDlgExtendedError(CDERR_NOHINSTANCE);
    335336                return FALSE;
    336337        }
     
    338339        if((pfr->Flags & FR_ENABLETEMPLATE) && !pfr->lpTemplateName)
    339340        {
    340                 COMDLG32_SetCommDlgExtendedError(CDERR_NOTEMPLATE);
    341                 return FALSE;
    342         }
    343 
    344         return TRUE;
    345 }
    346 
    347 /***********************************************************************
    348  *      COMDLG32_FR_DoFindReplace               [internal]
     341            COMDLG32_SetCommDlgExtendedError(CDERR_NOTEMPLATE);
     342                return FALSE;
     343        }
     344
     345    return TRUE;
     346}
     347
     348/***********************************************************************
     349 *  COMDLG32_FR_DoFindReplace       [internal]
    349350 * Actual load and creation of the Find/Replace dialog.
    350  *      RETURNS
    351  *              Window handle to created dialog:Success
    352  *              NULL:Failure
     351 *  RETURNS
     352 *      Window handle to created dialog:Success
     353 *      NULL:Failure
    353354 */
    354355static HWND COMDLG32_FR_DoFindReplace(
    355         COMDLG32_FR_Data *pdata /* [in] Internal data structure */
     356    COMDLG32_FR_Data *pdata /* [in] Internal data structure */
    356357) {
    357         HWND hdlgwnd = 0;
     358    HWND hdlgwnd = 0;
    358359        HGLOBAL loadrc;
    359360        DWORD error;
    360361        LPDLGTEMPLATEW rcs;
    361362
    362         TRACE("hInst=%08x, Flags=%08lx\n", pdata->fr.hInstance, pdata->fr.Flags);
     363    TRACE("hInst=%08x, Flags=%08lx\n", pdata->fr.hInstance, pdata->fr.Flags);
    363364
    364365        if(!(pdata->fr.Flags & FR_ENABLETEMPLATEHANDLE))
    365366        {
    366                 HMODULE hmod = COMDLG32_hInstance;
    367                 HRSRC htemplate;
    368                 if(pdata->fr.Flags & FR_ENABLETEMPLATE)
    369                 {
    370                         hmod = (HMODULE)pdata->fr.hInstance;
     367            HMODULE hmod = COMDLG32_hInstance;
     368        HRSRC htemplate;
     369            if(pdata->fr.Flags & FR_ENABLETEMPLATE)
     370            {
     371                hmod = (HMODULE)pdata->fr.hInstance;
    371372                        if(pdata->fr.Flags & FR_WINE_UNICODE)
    372373                        {
    373                                 htemplate = FindResourceW(hmod, (LPWSTR)pdata->fr.lpTemplateName, (LPWSTR)RT_DIALOGA);
     374                htemplate = FindResourceW(hmod, (LPWSTR)pdata->fr.lpTemplateName, (LPWSTR)RT_DIALOGA);
    374375                        }
    375376                        else
    376377                        {
    377                                 htemplate = FindResourceA(hmod, pdata->fr.lpTemplateName, (LPCSTR)RT_DIALOGA);
     378                htemplate = FindResourceA(hmod, pdata->fr.lpTemplateName, (LPCSTR)RT_DIALOGA);
    378379                        }
    379                 }
    380                 else
    381                 {
    382                         int rcid = pdata->fr.Flags & FR_WINE_REPLACE ? REPLACEDLGORD
    383                                                                      : FINDDLGORD;
    384                         htemplate = FindResourceA(hmod, MAKEINTRESOURCEA(rcid), (LPCSTR)RT_DIALOGA);
    385                 }
    386                 if(!htemplate)
    387                 {
    388                         error = CDERR_FINDRESFAILURE;
    389                         goto cleanup;
    390                 }
    391 
    392                 loadrc = LoadResource(hmod, htemplate);
    393         }
     380            }
    394381        else
    395         {
    396                 loadrc = (HGLOBAL)pdata->fr.hInstance;
     382            {
     383            int rcid = pdata->fr.Flags & FR_WINE_REPLACE ? REPLACEDLGORD
     384                                     : FINDDLGORD;
     385            htemplate = FindResourceA(hmod, MAKEINTRESOURCEA(rcid), (LPCSTR)RT_DIALOGA);
     386        }
     387        if(!htemplate)
     388                {
     389                    error = CDERR_FINDRESFAILURE;
     390                        goto cleanup;
     391                }
     392
     393            loadrc = LoadResource(hmod, htemplate);
     394        }
     395        else
     396        {
     397            loadrc = (HGLOBAL)pdata->fr.hInstance;
    397398        }
    398399
    399400        if(!loadrc)
    400401        {
    401                 error = CDERR_LOADRESFAILURE;
    402                 goto cleanup;
    403         }
     402        error = CDERR_LOADRESFAILURE;
     403        goto cleanup;
     404    }
    404405
    405406        if((rcs = (LPDLGTEMPLATEW)LockResource(loadrc)) == NULL)
    406407        {
    407                 error = CDERR_LOCKRESFAILURE;
    408                 goto cleanup;
     408        error = CDERR_LOCKRESFAILURE;
     409        goto cleanup;
    409410        }
    410411
    411412        hdlgwnd = CreateDialogIndirectParamA(COMDLG32_hInstance,
    412                                              rcs,
     413                             rcs,
    413414                                             pdata->fr.hwndOwner,
    414415                                             (DLGPROC)COMDLG32_FindReplaceDlgProc,
    415416                                             (LPARAM)pdata);
    416         if(!hdlgwnd)
    417         {
    418                 error = CDERR_DIALOGFAILURE;
     417    if(!hdlgwnd)
     418        {
     419            error = CDERR_DIALOGFAILURE;
    419420cleanup:
    420                 COMDLG32_SetCommDlgExtendedError(error);
     421            COMDLG32_SetCommDlgExtendedError(error);
    421422                HeapFree(GetProcessHeap(), 0, pdata);
    422423        }
     
    425426
    426427/***********************************************************************
    427  *      FindTextA                               [COMDLG32.6]
    428  *      RETURNS
    429  *              Window handle to created dialog: Success
    430  *              NULL: Failure
     428 *  FindTextA               [COMDLG32.6]
     429 *  RETURNS
     430 *      Window handle to created dialog: Success
     431 *      NULL: Failure
    431432 */
    432433HWND WINAPI FindTextA(
    433         LPFINDREPLACEA pfr      /* [in] Find/replace structure*/
     434    LPFINDREPLACEA pfr  /* [in] Find/replace structure*/
    434435) {
    435         COMDLG32_FR_Data *pdata;
     436    COMDLG32_FR_Data *pdata;
    436437
    437438        TRACE("LPFINDREPLACE=%p\n", pfr);
    438439
    439         if(!COMDLG32_FR_CheckPartial(pfr, FALSE))
    440                 return 0;
    441 
    442         if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data))) == NULL)
    443                 return 0; /* Error has been set */
     440    if(!COMDLG32_FR_CheckPartial(pfr, FALSE))
     441            return 0;
     442
     443    if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data))) == NULL)
     444            return 0; /* Error has been set */
    444445
    445446        pdata->user_fr.fra = pfr;
    446447        pdata->fr = *pfr;
    447         return COMDLG32_FR_DoFindReplace(pdata);
    448 }
    449 
    450 /***********************************************************************
    451  *      ReplaceTextA                            [COMDLG32.19]
    452  *      RETURNS
    453  *              Window handle to created dialog: Success
    454  *              NULL: Failure
     448    return COMDLG32_FR_DoFindReplace(pdata);
     449}
     450
     451/***********************************************************************
     452 *  ReplaceTextA                [COMDLG32.19]
     453 *  RETURNS
     454 *      Window handle to created dialog: Success
     455 *      NULL: Failure
    455456 */
    456457HWND WINAPI ReplaceTextA(
    457         LPFINDREPLACEA pfr      /* [in] Find/replace structure*/
     458    LPFINDREPLACEA pfr  /* [in] Find/replace structure*/
    458459) {
    459         COMDLG32_FR_Data *pdata;
     460    COMDLG32_FR_Data *pdata;
    460461
    461462        TRACE("LPFINDREPLACE=%p\n", pfr);
    462463
    463         if(!COMDLG32_FR_CheckPartial(pfr, TRUE))
    464                 return 0;
    465 
    466         if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data))) == NULL)
    467                 return 0; /* Error has been set */
     464    if(!COMDLG32_FR_CheckPartial(pfr, TRUE))
     465            return 0;
     466
     467    if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data))) == NULL)
     468            return 0; /* Error has been set */
    468469
    469470        pdata->user_fr.fra = pfr;
    470471        pdata->fr = *pfr;
    471         pdata->fr.Flags |= FR_WINE_REPLACE;
    472         return COMDLG32_FR_DoFindReplace(pdata);
    473 }
    474 
    475 /***********************************************************************
    476  *      FindTextW                               [COMDLG32.7]
    477  *      RETURNS
    478  *              Window handle to created dialog: Success
    479  *              NULL: Failure
     472    pdata->fr.Flags |= FR_WINE_REPLACE;
     473    return COMDLG32_FR_DoFindReplace(pdata);
     474}
     475
     476/***********************************************************************
     477 *  FindTextW               [COMDLG32.7]
     478 *  RETURNS
     479 *      Window handle to created dialog: Success
     480 *      NULL: Failure
    480481 */
    481482HWND WINAPI FindTextW(
    482         LPFINDREPLACEW pfr      /* [in] Find/replace structure*/
     483    LPFINDREPLACEW pfr  /* [in] Find/replace structure*/
    483484) {
    484         COMDLG32_FR_Data *pdata;
     485    COMDLG32_FR_Data *pdata;
    485486        DWORD len;
    486487
    487488        TRACE("LPFINDREPLACE=%p\n", pfr);
    488489
    489         if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE))
    490                 return 0;
     490    if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE))
     491            return 0;
    491492
    492493        len = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen,
     
    496497
    497498        pdata->user_fr.frw = pfr;
    498         pdata->fr = *(LPFINDREPLACEA)pfr;       /* FINDREPLACEx have same size */
    499         pdata->fr.Flags |= FR_WINE_UNICODE;
     499        pdata->fr = *(LPFINDREPLACEA)pfr;   /* FINDREPLACEx have same size */
     500    pdata->fr.Flags |= FR_WINE_UNICODE;
    500501        pdata->fr.lpstrFindWhat = (LPSTR)(pdata + 1);  /* Set string pointer */
    501502        WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen,
     
    505506
    506507/***********************************************************************
    507  *      ReplaceTextW                            [COMDLG32.20]
    508  *      RETURNS
    509  *              Window handle to created dialog: Success
    510  *              NULL: Failure
     508 *  ReplaceTextW                [COMDLG32.20]
     509 *  RETURNS
     510 *      Window handle to created dialog: Success
     511 *      NULL: Failure
    511512 */
    512513HWND WINAPI ReplaceTextW(
    513         LPFINDREPLACEW pfr      /* [in] Find/replace structure*/
     514    LPFINDREPLACEW pfr  /* [in] Find/replace structure*/
    514515) {
    515         COMDLG32_FR_Data *pdata;
     516    COMDLG32_FR_Data *pdata;
    516517        DWORD len1, len2;
    517518
    518519        TRACE("LPFINDREPLACE=%p\n", pfr);
    519520
    520         if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE))
    521                 return 0;
     521    if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE))
     522            return 0;
    522523
    523524        len1 = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen,
     
    525526        len2 = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrReplaceWith, pfr->wReplaceWithLen,
    526527                                    NULL, 0, NULL, NULL );
    527         if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data)
     528    if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data)
    528529                                                          + len1 + len2)) == NULL)
    529530            return 0; /* Error has been set */
    530531
    531532        pdata->user_fr.frw = pfr;
    532         pdata->fr = *(LPFINDREPLACEA)pfr;       /* FINDREPLACEx have same size */
    533         pdata->fr.Flags |= FR_WINE_REPLACE | FR_WINE_UNICODE;
     533        pdata->fr = *(LPFINDREPLACEA)pfr;   /* FINDREPLACEx have same size */
     534    pdata->fr.Flags |= FR_WINE_REPLACE | FR_WINE_UNICODE;
    534535        pdata->fr.lpstrFindWhat = (LPSTR)(pdata + 1);  /* Set string pointer */
    535536        pdata->fr.lpstrReplaceWith = pdata->fr.lpstrFindWhat + len1;
  • trunk/src/comdlg32/fontdlg.c

    r5583 r6645  
     1/* $Id: fontdlg.c,v 1.4 2001-09-05 12:12:02 bird Exp $ */
    12/*
    23 * COMMDLG - Font Dialog
     
    4546
    4647#ifdef __WIN32OS2__
    47 static HBITMAP hBitmapTT = 0; 
     48static HBITMAP hBitmapTT = 0;
    4849#else
    49 static HBITMAP16 hBitmapTT = 0; 
     50static HBITMAP16 hBitmapTT = 0;
    5051#endif
    5152
    5253LRESULT WINAPI FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
    53                                   LPARAM lParam);
     54                  LPARAM lParam);
    5455LRESULT WINAPI FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
    55                                   LPARAM lParam);
     56                  LPARAM lParam);
    5657
    5758#ifndef __WIN32OS2__
     
    7980
    8081/***********************************************************************
    81  *                        ChooseFont16   (COMMDLG.15)     
     82 *                        ChooseFont16   (COMMDLG.15)
    8283 */
    8384BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont)
     
    9293    LOGFONTA lf32a;
    9394    SEGPTR lpTemplateName;
    94    
     95
    9596    cf32a.lpLogFont=&lf32a;
    9697    CFn_CHOOSEFONT16to32A(lpChFont, &cf32a);
    9798
    9899    TRACE("ChooseFont\n");
    99     if (!lpChFont) return FALSE;   
     100    if (!lpChFont) return FALSE;
    100101
    101102    if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE)
     
    157158        }
    158159        ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
    159         hDlgTmpl16 = hGlobal16;         
     160        hDlgTmpl16 = hGlobal16;
    160161
    161162    }
     
    204205  if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
    205206    CF_ENABLETEMPLATEHANDLE)) FIXME(": unimplemented flag (ignored)\n");
    206   return DialogBoxIndirectParamA(COMMDLG_hInstance32, template, 
     207  return DialogBoxIndirectParamA(COMMDLG_hInstance32, template,
    207208            lpChFont->hwndOwner, (DLGPROC)FormatCharDlgProcA, (LPARAM)lpChFont );
    208209}
     
    239240  cf32a.lpszStyle=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont->lpszStyle);
    240241  lpChFont->lpTemplateName=(LPWSTR)&cf32a;
    241   bRet = DialogBoxIndirectParamW(COMMDLG_hInstance32, template, 
     242  bRet = DialogBoxIndirectParamW(COMMDLG_hInstance32, template,
    242243            lpChFont->hwndOwner, (DLGPROC)FormatCharDlgProcW, (LPARAM)lpChFont );
    243244  HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle);
     
    288289 *              AddFontFamily                               [internal]
    289290 */
    290 static INT AddFontFamily(LPLOGFONTA lplf, UINT nFontType, 
     291static INT AddFontFamily(LPLOGFONTA lplf, UINT nFontType,
    291292                           LPCHOOSEFONTA lpcf, HWND hwnd)
    292293{
     
    304305  if (lpcf->Flags & CF_TTONLY)
    305306   if (!(nFontType & TRUETYPE_FONTTYPE))
    306      return 1;   
     307     return 1;
    307308
    308309  i=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)lplf->lfFaceName);
     
    327328 *              FontFamilyEnumProc32                           [internal]
    328329 */
    329 static INT WINAPI FontFamilyEnumProc(LPENUMLOGFONTA lpEnumLogFont, 
    330           LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam)
     330static INT WINAPI FontFamilyEnumProc(LPENUMLOGFONTA lpEnumLogFont,
     331      LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam)
    331332{
    332333  LPCFn_ENUMSTRUCT e;
     
    344345  HWND16 hwnd=LOWORD(lParam);
    345346  HWND hDlg=GetParent(hwnd);
    346   LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER); 
     347  LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
    347348  LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN( logfont );
    348349  LOGFONTA lf32a;
     
    362363   #define FSTYLES 4
    363364   struct FONTSTYLE
    364           { int italic; 
     365          { int italic;
    365366            int weight;
    366367            char stname[20]; };
    367    static struct FONTSTYLE fontstyles[FSTYLES]={ 
     368   static struct FONTSTYLE fontstyles[FSTYLES]={
    368369          { 0,FW_NORMAL,"Regular"},{0,FW_BOLD,"Bold"},
    369370          { 1,FW_NORMAL,"Italic"}, {1,FW_BOLD,"Bold Italic"}};
     
    389390       j=SendMessageA(hwnd,CB_ADDSTRING,0,(LPARAM)str );
    390391       if (j==CB_ERR) return 1;
    391        j=SendMessageA(hwnd, CB_SETITEMDATA, j, 
     392       j=SendMessageA(hwnd, CB_SETITEMDATA, j,
    392393                                 MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
    393394#else
     
    396397       SEGPTR_FREE(str);
    397398       if (j==CB_ERR) return 1;
    398        j=SendMessage16(hwnd, CB_SETITEMDATA16, j, 
     399       j=SendMessage16(hwnd, CB_SETITEMDATA16, j,
    399400                                 MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
    400401#endif
    401        if (j==CB_ERR) return 1;                                 
     402       if (j==CB_ERR) return 1;
    402403     }
    403    } 
     404   }
    404405  return 0;
    405406}
     
    417418    {
    418419        sprintf(buffer, "%2d", h);
    419         j=SendMessageA(hwnd, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer);
    420         if (j==CB_ERR)
    421         {
    422             j=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)buffer);     
    423             if (j!=CB_ERR) j = SendMessageA(hwnd, CB_SETITEMDATA, j, h);
    424             if (j==CB_ERR) return 1;
    425         }
     420    j=SendMessageA(hwnd, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer);
     421    if (j==CB_ERR)
     422    {
     423            j=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)buffer);
     424            if (j!=CB_ERR) j = SendMessageA(hwnd, CB_SETITEMDATA, j, h);
     425            if (j==CB_ERR) return 1;
     426    }
    426427    }
    427428    return 0;
    428 } 
    429  
     429}
     430
    430431/*************************************************************************
    431432 *              SetFontSizesToCombo3                           [internal]
     
    444445 *                 AddFontStyle                          [internal]
    445446 */
    446 static INT AddFontStyle(LPLOGFONTA lplf, UINT nFontType, 
     447static INT AddFontStyle(LPLOGFONTA lplf, UINT nFontType,
    447448    LPCHOOSEFONTA lpcf, HWND hcmb2, HWND hcmb3, HWND hDlg)
    448449{
    449450  int i;
    450  
     451
    451452  TRACE("(nFontType=%d)\n",nFontType);
    452453  TRACE("  %s h=%ld w=%ld e=%ld o=%ld wg=%ld i=%d u=%d s=%d"
    453                " ch=%d op=%d cp=%d q=%d pf=%xh\n",
    454                lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
    455                lplf->lfEscapement,lplf->lfOrientation,
    456                lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
    457                lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
    458                lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily);
     454           " ch=%d op=%d cp=%d q=%d pf=%xh\n",
     455           lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
     456           lplf->lfEscapement,lplf->lfOrientation,
     457           lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
     458           lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
     459           lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily);
    459460  if (nFontType & RASTER_FONTTYPE)
    460461  {
     
    473474  return 1 ;
    474475
    475 }   
     476}
    476477
    477478#ifndef __WIN32OS2__
     
    485486  HWND16 hcmb3=HIWORD(lParam);
    486487  HWND hDlg=GetParent(hcmb3);
    487   LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER); 
     488  LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
    488489  LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN(logfont);
    489490  LOGFONTA lf32a;
     
    497498 *                 FontStyleEnumProc32                     [internal]
    498499 */
    499 static INT WINAPI FontStyleEnumProc( LPENUMLOGFONTA lpFont, 
     500static INT WINAPI FontStyleEnumProc( LPENUMLOGFONTA lpFont,
    500501          LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam )
    501502{
     
    520521  HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
    521522
    522   SetWindowLongA(hDlg, DWL_USER, lParam); 
     523  SetWindowLongA(hDlg, DWL_USER, lParam);
    523524  lpxx=lpcf->lpLogFont;
    524525  TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
     
    527528  {
    528529    ERR("structure size failure !!!\n");
    529     EndDialog (hDlg, 0); 
     530    EndDialog (hDlg, 0);
    530531    return FALSE;
    531532  }
     
    536537  SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,
    537538     CreateFontA(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL),FALSE);
    538                          
     539
    539540  if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow(lpcf->hwndOwner))
    540541    ShowWindow(GetDlgItem(hDlg,pshHelp),SW_HIDE);
     
    582583      {
    583584        SendDlgItemMessageA(hDlg, cmb1, CB_SETCURSEL, j, 0);
    584         SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
     585    SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
    585586                       GetDlgItem(hDlg,cmb1));
    586587        init=1;
     
    592593            SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0);
    593594        }
    594      
     595
    595596        /* look for fitting font size in combobox3 */
    596597        j=SendDlgItemMessageA(hDlg, cmb3, CB_GETCOUNT, 0, 0);
     
    607608      SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
    608609                       GetDlgItem(hDlg,cmb1));
    609     }   
     610    }
    610611    if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
    611612    {
     
    622623  {
    623624    WARN("HDC failure !!!\n");
    624     EndDialog (hDlg, 0); 
     625    EndDialog (hDlg, 0);
    625626    return FALSE;
    626627  }
     
    628629  if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
    629630    ReleaseDC(hDlg,hdc);
    630   SetCursor(hcursor);   
     631  SetCursor(hcursor);
    631632  return TRUE;
    632633}
     
    659660  COLORREF cr, oldText=0, oldBk=0;
    660661  RECT rect;
    661 #if 0 
     662#if 0
    662663  HDC hMemDC;
    663664  int nFontType;
    664665  HBITMAP hBitmap; /* for later TT usage */
    665 #endif 
     666#endif
    666667  LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
    667668
    668   if (lpdi->itemID == 0xFFFF)                   /* got no items */
     669  if (lpdi->itemID == 0xFFFF)           /* got no items */
    669670    DrawFocusRect(lpdi->hDC, &lpdi->rcItem);
    670671  else
     
    685686   }
    686687   else
    687      return TRUE;       /* this should never happen */
     688     return TRUE;   /* this should never happen */
    688689
    689690   rect=lpdi->rcItem;
    690691   switch (lpdi->CtlID)
    691692   {
    692     case cmb1:  /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
    693                 SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
    694                                (LPARAM)buffer);           
    695                 GetObjectA( hBitmapTT, sizeof(bm), &bm );
    696                 TextOutA(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
     693    case cmb1:  /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
     694        SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
     695                   (LPARAM)buffer);
     696        GetObjectA( hBitmapTT, sizeof(bm), &bm );
     697        TextOutA(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
    697698                           lpdi->rcItem.top, buffer, strlen(buffer));
    698699#if 0
    699                 nFontType = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
    700                   /* FIXME: draw bitmap if truetype usage */
    701                 if (nFontType&TRUETYPE_FONTTYPE)
    702                 {
    703                   hMemDC = CreateCompatibleDC(lpdi->hDC);
    704                   hBitmap = SelectObject(hMemDC, hBitmapTT);
    705                   BitBlt(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
     700        nFontType = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
     701          /* FIXME: draw bitmap if truetype usage */
     702        if (nFontType&TRUETYPE_FONTTYPE)
     703        {
     704          hMemDC = CreateCompatibleDC(lpdi->hDC);
     705          hBitmap = SelectObject(hMemDC, hBitmapTT);
     706          BitBlt(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
    706707                           bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
    707                   SelectObject(hMemDC, hBitmap);
    708                   DeleteDC(hMemDC);
    709                 }
     708          SelectObject(hMemDC, hBitmap);
     709          DeleteDC(hMemDC);
     710        }
    710711#endif
    711                 break;
     712        break;
    712713    case cmb2:
    713     case cmb3:  /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
    714                 SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
    715                                (LPARAM)buffer);
    716                 TextOutA(lpdi->hDC, lpdi->rcItem.left,
     714    case cmb3:  /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
     715        SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
     716                       (LPARAM)buffer);
     717        TextOutA(lpdi->hDC, lpdi->rcItem.left,
    717718                           lpdi->rcItem.top, buffer, strlen(buffer));
    718                 break;
    719 
    720     case cmb4:  /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
    721                 SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
    722                                (LPARAM)buffer);
    723                 TextOutA(lpdi->hDC, lpdi->rcItem.left +  25+5,
     719        break;
     720
     721    case cmb4:  /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
     722        SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
     723                           (LPARAM)buffer);
     724        TextOutA(lpdi->hDC, lpdi->rcItem.left +  25+5,
    724725                           lpdi->rcItem.top, buffer, strlen(buffer));
    725                 cr = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
    726                 hBrush = CreateSolidBrush(cr);
    727                 if (hBrush)
    728                 {
    729                   hBrush = SelectObject (lpdi->hDC, hBrush) ;
    730                   rect.right=rect.left+25;
    731                   rect.top++;
    732                   rect.left+=5;
    733                   rect.bottom--;
    734                   Rectangle( lpdi->hDC, rect.left, rect.top,
     726        cr = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
     727        hBrush = CreateSolidBrush(cr);
     728        if (hBrush)
     729        {
     730          hBrush = SelectObject (lpdi->hDC, hBrush) ;
     731          rect.right=rect.left+25;
     732          rect.top++;
     733          rect.left+=5;
     734          rect.bottom--;
     735          Rectangle( lpdi->hDC, rect.left, rect.top,
    735736                               rect.right, rect.bottom );
    736                   DeleteObject( SelectObject (lpdi->hDC, hBrush)) ;
    737                 }
    738                 rect=lpdi->rcItem;
    739                 rect.left+=25+5;
    740                 break;
    741 
    742     default:    return TRUE;    /* this should never happen */
     737          DeleteObject( SelectObject (lpdi->hDC, hBrush)) ;
     738        }
     739        rect=lpdi->rcItem;
     740        rect.left+=25+5;
     741        break;
     742
     743    default:    return TRUE;    /* this should never happen */
    743744   }
    744745   if (lpdi->itemState == ODS_SELECTED)
     
    777778  HDC hdc;
    778779  LPLOGFONTA lpxx=lpcf->lpLogFont;
    779  
     780
    780781  TRACE("WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG)wParam, lParam);
    781782  switch (LOWORD(wParam))
    782783  {
    783         case cmb1:if (HIWORD(wParam)==CBN_SELCHANGE)
    784                   {
    785                     hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
    786                     if (hdc)
    787                     {
     784    case cmb1:if (HIWORD(wParam)==CBN_SELCHANGE)
     785          {
     786            hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
     787            if (hdc)
     788            {
    788789#ifdef __WIN32OS2__
    789                       SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT, 0, 0); 
    790                       SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT, 0, 0);
    791                       i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL, 0, 0);
     790                      SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT, 0, 0);
     791              SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT, 0, 0);
     792              i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL, 0, 0);
    792793#else
    793                       SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT16, 0, 0); 
    794                       SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT16, 0, 0);
    795                       i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL16, 0, 0);
     794                      SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT16, 0, 0);
     795              SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT16, 0, 0);
     796              i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL16, 0, 0);
    796797#endif
    797                       if (i!=CB_ERR)
    798                       {
    799                         HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
    800                         CFn_ENUMSTRUCT s;
     798              if (i!=CB_ERR)
     799              {
     800                HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
     801            CFn_ENUMSTRUCT s;
    801802                        char str[256];
    802803                        SendDlgItemMessageA(hDlg, cmb1, CB_GETLBTEXT, i,
    803804                                              (LPARAM)str);
    804                         TRACE("WM_COMMAND/cmb1 =>%s\n",str);
    805                         s.hWnd1=GetDlgItem(hDlg, cmb2);
    806                         s.hWnd2=GetDlgItem(hDlg, cmb3);
    807                         s.lpcf32a=lpcf;
    808                         EnumFontFamiliesA(hdc, str, FontStyleEnumProc, (LPARAM)&s);
    809                         SetCursor(hcursor);
    810                       }
    811                       if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
    812                         ReleaseDC(hDlg,hdc);
    813                     }
    814                     else
     805                    TRACE("WM_COMMAND/cmb1 =>%s\n",str);
     806            s.hWnd1=GetDlgItem(hDlg, cmb2);
     807            s.hWnd2=GetDlgItem(hDlg, cmb3);
     808            s.lpcf32a=lpcf;
     809                    EnumFontFamiliesA(hdc, str, FontStyleEnumProc, (LPARAM)&s);
     810                SetCursor(hcursor);
     811              }
     812              if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
     813                ReleaseDC(hDlg,hdc);
     814            }
     815            else
    815816                    {
    816817                      WARN("HDC failure !!!\n");
    817                       EndDialog (hDlg, 0); 
     818                      EndDialog (hDlg, 0);
    818819                      return TRUE;
    819820                    }
    820                   }
    821         case chx1:
    822         case chx2:
    823         case cmb2:
    824         case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
    825                   {
     821              }
     822    case chx1:
     823    case chx2:
     824    case cmb2:
     825    case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
     826              {
    826827                    char str[256];
    827828                    TRACE("WM_COMMAND/cmb2,3 =%08lX\n", lParam);
    828                     i=SendDlgItemMessageA(hDlg,cmb1,CB_GETCURSEL,0,0);
    829                     if (i==CB_ERR)
     829            i=SendDlgItemMessageA(hDlg,cmb1,CB_GETCURSEL,0,0);
     830            if (i==CB_ERR)
    830831                      i=GetDlgItemTextA( hDlg, cmb1, str, 256 );
    831832                    else
    832833                    {
    833                       SendDlgItemMessageA(hDlg,cmb1,CB_GETLBTEXT,i,
    834                                             (LPARAM)str);
    835                       l=SendDlgItemMessageA(hDlg,cmb1,CB_GETITEMDATA,i,0);
    836                       j=HIWORD(l);
    837                       lpcf->nFontType = LOWORD(l);
    838                       /* FIXME:   lpcf->nFontType |= ....  SIMULATED_FONTTYPE and so */
    839                       /* same value reported to the EnumFonts
    840                        call back with the extra FONTTYPE_...  bits added */
    841                       lpxx->lfPitchAndFamily=j&0xff;
    842                       lpxx->lfCharSet=j>>8;
     834              SendDlgItemMessageA(hDlg,cmb1,CB_GETLBTEXT,i,
     835                                    (LPARAM)str);
     836              l=SendDlgItemMessageA(hDlg,cmb1,CB_GETITEMDATA,i,0);
     837              j=HIWORD(l);
     838              lpcf->nFontType = LOWORD(l);
     839              /* FIXME:   lpcf->nFontType |= ....  SIMULATED_FONTTYPE and so */
     840              /* same value reported to the EnumFonts
     841               call back with the extra FONTTYPE_...  bits added */
     842              lpxx->lfPitchAndFamily=j&0xff;
     843              lpxx->lfCharSet=j>>8;
    843844                    }
    844845                    strcpy(lpxx->lfFaceName,str);
    845                     i=SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
    846                     if (i!=CB_ERR)
    847                     {
    848                       l=SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0);
    849                       if (0!=(lpxx->lfItalic=HIWORD(l)))
    850                         lpcf->nFontType |= ITALIC_FONTTYPE;
    851                       if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
    852                         lpcf->nFontType |= BOLD_FONTTYPE;
    853                     }
    854                     i=SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
    855                     if (i!=CB_ERR)
    856                       lpxx->lfHeight=-LOWORD(SendDlgItemMessageA(hDlg, cmb3, CB_GETITEMDATA, i, 0));
    857                     else
    858                       lpxx->lfHeight=0;
    859                     lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
    860                     lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2);
    861                     lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
    862                     lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
    863                     lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
    864                     lpxx->lfQuality=DEFAULT_QUALITY;
     846            i=SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
     847            if (i!=CB_ERR)
     848            {
     849              l=SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0);
     850              if (0!=(lpxx->lfItalic=HIWORD(l)))
     851                lpcf->nFontType |= ITALIC_FONTTYPE;
     852              if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
     853                lpcf->nFontType |= BOLD_FONTTYPE;
     854            }
     855            i=SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
     856            if (i!=CB_ERR)
     857              lpxx->lfHeight=-LOWORD(SendDlgItemMessageA(hDlg, cmb3, CB_GETITEMDATA, i, 0));
     858            else
     859              lpxx->lfHeight=0;
     860            lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
     861            lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2);
     862            lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
     863            lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
     864            lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
     865            lpxx->lfQuality=DEFAULT_QUALITY;
    865866                    lpcf->iPointSize= -10*lpxx->lfHeight;
    866867
    867                     hFont=CreateFontIndirectA(lpxx);
    868                     if (hFont)
    869                     {
    870                       HFONT oldFont=SendDlgItemMessageA(hDlg, stc6,
    871                           WM_GETFONT, 0, 0);
    872                       SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,hFont,TRUE);
    873                       DeleteObject(oldFont);
    874                     }
     868            hFont=CreateFontIndirectA(lpxx);
     869            if (hFont)
     870            {
     871              HFONT oldFont=SendDlgItemMessageA(hDlg, stc6,
     872                  WM_GETFONT, 0, 0);
     873              SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,hFont,TRUE);
     874              DeleteObject(oldFont);
     875            }
    875876                  }
    876877                  break;
    877878
    878         case cmb4:i=SendDlgItemMessageA(hDlg, cmb4, CB_GETCURSEL, 0, 0);
    879                   if (i!=CB_ERR)
    880                   {
    881                    lpcf->rgbColors=textcolors[i];
    882                    InvalidateRect( GetDlgItem(hDlg,stc6), NULL, 0 );
    883                   }
    884                   break;
    885        
    886         case psh15:i=RegisterWindowMessageA( HELPMSGSTRINGA );
    887                   if (lpcf->hwndOwner)
    888                     SendMessageA(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLongA(hDlg, DWL_USER));
    889 /*                if (CFn_HookCallChk(lpcf))
    890                     CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
    891                   break;
    892 
    893         case IDOK:if (  (!(lpcf->Flags & CF_LIMITSIZE))  ||
    894                      ( (lpcf->Flags & CF_LIMITSIZE) && 
    895                       (-lpxx->lfHeight >= lpcf->nSizeMin) && 
     879    case cmb4:i=SendDlgItemMessageA(hDlg, cmb4, CB_GETCURSEL, 0, 0);
     880          if (i!=CB_ERR)
     881          {
     882           lpcf->rgbColors=textcolors[i];
     883           InvalidateRect( GetDlgItem(hDlg,stc6), NULL, 0 );
     884          }
     885          break;
     886
     887    case psh15:i=RegisterWindowMessageA( HELPMSGSTRINGA );
     888          if (lpcf->hwndOwner)
     889            SendMessageA(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLongA(hDlg, DWL_USER));
     890/*        if (CFn_HookCallChk(lpcf))
     891            CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
     892          break;
     893
     894    case IDOK:if (  (!(lpcf->Flags & CF_LIMITSIZE))  ||
     895                     ( (lpcf->Flags & CF_LIMITSIZE) &&
     896                      (-lpxx->lfHeight >= lpcf->nSizeMin) &&
    896897                      (-lpxx->lfHeight <= lpcf->nSizeMax)))
    897                      EndDialog(hDlg, TRUE);
    898                   else
    899                   {
     898                 EndDialog(hDlg, TRUE);
     899              else
     900              {
    900901                   char buffer[80];
    901                    sprintf(buffer,"Select a font size between %d and %d points.",
     902               sprintf(buffer,"Select a font size between %d and %d points.",
    902903                           lpcf->nSizeMin,lpcf->nSizeMax);
    903                    MessageBoxA(hDlg, buffer, NULL, MB_OK);
    904                   }
    905                   return(TRUE);
    906         case IDCANCEL:EndDialog(hDlg, FALSE);
    907                   return(TRUE);
    908         }
     904               MessageBoxA(hDlg, buffer, NULL, MB_OK);
     905              }
     906          return(TRUE);
     907    case IDCANCEL:EndDialog(hDlg, FALSE);
     908          return(TRUE);
     909    }
    909910      return(FALSE);
    910911}
     
    930931  UINT uMsg32;
    931932  WPARAM wParam32;
    932   LRESULT res=0; 
     933  LRESULT res=0;
    933934  if (message!=WM_INITDIALOG)
    934935  {
    935    lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);   
     936   lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
    936937   if (!lpcf)
    937938      return FALSE;
     
    945946    lpcf=(LPCHOOSEFONT16)lParam;
    946947    lpcf32a=(LPCHOOSEFONTA)lpcf->lpTemplateName;
    947     if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a)) 
     948    if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
    948949    {
    949950      TRACE("CFn_WMInitDialog returned FALSE\n");
    950951      return FALSE;
    951     } 
     952    }
    952953    if (CFn_HookCallChk(lpcf))
    953954      return CallWindowProc16((WNDPROC16)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
     
    959960      case WM_MEASUREITEM:
    960961                        res=CFn_WMMeasureItem(hDlg, wParam32, lParam);
    961                         break;
     962            break;
    962963      case WM_DRAWITEM:
    963964                        res=CFn_WMDrawItem(hDlg, wParam32, lParam);
    964                         break;
     965            break;
    965966      case WM_CTLCOLORSTATIC:
    966967                        res=CFn_WMCtlColorStatic(hDlg, wParam32, lParam, lpcf32a);
    967                         break;
     968            break;
    968969      case WM_COMMAND:
    969970                        res=CFn_WMCommand(hDlg, wParam32, lParam, lpcf32a);
    970                         break;
     971            break;
    971972      case WM_DESTROY:
    972973                        res=CFn_WMDestroy(hDlg, wParam32, lParam);
    973                         break;
    974       case WM_CHOOSEFONT_GETLOGFONT: 
     974            break;
     975      case WM_CHOOSEFONT_GETLOGFONT:
    975976                         TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
    976                                       lParam);
    977                         FIXME("current logfont back to caller\n");
     977                      lParam);
     978            FIXME("current logfont back to caller\n");
    978979                        break;
    979980    }
    980   WINPROC_UnmapMsg16To32A(hDlg,uMsg32, wParam32, lParam, res);   
     981  WINPROC_UnmapMsg16To32A(hDlg,uMsg32, wParam32, lParam, res);
    981982  return res;
    982983}
     
    993994  if (uMsg!=WM_INITDIALOG)
    994995  {
    995    lpcf=(LPCHOOSEFONTA)GetWindowLongA(hDlg, DWL_USER);   
     996   lpcf=(LPCHOOSEFONTA)GetWindowLongA(hDlg, DWL_USER);
    996997   if (!lpcf)
    997998     return FALSE;
     
    10041005  {
    10051006    lpcf=(LPCHOOSEFONTA)lParam;
    1006     if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf)) 
     1007    if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
    10071008    {
    10081009      TRACE("CFn_WMInitDialog returned FALSE\n");
    10091010      return FALSE;
    1010     } 
     1011    }
    10111012    if (CFn_HookCallChk32(lpcf))
    10121013      return CallWindowProcA((WNDPROC)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
     
    10261027      case WM_CHOOSEFONT_GETLOGFONT:
    10271028                         TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
    1028                                       lParam);
    1029                         FIXME("current logfont back to caller\n");
     1029                      lParam);
     1030            FIXME("current logfont back to caller\n");
    10301031                        break;
    10311032    }
     
    10441045  if (uMsg!=WM_INITDIALOG)
    10451046  {
    1046    lpcf32w=(LPCHOOSEFONTW)GetWindowLongA(hDlg, DWL_USER);   
     1047   lpcf32w=(LPCHOOSEFONTW)GetWindowLongA(hDlg, DWL_USER);
    10471048   if (!lpcf32w)
    10481049     return FALSE;
     
    10561057    lpcf32w=(LPCHOOSEFONTW)lParam;
    10571058    lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName;
    1058     if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a)) 
     1059    if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
    10591060    {
    10601061      TRACE("CFn_WMInitDialog returned FALSE\n");
    10611062      return FALSE;
    1062     } 
     1063    }
    10631064    if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
    10641065      return CallWindowProcW((WNDPROC)lpcf32w->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
     
    10771078      case WM_DESTROY:
    10781079                        return CFn_WMDestroy(hDlg, wParam, lParam);
    1079       case WM_CHOOSEFONT_GETLOGFONT: 
     1080      case WM_CHOOSEFONT_GETLOGFONT:
    10801081                         TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
    1081                                       lParam);
    1082                         FIXME("current logfont back to caller\n");
     1082                      lParam);
     1083            FIXME("current logfont back to caller\n");
    10831084                        break;
    10841085    }
  • trunk/src/comdlg32/initcomdlg32.cpp

    r6401 r6645  
     1/* $Id: initcomdlg32.cpp,v 1.3 2001-09-05 12:12:02 bird Exp $ */
    12/*
    23 * DLL entry point
     
    5455   case DLL_THREAD_ATTACH:
    5556   case DLL_THREAD_DETACH:
    56         return COMDLG32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
     57    return COMDLG32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
    5758
    5859   case DLL_PROCESS_DETACH:
    59         COMDLG32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
    60         return TRUE;
     60    COMDLG32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
     61    return TRUE;
    6162   }
    6263   return FALSE;
     
    8384   switch (ulFlag) {
    8485      case 0 :
    85         dllHandle = RegisterLxDll(hModule, LibMainComdlg32, (PVOID)&comdlg32_PEResTab,
     86    dllHandle = RegisterLxDll(hModule, LibMainComdlg32, (PVOID)&comdlg32_PEResTab,
    8687                                   COMDLG32_MAJORIMAGE_VERSION, COMDLG32_MINORIMAGE_VERSION,
    8788                                   IMAGE_SUBSYSTEM_WINDOWS_GUI);
    88          if(dllHandle == 0) 
    89                 return 0UL;
     89         if(dllHandle == 0)
     90        return 0UL;
    9091
    9192         break;
    9293      case 1 :
    9394         if(dllHandle) {
    94                 UnregisterLxDll(dllHandle);
     95        UnregisterLxDll(dllHandle);
    9596         }
    9697         break;
  • trunk/src/comdlg32/initterm.cpp

    r6375 r6645  
     1/* $Id: initterm.cpp,v 1.14 2001-09-05 12:12:02 bird Exp $ */
    12/*
    23 * DLL entry point
     
    6667      case 1 :
    6768         inittermComdlg32(hModule, ulFlag);
    68         ctordtorTerm();
     69    ctordtorTerm();
    6970         break;
    7071
  • trunk/src/comdlg32/printdlg.c

    r6335 r6645  
     1/* $Id: printdlg.c,v 1.2 2001-09-05 12:12:02 bird Exp $ */
    12/*
    23 * COMMDLG - Print Dialog
     
    3031/* This PRINTDLGA internal structure stores
    3132 * pointers to several throughout useful structures.
    32  * 
    33  */
    34 typedef struct 
     33 *
     34 */
     35typedef struct
    3536{
    3637  LPDEVMODEA        lpDevMode;
    3738  struct {
    3839      LPPRINTDLGA       lpPrintDlg;
    39       LPPRINTDLG16      lpPrintDlg16;
     40      LPPRINTDLG16  lpPrintDlg16;
    4041  } dlg;
    4142  LPPRINTER_INFO_2A lpPrinterInfo;
     
    108109 *
    109110 * Returns the default printer name in buf.
    110  * Even under WinNT/2000 default printer is retrieved via GetProfileString - 
     111 * Even under WinNT/2000 default printer is retrieved via GetProfileString -
    111112 * these entries are mapped somewhere in the registry rather than win.ini.
    112113 *
     
    118119
    119120    if(!GetProfileStringA("windows", "device", "", buf, len)) {
    120         TRACE("No profile entry for default printer found.\n");
    121         return FALSE;
     121    TRACE("No profile entry for default printer found.\n");
     122    return FALSE;
    122123    }
    123124    if((ptr = strchr(buf, ',')) == NULL) {
    124         FIXME("bad format for default printer (%s)!\n",buf);
    125         return FALSE;
     125    FIXME("bad format for default printer (%s)!\n",buf);
     126    return FALSE;
    126127    }
    127128    *ptr = '\0';
     
    145146    res = OpenPrinterA(buf, hprn, NULL);
    146147    if (!res)
    147         FIXME("Could not open printer %s?!\n",buf);
     148    FIXME("Could not open printer %s?!\n",buf);
    148149    return res;
    149150}
     
    169170    EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
    170171    pi = HeapAlloc(GetProcessHeap(), 0, needed);
    171     EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed, 
    172                   &num);
     172    EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed,
     173          &num);
    173174
    174175    for(i = 0; i < num; i++) {
    175176        SendDlgItemMessageA(hDlg, id, CB_ADDSTRING, 0,
    176                             (LPARAM)pi[i].pPrinterName );
     177                (LPARAM)pi[i].pPrinterName );
    177178    }
    178179    HeapFree(GetProcessHeap(), 0, pi);
    179180    if(!name ||
    180181       (i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1,
    181                                 (LPARAM)name)) == CB_ERR) {
     182                (LPARAM)name)) == CB_ERR) {
    182183
    183184        char buf[260];
    184185        FIXME("Can't find '%s' in printer list so trying to find default\n",
    185               name);
    186         if(!PRINTDLG_GetDefaultPrinterName(buf, sizeof(buf)))
    187             return num;
    188         i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);
    189         if(i == CB_ERR)
    190             FIXME("Can't find default printer in printer list\n");
     186          name);
     187    if(!PRINTDLG_GetDefaultPrinterName(buf, sizeof(buf)))
     188        return num;
     189    i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);
     190    if(i == CB_ERR)
     191        FIXME("Can't find default printer in printer list\n");
    191192    }
    192193    SendDlgItemMessageA(hDlg, id, CB_SETCURSEL, i, 0);
     
    202203 *  (NB. when we handle unicode the offsets will be in wchars).
    203204 */
    204 static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName, 
    205                                     char* DeviceName, char* OutputPort)
     205static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName,
     206                    char* DeviceName, char* OutputPort)
    206207{
    207208    long size;
     
    215216            + strlen(OutputPort) + 1
    216217            + sizeof(DEVNAMES);
    217            
     218
    218219    if(*hmem)
    219220        *hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE);
     
    233234    strcpy(pTempPtr, DeviceName);
    234235    lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
    235        
     236
    236237    pTempPtr += strlen(DeviceName) + 1;
    237238    strcpy(pTempPtr, OutputPort);
     
    244245}
    245246#ifndef __WIN32OS2__
    246 static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName, 
    247                                       char* DeviceName, char* OutputPort)
     247static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName,
     248                      char* DeviceName, char* OutputPort)
    248249{
    249250    long size;
     
    257258            + strlen(OutputPort) + 1
    258259            + sizeof(DEVNAMES);
    259            
     260
    260261    if(*hmem)
    261262        *hmem = GlobalReAlloc16(*hmem, size, GMEM_MOVEABLE);
     
    275276    strcpy(pTempPtr, DeviceName);
    276277    lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
    277        
     278
    278279    pTempPtr += strlen(DeviceName) + 1;
    279280    strcpy(pTempPtr, OutputPort);
     
    292293 *
    293294 *   updates the PrintDlg structure for returnvalues.
    294  *     
     295 *
    295296 * RETURNS
    296297 *   FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values)
    297298 *   TRUE  if succesful.
    298299 */
    299 static BOOL PRINTDLG_UpdatePrintDlg(HWND hDlg, 
    300                                     PRINT_PTRA* PrintStructures)
     300static BOOL PRINTDLG_UpdatePrintDlg(HWND hDlg,
     301                    PRINT_PTRA* PrintStructures)
    301302{
    302303    LPPRINTDLGA       lppd = PrintStructures->dlg.lpPrintDlg;
     
    306307
    307308    if(!lpdm) {
    308         FIXME("No lpdm ptr?\n");
    309         return FALSE;
     309    FIXME("No lpdm ptr?\n");
     310    return FALSE;
    310311    }
    311312
     
    313314    if(!(lppd->Flags & PD_PRINTSETUP)) {
    314315        /* check whether nFromPage and nToPage are within range defined by
    315         * nMinPage and nMaxPage
    316         */
     316    * nMinPage and nMaxPage
     317    */
    317318        if (IsDlgButtonChecked(hDlg, rad3) == BST_CHECKED) { /* Pages */
    318             WORD nToPage;
    319             WORD nFromPage;
    320             nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
    321             nToPage   = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
    322             if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||
    323                 nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) {
    324                 char resourcestr[256];
    325                 char resultstr[256];
    326                 LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE,
    327                             resourcestr, 255);
    328                 sprintf(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage);
    329                 LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE,
    330                             resourcestr, 255);
    331                 MessageBoxA(hDlg, resultstr, resourcestr,
    332                             MB_OK | MB_ICONWARNING);
    333                 return FALSE;
    334             }
    335             lppd->nFromPage = nFromPage;
    336             lppd->nToPage   = nToPage;
    337         }
    338 
    339         if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */
    340             lppd->Flags |= PD_PRINTTOFILE;
    341             pi->pPortName = "FILE:";
    342         }
    343 
    344         if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) { /* Collate */
    345             FIXME("Collate lppd not yet implemented as output\n");
    346         }
    347 
    348         /* set PD_Collate and nCopies */
    349         if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
    350           /*  The application doesn't support multiple copies or collate...
    351            */
    352             lppd->Flags &= ~PD_COLLATE;
    353             lppd->nCopies = 1;
    354           /* if the printer driver supports it... store info there
    355            * otherwise no collate & multiple copies !
    356            */
    357             if (lpdm->dmFields & DM_COLLATE)
    358                 lpdm->dmCollate =
    359                   (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED);
    360             if (lpdm->dmFields & DM_COPIES)
    361                 lpdm->dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
    362         } else {
    363             if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
    364                 lppd->Flags |= PD_COLLATE;
     319        WORD nToPage;
     320        WORD nFromPage;
     321        nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
     322        nToPage   = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
     323        if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||
     324        nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) {
     325            char resourcestr[256];
     326        char resultstr[256];
     327        LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE,
     328                resourcestr, 255);
     329        sprintf(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage);
     330        LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE,
     331                resourcestr, 255);
     332        MessageBoxA(hDlg, resultstr, resourcestr,
     333                MB_OK | MB_ICONWARNING);
     334        return FALSE;
     335        }
     336        lppd->nFromPage = nFromPage;
     337        lppd->nToPage   = nToPage;
     338    }
     339
     340    if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */
     341        lppd->Flags |= PD_PRINTTOFILE;
     342        pi->pPortName = "FILE:";
     343    }
     344
     345    if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) { /* Collate */
     346        FIXME("Collate lppd not yet implemented as output\n");
     347    }
     348
     349    /* set PD_Collate and nCopies */
     350    if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
     351      /*  The application doesn't support multiple copies or collate...
     352       */
     353        lppd->Flags &= ~PD_COLLATE;
     354        lppd->nCopies = 1;
     355      /* if the printer driver supports it... store info there
     356       * otherwise no collate & multiple copies !
     357       */
     358        if (lpdm->dmFields & DM_COLLATE)
     359            lpdm->dmCollate =
     360          (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED);
     361        if (lpdm->dmFields & DM_COPIES)
     362            lpdm->dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
     363    } else {
     364        if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
     365            lppd->Flags |= PD_COLLATE;
    365366            else
    366367               lppd->Flags &= ~PD_COLLATE;
    367368            lppd->nCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
    368         }
     369    }
    369370    }
    370371    return TRUE;
     
    372373
    373374static BOOL PRINTDLG_PaperSize(
    374         PRINTDLGA       *pdlga,const char *PaperSize,LPPOINT size
     375    PRINTDLGA   *pdlga,const char *PaperSize,LPPOINT size
    375376) {
    376     DEVNAMES    *dn;
    377     DEVMODEA    *dm;
    378     LPSTR       devname,portname;
    379     int         i;
    380     DWORD       NrOfEntries,ret;
    381     char        *Names = NULL;
    382     POINT       *points = NULL;
    383     BOOL        retval = FALSE;
    384    
     377    DEVNAMES    *dn;
     378    DEVMODEA    *dm;
     379    LPSTR   devname,portname;
     380    int     i;
     381    DWORD   NrOfEntries,ret;
     382    char    *Names = NULL;
     383    POINT   *points = NULL;
     384    BOOL    retval = FALSE;
     385
    385386    dn = GlobalLock(pdlga->hDevNames);
    386387    dm = GlobalLock(pdlga->hDevMode);
    387     devname     = ((char*)dn)+dn->wDeviceOffset;
    388     portname    = ((char*)dn)+dn->wOutputOffset;
     388    devname = ((char*)dn)+dn->wDeviceOffset;
     389    portname    = ((char*)dn)+dn->wOutputOffset;
    389390
    390391
    391392    NrOfEntries = DeviceCapabilitiesA(devname,portname,DC_PAPERNAMES,NULL,dm);
    392393    if (!NrOfEntries) {
    393         FIXME("No papernames found for %s/%s\n",devname,portname);
    394         goto out;
     394    FIXME("No papernames found for %s/%s\n",devname,portname);
     395    goto out;
    395396    }
    396397    Names = (char*)HeapAlloc(GetProcessHeap(),0,NrOfEntries*64);
    397398    if (NrOfEntries != (ret=DeviceCapabilitiesA(devname,portname,DC_PAPERNAMES,Names,dm))) {
    398         FIXME("Number of returned vals %ld is not %ld\n",NrOfEntries,ret);
    399         goto out;
     399    FIXME("Number of returned vals %ld is not %ld\n",NrOfEntries,ret);
     400    goto out;
    400401    }
    401402    for (i=0;i<NrOfEntries;i++)
    402         if (!strcmp(PaperSize,Names+(64*i)))
    403             break;
     403    if (!strcmp(PaperSize,Names+(64*i)))
     404        break;
    404405    HeapFree(GetProcessHeap(),0,Names);
    405406    if (i==NrOfEntries) {
    406         FIXME("Papersize %s not found in list?\n",PaperSize);
    407         goto out;
     407    FIXME("Papersize %s not found in list?\n",PaperSize);
     408    goto out;
    408409    }
    409410    points = HeapAlloc(GetProcessHeap(),0,sizeof(points[0])*NrOfEntries);
    410411    if (NrOfEntries!=(ret=DeviceCapabilitiesA(devname,portname,DC_PAPERSIZE,(LPBYTE)points,dm))) {
    411         FIXME("Number of returned sizes %ld is not %ld?\n",NrOfEntries,ret);
    412         goto out;
     412    FIXME("Number of returned sizes %ld is not %ld?\n",NrOfEntries,ret);
     413    goto out;
    413414    }
    414415    /* this is _10ths_ of a millimeter */
     
    434435 */
    435436static BOOL PRINTDLG_SetUpPaperComboBox(HWND hDlg,
    436                                         int   nIDComboBox,
    437                                         char* PrinterName,
    438                                         char* PortName,
    439                                         LPDEVMODEA dm)
     437                    int   nIDComboBox,
     438                    char* PrinterName,
     439                    char* PortName,
     440                    LPDEVMODEA dm)
    440441{
    441442    int     i;
     
    448449    int     fwCapability_Names;
    449450    int     fwCapability_Words;
    450    
     451
    451452    TRACE(" Printer: %s, ComboID: %d\n",PrinterName,nIDComboBox);
    452    
     453
    453454    /* query the dialog box for the current selected value */
    454455    Sel = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0);
     
    498499         fwCapability_Words = DC_BINS;
    499500    }
    500    
    501     /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the 
     501
     502    /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the
    502503     * paper settings. As Wine doesn't allow VXDs, this results in a crash.
    503504     */
     
    511512       != NrOfEntries) {
    512513        ERR("Number of caps is different\n");
    513         NrOfEntries = 0;
     514    NrOfEntries = 0;
    514515    }
    515516
     
    519520                                      fwCapability_Names, Names, dm);
    520521    NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
    521                                       fwCapability_Words, (LPSTR)Words, dm);
     522                      fwCapability_Words, (LPSTR)Words, dm);
    522523
    523524    /* reset any current content in the combobox */
    524525    SendDlgItemMessageA(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0);
    525    
     526
    526527    /* store new content */
    527528    for (i = 0; i < NrOfEntries; i++) {
    528529        DWORD pos = SendDlgItemMessageA(hDlg, nIDComboBox, CB_ADDSTRING, 0,
    529                                         (LPARAM)(&Names[i*NamesSize]) );
    530         SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos,
    531                             Words[i]);
     530                    (LPARAM)(&Names[i*NamesSize]) );
     531    SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos,
     532                Words[i]);
    532533    }
    533534
     
    537538    for (i = 0; i < NrOfEntries; i++) {
    538539        if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) ==
    539            oldWord) {
    540             Sel = i;
    541             break;
    542         }
     540       oldWord) {
     541        Sel = i;
     542        break;
     543    }
    543544    }
    544545    SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0);
     
    564565    for (i = 0; i < 25; i++) {
    565566        if (pi->Status & (1<<i)) {
    566             LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i,
    567                         ResourceString, 255);
    568             strcat(StatusMsg,ResourceString);
     567        LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i,
     568            ResourceString, 255);
     569        strcat(StatusMsg,ResourceString);
    569570        }
    570571    }
    571572    /* append "ready" */
    572     /* FIXME: status==ready must only be appended if really so. 
     573    /* FIXME: status==ready must only be appended if really so.
    573574              but how to detect? */
    574     LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY, 
    575                 ResourceString, 255);
     575    LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY,
     576        ResourceString, 255);
    576577    strcat(StatusMsg,ResourceString);
    577  
     578
    578579    SendDlgItemMessageA(hDlg, stc12, WM_SETTEXT, 0, (LPARAM)StatusMsg);
    579580
     
    585586        SendDlgItemMessageA(hDlg, stc14, WM_SETTEXT, 0,(LPARAM)pi->pPortName);
    586587    SendDlgItemMessageA(hDlg, stc13, WM_SETTEXT, 0, (LPARAM)(pi->pComment ?
    587                         pi->pComment : ""));
     588            pi->pComment : ""));
    588589    return;
    589590}
     
    596597 */
    597598static BOOL PRINTDLG_ChangePrinter(HWND hDlg, char *name,
    598                                    PRINT_PTRA *PrintStructures)
     599                   PRINT_PTRA *PrintStructures)
    599600{
    600601    LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg;
     
    610611    if(!OpenPrinterA(name, &hprn, NULL)) {
    611612        ERR("Can't open printer %s\n", name);
    612         return FALSE;
     613    return FALSE;
    613614    }
    614615    GetPrinterA(hprn, 2, NULL, 0, &needed);
    615616    PrintStructures->lpPrinterInfo = HeapAlloc(GetProcessHeap(),0,needed);
    616617    GetPrinterA(hprn, 2, (LPBYTE)PrintStructures->lpPrinterInfo, needed,
    617                 &needed);
     618        &needed);
    618619    GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
    619620    PrintStructures->lpDriverInfo = HeapAlloc(GetProcessHeap(),0,needed);
    620621    if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)PrintStructures->lpDriverInfo,
    621             needed, &needed)) {
    622         ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures->lpPrinterInfo->pPrinterName);
    623         return FALSE;
     622        needed, &needed)) {
     623    ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures->lpPrinterInfo->pPrinterName);
     624    return FALSE;
    624625    }
    625626    ClosePrinter(hprn);
     
    629630    if(PrintStructures->lpDevMode) {
    630631        HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
    631         PrintStructures->lpDevMode = NULL;
     632    PrintStructures->lpDevMode = NULL;
    632633    }
    633634
     
    635636    if(dmSize == -1) {
    636637        ERR("DocumentProperties fails on %s\n", debugstr_a(name));
    637         return FALSE;
     638    return FALSE;
    638639    }
    639640    PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(), 0, dmSize);
    640641    dmSize = DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, NULL,
    641                                 DM_OUT_BUFFER);
     642                DM_OUT_BUFFER);
    642643    if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) &&
    643                           !strcmp(lpdm->dmDeviceName,
    644                                   PrintStructures->lpDevMode->dmDeviceName)) {
     644              !strcmp(lpdm->dmDeviceName,
     645                  PrintStructures->lpDevMode->dmDeviceName)) {
    645646      /* Supplied devicemode matches current printer so try to use it */
    646647        DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, lpdm,
    647                             DM_OUT_BUFFER | DM_IN_BUFFER);
     648                DM_OUT_BUFFER | DM_IN_BUFFER);
    648649    }
    649650    if(lpdm)
     
    655656      /* Print range (All/Range/Selection) */
    656657        SetDlgItemInt(hDlg, edt1, lppd->nFromPage, FALSE);
    657         SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);
    658         CheckRadioButton(hDlg, rad1, rad3, rad1);               /* default */
    659         if (lppd->Flags & PD_NOSELECTION)
    660             EnableWindow(GetDlgItem(hDlg, rad2), FALSE);
    661         else
    662             if (lppd->Flags & PD_SELECTION)
    663                 CheckRadioButton(hDlg, rad1, rad3, rad2);
    664         if (lppd->Flags & PD_NOPAGENUMS) {
    665             EnableWindow(GetDlgItem(hDlg, rad3), FALSE);
    666             EnableWindow(GetDlgItem(hDlg, stc2),FALSE);
    667             EnableWindow(GetDlgItem(hDlg, edt1), FALSE);
    668             EnableWindow(GetDlgItem(hDlg, stc3),FALSE);
    669             EnableWindow(GetDlgItem(hDlg, edt2), FALSE);
    670         } else {
    671             if (lppd->Flags & PD_PAGENUMS)
    672                 CheckRadioButton(hDlg, rad1, rad3, rad3);
    673         }
    674         /* "All xxx pages"... */
    675         {
    676             char        resourcestr[64];
    677             char        result[64];
    678             LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES,
    679                         resourcestr, 49);
    680             sprintf(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1);
    681             SendDlgItemMessageA(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result);
    682         }
    683        
    684         /* Collate pages
    685         *
    686         * FIXME: The ico3 is not displayed for some reason. I don't know why.
    687         */
    688         if (lppd->Flags & PD_COLLATE) {
    689             SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
    690                                 (LPARAM)PrintStructures->hCollateIcon);
    691             CheckDlgButton(hDlg, chx2, 1);
    692         } else {
    693             SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
    694                                 (LPARAM)PrintStructures->hNoCollateIcon);
    695             CheckDlgButton(hDlg, chx2, 0);
    696         }
    697 
    698         if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
    699           /* if printer doesn't support it: no Collate */
    700             if (!(lpdm->dmFields & DM_COLLATE)) {
    701                 EnableWindow(GetDlgItem(hDlg, chx2), FALSE);   
    702                 EnableWindow(GetDlgItem(hDlg, ico3), FALSE);   
    703             }
    704         }
    705 
    706         /* nCopies */
    707         {
    708           INT copies;
    709           if (lppd->hDevMode == 0)
    710               copies = lppd->nCopies;
    711           else
    712               copies = lpdm->dmCopies;
    713           if(copies == 0) copies = 1;
    714           else if(copies < 0) copies = MAX_COPIES;
    715           SetDlgItemInt(hDlg, edt3, copies, FALSE);
    716         }
    717 
    718         if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
    719           /* if printer doesn't support it: no nCopies */
    720             if (!(lpdm->dmFields & DM_COPIES)) {
    721                 EnableWindow(GetDlgItem(hDlg, edt3), FALSE);   
    722                 EnableWindow(GetDlgItem(hDlg, stc5), FALSE);   
    723             }
    724         }
    725 
    726         /* print to file */
    727         CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
    728         if (lppd->Flags & PD_DISABLEPRINTTOFILE)
    729             EnableWindow(GetDlgItem(hDlg, chx1), FALSE);   
    730         if (lppd->Flags & PD_HIDEPRINTTOFILE)
     658    SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);
     659    CheckRadioButton(hDlg, rad1, rad3, rad1);       /* default */
     660    if (lppd->Flags & PD_NOSELECTION)
     661        EnableWindow(GetDlgItem(hDlg, rad2), FALSE);
     662    else
     663        if (lppd->Flags & PD_SELECTION)
     664            CheckRadioButton(hDlg, rad1, rad3, rad2);
     665    if (lppd->Flags & PD_NOPAGENUMS) {
     666        EnableWindow(GetDlgItem(hDlg, rad3), FALSE);
     667        EnableWindow(GetDlgItem(hDlg, stc2),FALSE);
     668        EnableWindow(GetDlgItem(hDlg, edt1), FALSE);
     669        EnableWindow(GetDlgItem(hDlg, stc3),FALSE);
     670        EnableWindow(GetDlgItem(hDlg, edt2), FALSE);
     671    } else {
     672        if (lppd->Flags & PD_PAGENUMS)
     673            CheckRadioButton(hDlg, rad1, rad3, rad3);
     674    }
     675    /* "All xxx pages"... */
     676    {
     677        char        resourcestr[64];
     678        char        result[64];
     679        LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES,
     680            resourcestr, 49);
     681        sprintf(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1);
     682        SendDlgItemMessageA(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result);
     683    }
     684
     685    /* Collate pages
     686    *
     687    * FIXME: The ico3 is not displayed for some reason. I don't know why.
     688    */
     689    if (lppd->Flags & PD_COLLATE) {
     690        SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
     691                (LPARAM)PrintStructures->hCollateIcon);
     692        CheckDlgButton(hDlg, chx2, 1);
     693    } else {
     694        SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
     695                (LPARAM)PrintStructures->hNoCollateIcon);
     696        CheckDlgButton(hDlg, chx2, 0);
     697    }
     698
     699    if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
     700      /* if printer doesn't support it: no Collate */
     701        if (!(lpdm->dmFields & DM_COLLATE)) {
     702            EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
     703        EnableWindow(GetDlgItem(hDlg, ico3), FALSE);
     704        }
     705    }
     706
     707    /* nCopies */
     708    {
     709      INT copies;
     710      if (lppd->hDevMode == 0)
     711          copies = lppd->nCopies;
     712      else
     713          copies = lpdm->dmCopies;
     714      if(copies == 0) copies = 1;
     715      else if(copies < 0) copies = MAX_COPIES;
     716      SetDlgItemInt(hDlg, edt3, copies, FALSE);
     717    }
     718
     719    if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
     720      /* if printer doesn't support it: no nCopies */
     721        if (!(lpdm->dmFields & DM_COPIES)) {
     722            EnableWindow(GetDlgItem(hDlg, edt3), FALSE);
     723        EnableWindow(GetDlgItem(hDlg, stc5), FALSE);
     724        }
     725    }
     726
     727    /* print to file */
     728    CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
     729    if (lppd->Flags & PD_DISABLEPRINTTOFILE)
     730            EnableWindow(GetDlgItem(hDlg, chx1), FALSE);
     731    if (lppd->Flags & PD_HIDEPRINTTOFILE)
    731732            ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
    732733
     
    739740
    740741      PRINTDLG_SetUpPaperComboBox(hDlg, cmb2,
    741                                   PrintStructures->lpPrinterInfo->pPrinterName,
    742                                   PrintStructures->lpPrinterInfo->pPortName,
    743                                   lpdm);
     742                  PrintStructures->lpPrinterInfo->pPrinterName,
     743                  PrintStructures->lpPrinterInfo->pPortName,
     744                  lpdm);
    744745      PRINTDLG_SetUpPaperComboBox(hDlg, cmb3,
    745                                   PrintStructures->lpPrinterInfo->pPrinterName,
    746                                   PrintStructures->lpPrinterInfo->pPortName,
    747                                   lpdm);
     746                  PrintStructures->lpPrinterInfo->pPrinterName,
     747                  PrintStructures->lpPrinterInfo->pPortName,
     748                  lpdm);
    748749      CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2);
    749750      SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
    750751                          (LPARAM)(bPortrait ? PrintStructures->hPortraitIcon :
    751752                                   PrintStructures->hLandscapeIcon));
    752      
     753
    753754    }
    754755
     
    756757    if ((lppd->Flags & PD_SHOWHELP)==0) {
    757758        /* hide if PD_SHOWHELP not specified */
    758         ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE);         
     759        ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE);
    759760    }
    760761    return TRUE;
     
    765766 */
    766767static LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam,
    767                                      PRINT_PTRA* PrintStructures)
     768                     PRINT_PTRA* PrintStructures)
    768769{
    769770    LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg;
     
    778779    PrintStructures->hCollateIcon =
    779780      LoadImageA(COMDLG32_hInstance, "PD32_COLLATE", IMAGE_ICON, 0, 0, 0);
    780     PrintStructures->hNoCollateIcon = 
     781    PrintStructures->hNoCollateIcon =
    781782      LoadImageA(COMDLG32_hInstance, "PD32_NOCOLLATE", IMAGE_ICON, 0, 0, 0);
    782783
     
    792793       PrintStructures->hLandscapeIcon == 0) {
    793794        ERR("no icon in resourcefile\n");
    794         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    795         EndDialog(hDlg, FALSE);
     795    COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     796    EndDialog(hDlg, FALSE);
    796797    }
    797798
     
    801802     */
    802803    if (lppd->Flags & PD_SHOWHELP) {
    803         if((PrintStructures->HelpMessageID = 
    804             RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {
    805             COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
    806             return FALSE;
    807         }
     804        if((PrintStructures->HelpMessageID =
     805        RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {
     806        COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
     807        return FALSE;
     808    }
    808809    } else
    809810        PrintStructures->HelpMessageID = 0;
     
    811812    if(!(lppd->Flags &PD_PRINTSETUP)) {
    812813        PrintStructures->hwndUpDown =
    813           CreateUpDownControl(WS_CHILD | WS_VISIBLE | WS_BORDER |
    814                               UDS_NOTHOUSANDS | UDS_ARROWKEYS |
    815                               UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0,
    816                               hDlg, UPDOWN_ID, COMDLG32_hInstance,
    817                               GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1);
     814      CreateUpDownControl(WS_CHILD | WS_VISIBLE | WS_BORDER |
     815                  UDS_NOTHOUSANDS | UDS_ARROWKEYS |
     816                  UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0,
     817                  hDlg, UPDOWN_ID, COMDLG32_hInstance,
     818                  GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1);
    818819    }
    819820
     
    823824     */
    824825    if (lppd->nMaxPage < lppd->nMinPage)
    825         lppd->nMaxPage = lppd->nMinPage;
    826     if (lppd->nMinPage == lppd->nMaxPage) 
    827         lppd->Flags |= PD_NOPAGENUMS;       
     826        lppd->nMaxPage = lppd->nMinPage;
     827    if (lppd->nMinPage == lppd->nMaxPage)
     828        lppd->Flags |= PD_NOPAGENUMS;
    828829    if (lppd->nToPage < lppd->nMinPage)
    829830        lppd->nToPage = lppd->nMinPage;
     
    837838    /* if we have the combo box, fill it */
    838839    if (GetDlgItem(hDlg,comboID)) {
    839         /* Fill Combobox
    840         */
    841         pdn = GlobalLock(lppd->hDevNames);
    842         pdm = GlobalLock(lppd->hDevMode);
    843         if(pdn)
    844             name = (char*)pdn + pdn->wDeviceOffset;
    845         else if(pdm)
    846             name = pdm->dmDeviceName;
    847         PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name);
    848         if(pdm) GlobalUnlock(lppd->hDevMode);
    849         if(pdn) GlobalUnlock(lppd->hDevNames);
    850 
    851         /* Now find selected printer and update rest of dlg */
    852         name = HeapAlloc(GetProcessHeap(),0,256);
    853         if (GetDlgItemTextA(hDlg, comboID, name, 255))
    854             PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
    855         HeapFree(GetProcessHeap(),0,name);
     840    /* Fill Combobox
     841    */
     842    pdn = GlobalLock(lppd->hDevNames);
     843    pdm = GlobalLock(lppd->hDevMode);
     844    if(pdn)
     845        name = (char*)pdn + pdn->wDeviceOffset;
     846    else if(pdm)
     847        name = pdm->dmDeviceName;
     848    PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name);
     849    if(pdm) GlobalUnlock(lppd->hDevMode);
     850    if(pdn) GlobalUnlock(lppd->hDevNames);
     851
     852    /* Now find selected printer and update rest of dlg */
     853    name = HeapAlloc(GetProcessHeap(),0,256);
     854    if (GetDlgItemTextA(hDlg, comboID, name, 255))
     855        PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
     856    HeapFree(GetProcessHeap(),0,name);
    856857    } else {
    857         /* else use default printer */
    858         char name[200];
    859         BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name));
    860 
    861         if (ret)
    862             PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
    863         else
    864             FIXME("No default printer found, expect problems!\n");
     858    /* else use default printer */
     859    char name[200];
     860    BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name));
     861
     862    if (ret)
     863        PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
     864    else
     865        FIXME("No default printer found, expect problems!\n");
    865866    }
    866867    return TRUE;
     
    872873 */
    873874static LRESULT PRINTDLG_WMInitDialog16(HWND hDlg, WPARAM wParam,
    874                                      PRINT_PTRA* PrintStructures)
     875                     PRINT_PTRA* PrintStructures)
    875876{
    876877    LPPRINTDLG16 lppd = PrintStructures->dlg.lpPrintDlg16;
     
    883884    PrintStructures->hCollateIcon =
    884885      LoadIconA(COMDLG32_hInstance, "PD32_COLLATE");
    885     PrintStructures->hNoCollateIcon = 
     886    PrintStructures->hNoCollateIcon =
    886887      LoadIconA(COMDLG32_hInstance, "PD32_NOCOLLATE");
    887888    if(PrintStructures->hCollateIcon == 0 ||
    888889       PrintStructures->hNoCollateIcon == 0) {
    889890        ERR("no icon in resourcefile\n");
    890         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    891         EndDialog(hDlg, FALSE);
     891    COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     892    EndDialog(hDlg, FALSE);
    892893    }
    893894
     
    900901     */
    901902    if (lppd->Flags & PD_SHOWHELP) {
    902         if((PrintStructures->HelpMessageID = 
    903             RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {
    904             COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
    905             return FALSE;
    906         }
     903        if((PrintStructures->HelpMessageID =
     904        RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {
     905        COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
     906        return FALSE;
     907    }
    907908    } else
    908909        PrintStructures->HelpMessageID = 0;
    909910
    910911    if (!(lppd->Flags & PD_PRINTSETUP)) {
    911         /* We have a print quality combo box. What shall we do? */
    912         if (GetDlgItem(hDlg,cmb1)) {
    913             char buf [20];
    914 
    915             FIXME("Print quality only displaying currently.\n");
    916 
    917             pdm = GlobalLock16(lppd->hDevMode);
    918             if(pdm) {
    919                 switch (pdm->dmPrintQuality) {
    920                 case DMRES_HIGH         : strcpy(buf,"High");break;
    921                 case DMRES_MEDIUM       : strcpy(buf,"Medium");break;
    922                 case DMRES_LOW          : strcpy(buf,"Low");break;
    923                 case DMRES_DRAFT        : strcpy(buf,"Draft");break;
    924                 case 0                  : strcpy(buf,"Default");break;
    925                 default                 : sprintf(buf,"%ddpi",pdm->dmPrintQuality);break;
    926                 }
    927                 GlobalUnlock16(lppd->hDevMode);
    928             } else
    929                 strcpy(buf,"Default");
    930             SendDlgItemMessageA(hDlg,cmb1,CB_ADDSTRING,0,(LPARAM)buf);
    931             SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0);
    932             EnableWindow(GetDlgItem(hDlg,cmb1),FALSE);
    933         }
     912    /* We have a print quality combo box. What shall we do? */
     913    if (GetDlgItem(hDlg,cmb1)) {
     914        char buf [20];
     915
     916        FIXME("Print quality only displaying currently.\n");
     917
     918        pdm = GlobalLock16(lppd->hDevMode);
     919        if(pdm) {
     920        switch (pdm->dmPrintQuality) {
     921        case DMRES_HIGH     : strcpy(buf,"High");break;
     922        case DMRES_MEDIUM   : strcpy(buf,"Medium");break;
     923        case DMRES_LOW      : strcpy(buf,"Low");break;
     924        case DMRES_DRAFT    : strcpy(buf,"Draft");break;
     925        case 0          : strcpy(buf,"Default");break;
     926        default         : sprintf(buf,"%ddpi",pdm->dmPrintQuality);break;
     927        }
     928            GlobalUnlock16(lppd->hDevMode);
     929        } else
     930        strcpy(buf,"Default");
     931        SendDlgItemMessageA(hDlg,cmb1,CB_ADDSTRING,0,(LPARAM)buf);
     932        SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0);
     933        EnableWindow(GetDlgItem(hDlg,cmb1),FALSE);
     934    }
    934935    }
    935936
     
    939940     */
    940941    if (lppd->nMaxPage < lppd->nMinPage)
    941         lppd->nMaxPage = lppd->nMinPage;
    942     if (lppd->nMinPage == lppd->nMaxPage) 
    943         lppd->Flags |= PD_NOPAGENUMS;       
     942        lppd->nMaxPage = lppd->nMinPage;
     943    if (lppd->nMinPage == lppd->nMaxPage)
     944        lppd->Flags |= PD_NOPAGENUMS;
    944945    if (lppd->nToPage < lppd->nMinPage)
    945946        lppd->nToPage = lppd->nMinPage;
     
    953954    /* If the printer combo box is in the dialog, fill it */
    954955    if (GetDlgItem(hDlg,comboID)) {
    955         /* Fill Combobox
    956         */
    957         pdn = GlobalLock16(lppd->hDevNames);
    958         pdm = GlobalLock16(lppd->hDevMode);
    959         if(pdn)
    960             name = (char*)pdn + pdn->wDeviceOffset;
    961         else if(pdm)
    962             name = pdm->dmDeviceName;
    963         PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name);
    964         if(pdm) GlobalUnlock16(lppd->hDevMode);
    965         if(pdn) GlobalUnlock16(lppd->hDevNames);
    966 
    967         /* Now find selected printer and update rest of dlg */
    968         name = HeapAlloc(GetProcessHeap(),0,256);
    969         if (GetDlgItemTextA(hDlg, comboID, name, 255))
    970             PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
     956    /* Fill Combobox
     957    */
     958    pdn = GlobalLock16(lppd->hDevNames);
     959    pdm = GlobalLock16(lppd->hDevMode);
     960    if(pdn)
     961        name = (char*)pdn + pdn->wDeviceOffset;
     962    else if(pdm)
     963        name = pdm->dmDeviceName;
     964    PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name);
     965    if(pdm) GlobalUnlock16(lppd->hDevMode);
     966    if(pdn) GlobalUnlock16(lppd->hDevNames);
     967
     968    /* Now find selected printer and update rest of dlg */
     969    name = HeapAlloc(GetProcessHeap(),0,256);
     970    if (GetDlgItemTextA(hDlg, comboID, name, 255))
     971        PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
    971972    } else {
    972         /* else just use default printer */
    973         char name[200];
    974         BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name));
    975 
    976         if (ret)
    977             PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
    978         else
    979             FIXME("No default printer found, expect problems!\n");
     973    /* else just use default printer */
     974    char name[200];
     975    BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name));
     976
     977    if (ret)
     978        PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
     979    else
     980        FIXME("No default printer found, expect problems!\n");
    980981    }
    981982    HeapFree(GetProcessHeap(),0,name);
     
    988989 *                              PRINTDLG_WMCommand               [internal]
    989990 */
    990 static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam, 
    991                         LPARAM lParam, PRINT_PTRA* PrintStructures)
     991static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam,
     992            LPARAM lParam, PRINT_PTRA* PrintStructures)
    992993{
    993994    LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg;
     
    9991000        TRACE(" OK button was hit\n");
    10001001        if (PRINTDLG_UpdatePrintDlg(hDlg, PrintStructures)!=TRUE) {
    1001             FIXME("Update printdlg was not successful!\n");
    1002             return(FALSE);
    1003         }
    1004         EndDialog(hDlg, TRUE);
    1005         return(TRUE);
     1002        FIXME("Update printdlg was not successful!\n");
     1003        return(FALSE);
     1004    }
     1005    EndDialog(hDlg, TRUE);
     1006    return(TRUE);
    10061007
    10071008    case IDCANCEL:
    10081009        TRACE(" CANCEL button was hit\n");
    10091010        EndDialog(hDlg, FALSE);
    1010         return(FALSE);
     1011    return(FALSE);
    10111012
    10121013     case pshHelp:
    10131014        TRACE(" HELP button was hit\n");
    1014         SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID, 
    1015                                 (WPARAM) hDlg, (LPARAM) lppd);
     1015        SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID,
     1016                    (WPARAM) hDlg, (LPARAM) lppd);
    10161017        break;
    10171018
    10181019     case chx2:                         /* collate pages checkbox */
    10191020        if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
    1020             SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
     1021            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
    10211022                                    (LPARAM)PrintStructures->hCollateIcon);
    10221023        else
    1023             SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
     1024            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
    10241025                                    (LPARAM)PrintStructures->hNoCollateIcon);
    1025         break;       
     1026        break;
    10261027     case edt1:                         /* from page nr editbox */
    10271028     case edt2:                         /* to page nr editbox */
    10281029        if (HIWORD(wParam)==EN_CHANGE) {
    1029             WORD nToPage;
    1030             WORD nFromPage;
    1031             nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
    1032             nToPage   = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
     1030        WORD nToPage;
     1031        WORD nFromPage;
     1032        nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
     1033        nToPage   = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
    10331034            if (nFromPage != lppd->nFromPage || nToPage != lppd->nToPage)
    1034                 CheckRadioButton(hDlg, rad1, rad3, rad3);
    1035         }
     1035            CheckRadioButton(hDlg, rad1, rad3, rad3);
     1036    }
    10361037        break;
    10371038
    10381039    case edt3:
    10391040        if(HIWORD(wParam) == EN_CHANGE) {
    1040             INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
    1041             if(copies <= 1)
    1042                 EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
    1043             else
    1044                 EnableWindow(GetDlgItem(hDlg, chx2), TRUE);
    1045         }
    1046         break;
     1041        INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
     1042        if(copies <= 1)
     1043            EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
     1044        else
     1045            EnableWindow(GetDlgItem(hDlg, chx2), TRUE);
     1046    }
     1047    break;
    10471048
    10481049#ifndef __WIN32OS2__
    10491050     case psh1:                       /* Print Setup */
    1050         {
    1051             PRINTDLG16  pdlg;
    1052            
    1053             if (!PrintStructures->dlg.lpPrintDlg16) {
    1054                 FIXME("The 32bit print dialog does not have this button!?\n");
    1055                 break;
    1056             }
    1057 
    1058             memcpy(&pdlg,PrintStructures->dlg.lpPrintDlg16,sizeof(pdlg));
    1059             pdlg.Flags |= PD_PRINTSETUP;
    1060             pdlg.hwndOwner = hDlg;
    1061             if (!PrintDlg16(&pdlg))
    1062                 break;
    1063         }
    1064         break;
     1051    {
     1052        PRINTDLG16  pdlg;
     1053
     1054        if (!PrintStructures->dlg.lpPrintDlg16) {
     1055        FIXME("The 32bit print dialog does not have this button!?\n");
     1056        break;
     1057        }
     1058
     1059        memcpy(&pdlg,PrintStructures->dlg.lpPrintDlg16,sizeof(pdlg));
     1060        pdlg.Flags |= PD_PRINTSETUP;
     1061        pdlg.hwndOwner = hDlg;
     1062        if (!PrintDlg16(&pdlg))
     1063        break;
     1064    }
     1065    break;
    10651066#endif
    10661067
     
    10721073         GetDlgItemTextA(hDlg, PrinterComboID, PrinterName, 255);
    10731074         if (!OpenPrinterA(PrinterName, &hPrinter, NULL)) {
    1074              FIXME(" Call to OpenPrinter did not succeed!\n");
    1075              break;
    1076         }
    1077          DocumentPropertiesA(hDlg, hPrinter, PrinterName,
    1078                              PrintStructures->lpDevMode,
    1079                              PrintStructures->lpDevMode,
    1080                              DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT);
    1081         ClosePrinter(hPrinter);
     1075         FIXME(" Call to OpenPrinter did not succeed!\n");
     1076         break;
     1077    }
     1078     DocumentPropertiesA(hDlg, hPrinter, PrinterName,
     1079                 PrintStructures->lpDevMode,
     1080                 PrintStructures->lpDevMode,
     1081                 DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT);
     1082    ClosePrinter(hPrinter);
    10821083         break;
    10831084       }
     
    10951096        }
    10961097        break;
    1097            
     1098
    10981099    case rad2: /* Paperorientation */
    10991100        if (lppd->Flags & PD_PRINTSETUP)
     
    11081109        }
    11091110        break;
    1110            
     1111
    11111112    case cmb1: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT */
    1112         if (PrinterComboID != wParam) {
    1113              FIXME("No handling for print quality combo box yet.\n");
    1114              break;
    1115         }
    1116         /* FALLTHROUGH */
     1113    if (PrinterComboID != wParam) {
     1114         FIXME("No handling for print quality combo box yet.\n");
     1115         break;
     1116    }
     1117    /* FALLTHROUGH */
    11171118    case cmb4:                         /* Printer combobox */
    11181119         if (HIWORD(wParam)==CBN_SELCHANGE) {
    1119              char   PrinterName[256];
    1120              GetDlgItemTextA(hDlg, LOWORD(wParam), PrinterName, 255);
    1121              PRINTDLG_ChangePrinter(hDlg, PrinterName, PrintStructures);
    1122         }
    1123         break;
     1120         char   PrinterName[256];
     1121         GetDlgItemTextA(hDlg, LOWORD(wParam), PrinterName, 255);
     1122         PRINTDLG_ChangePrinter(hDlg, PrinterName, PrintStructures);
     1123    }
     1124    break;
    11241125
    11251126    case cmb2: /* Papersize */
    11261127      {
    1127           DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
    1128           if(Sel != CB_ERR)
     1128      DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
     1129      if(Sel != CB_ERR)
    11291130#ifdef __WIN32OS2__
    1130               lpdm->dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
     1131          lpdm->dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
    11311132#else
    1132               lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
     1133          lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
    11331134#endif
    1134                                                             CB_GETITEMDATA,
    1135                                                             Sel, 0);
     1135                                CB_GETITEMDATA,
     1136                                Sel, 0);
    11361137      }
    11371138      break;
     
    11391140    case cmb3: /* Bin */
    11401141      {
    1141           DWORD Sel = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
    1142           if(Sel != CB_ERR)
    1143               lpdm->dmDefaultSource = SendDlgItemMessageA(hDlg, cmb3,
    1144                                                           CB_GETITEMDATA, Sel,
    1145                                                           0);
     1142      DWORD Sel = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
     1143      if(Sel != CB_ERR)
     1144          lpdm->dmDefaultSource = SendDlgItemMessageA(hDlg, cmb3,
     1145                              CB_GETITEMDATA, Sel,
     1146                              0);
    11461147      }
    1147       break; 
     1148      break;
    11481149    }
    11491150    if(lppd->Flags & PD_PRINTSETUP) {
    11501151        switch (LOWORD(wParam)) {
    1151         case rad1:                         /* orientation */
    1152         case rad2:
    1153             if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) {
     1152    case rad1:                         /* orientation */
     1153    case rad2:
     1154        if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) {
    11541155#ifdef __WIN32OS2__
    1155                 if(lpdm->dmOrientation != DMORIENT_PORTRAIT) {
    1156                     lpdm->dmOrientation = DMORIENT_PORTRAIT;
     1156            if(lpdm->dmOrientation != DMORIENT_PORTRAIT) {
     1157            lpdm->dmOrientation = DMORIENT_PORTRAIT;
    11571158#else
    1158                 if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) {
    1159                     lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
     1159            if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) {
     1160            lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
    11601161#endif
    1161                     SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,
    1162                                         (WPARAM)IMAGE_ICON,
    1163                                         (LPARAM)PrintStructures->hPortraitIcon);
    1164                     SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
    1165                                         (WPARAM)IMAGE_ICON,
    1166                                         (LPARAM)PrintStructures->hPortraitIcon);
    1167                 }
    1168             } else {
     1162            SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,
     1163                    (WPARAM)IMAGE_ICON,
     1164                    (LPARAM)PrintStructures->hPortraitIcon);
     1165            SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
     1166                    (WPARAM)IMAGE_ICON,
     1167                    (LPARAM)PrintStructures->hPortraitIcon);
     1168        }
     1169        } else {
    11691170#ifdef __WIN32OS2__
    1170                 if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) {
    1171                     lpdm->dmOrientation = DMORIENT_LANDSCAPE;
     1171            if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) {
     1172            lpdm->dmOrientation = DMORIENT_LANDSCAPE;
    11721173#else
    1173                 if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) {
    1174                     lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
     1174            if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) {
     1175                lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
    11751176#endif
    1176                     SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,
    1177                                         (WPARAM)IMAGE_ICON,
    1178                                         (LPARAM)PrintStructures->hLandscapeIcon);
    1179                     SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
    1180                                         (WPARAM)IMAGE_ICON,
    1181                                         (LPARAM)PrintStructures->hLandscapeIcon);
    1182                 }
    1183             }
    1184             break;
    1185         }
     1177            SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,
     1178                    (WPARAM)IMAGE_ICON,
     1179                    (LPARAM)PrintStructures->hLandscapeIcon);
     1180            SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
     1181                    (WPARAM)IMAGE_ICON,
     1182                    (LPARAM)PrintStructures->hLandscapeIcon);
     1183        }
     1184        }
     1185        break;
     1186    }
    11861187    }
    11871188    return FALSE;
    1188 }   
     1189}
    11891190
    11901191/***********************************************************************
    1191  *           PrintDlgProcA                      [internal]
     1192 *           PrintDlgProcA          [internal]
    11921193 */
    11931194#ifdef __WIN32OS2__
    11941195LRESULT WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
    1195                              LPARAM lParam)
     1196                 LPARAM lParam)
    11961197#else
    11971198BOOL WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
    1198                           LPARAM lParam)
     1199              LPARAM lParam)
    11991200#endif
    12001201{
     
    12031204
    12041205    if (uMsg!=WM_INITDIALOG) {
    1205         PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);   
    1206         if (!PrintStructures)
    1207             return FALSE;
     1206        PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);
     1207    if (!PrintStructures)
     1208        return FALSE;
    12081209    } else {
    12091210        PrintStructures = (PRINT_PTRA*) lParam;
    1210         SetWindowLongA(hDlg, DWL_USER, lParam);
    1211         res = PRINTDLG_WMInitDialog(hDlg, wParam, PrintStructures);
    1212 
    1213         if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK)
    1214             res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(
    1215                 hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg
    1216             );
    1217         return res;
    1218     }
    1219  
     1211    SetWindowLongA(hDlg, DWL_USER, lParam);
     1212    res = PRINTDLG_WMInitDialog(hDlg, wParam, PrintStructures);
     1213
     1214    if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK)
     1215        res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(
     1216        hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg
     1217        );
     1218    return res;
     1219    }
     1220
    12201221    if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) {
    12211222        res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam,
    1222                                                         lParam);
    1223         if(res) return res;
     1223                            lParam);
     1224    if(res) return res;
    12241225    }
    12251226
     
    12291230
    12301231    case WM_DESTROY:
    1231         DestroyIcon(PrintStructures->hCollateIcon);
    1232         DestroyIcon(PrintStructures->hNoCollateIcon);
     1232    DestroyIcon(PrintStructures->hCollateIcon);
     1233    DestroyIcon(PrintStructures->hNoCollateIcon);
    12331234        DestroyIcon(PrintStructures->hPortraitIcon);
    12341235        DestroyIcon(PrintStructures->hLandscapeIcon);
    1235         if(PrintStructures->hwndUpDown)
    1236             DestroyWindow(PrintStructures->hwndUpDown);
     1236    if(PrintStructures->hwndUpDown)
     1237        DestroyWindow(PrintStructures->hwndUpDown);
    12371238        return FALSE;
    1238     }   
     1239    }
    12391240    return res;
    12401241}
     
    12551256        HGLOBAL16 hGlobal16;
    12561257        LPVOID template;
    1257  
     1258
    12581259        if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
    12591260               PrintResourceName, RT_DIALOGA)))
     
    13001301
    13011302    if (lppd->Flags & PD_PRINTSETUP) {
    1302         if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
    1303             hDlgTmpl = lppd->hSetupTemplate;
    1304         } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {       
    1305             hResInfo = FindResourceA(lppd->hInstance,
    1306                                      lppd->lpSetupTemplateName, RT_DIALOGA);
    1307             hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
    1308         } else {
    1309             hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP",
    1310                                      RT_DIALOGA);
    1311             hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
    1312         }
     1303    if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
     1304        hDlgTmpl = lppd->hSetupTemplate;
     1305    } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {
     1306        hResInfo = FindResourceA(lppd->hInstance,
     1307                     lppd->lpSetupTemplateName, RT_DIALOGA);
     1308        hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
    13131309    } else {
    1314         if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
    1315             hDlgTmpl = lppd->hPrintTemplate;
    1316         } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
    1317             hResInfo = FindResourceA(lppd->hInstance,
    1318                                      lppd->lpPrintTemplateName,
    1319                                      RT_DIALOGA);
    1320             hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
    1321         } else {
    1322             hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32",
    1323                                      RT_DIALOGA);
    1324             hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
    1325         }
     1310        hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP",
     1311                     RT_DIALOGA);
     1312        hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
     1313    }
     1314    } else {
     1315    if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
     1316        hDlgTmpl = lppd->hPrintTemplate;
     1317    } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
     1318        hResInfo = FindResourceA(lppd->hInstance,
     1319                     lppd->lpPrintTemplateName,
     1320                     RT_DIALOGA);
     1321        hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
     1322    } else {
     1323        hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32",
     1324                     RT_DIALOGA);
     1325        hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
     1326    }
    13261327    }
    13271328    return hDlgTmpl;
     
    13401341
    13411342    if (lppd->Flags & PD_PRINTSETUP) {
    1342         if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
    1343             hDlgTmpl = lppd->hSetupTemplate;
    1344         } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {       
    1345             hResInfo = FindResource16(lppd->hInstance,
    1346                                      MapSL(lppd->lpSetupTemplateName), RT_DIALOGA);
    1347             hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo);
    1348         } else {
    1349             hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32_SETUP");
    1350         }
     1343    if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
     1344        hDlgTmpl = lppd->hSetupTemplate;
     1345    } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {
     1346        hResInfo = FindResource16(lppd->hInstance,
     1347                     MapSL(lppd->lpSetupTemplateName), RT_DIALOGA);
     1348        hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo);
    13511349    } else {
    1352         if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
    1353             hDlgTmpl = lppd->hPrintTemplate;
    1354         } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
    1355             hResInfo = FindResource16(lppd->hInstance,
    1356                                      MapSL(lppd->lpPrintTemplateName),
    1357                                      RT_DIALOGA);
    1358             hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo);
    1359         } else {
    1360             hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32");
    1361         }
     1350        hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32_SETUP");
     1351    }
     1352    } else {
     1353    if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
     1354        hDlgTmpl = lppd->hPrintTemplate;
     1355    } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
     1356        hResInfo = FindResource16(lppd->hInstance,
     1357                     MapSL(lppd->lpPrintTemplateName),
     1358                     RT_DIALOGA);
     1359        hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo);
     1360    } else {
     1361        hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32");
     1362    }
    13621363    }
    13631364    return hDlgTmpl;
     
    13771378    if(lppd->Flags & PD_RETURNDC) {
    13781379        lppd->hDC = CreateDCA((char*)pdn + pdn->wDriverOffset,
    1379                               (char*)pdn + pdn->wDeviceOffset,
    1380                               (char*)pdn + pdn->wOutputOffset,
    1381                               pdm );
     1380                  (char*)pdn + pdn->wDeviceOffset,
     1381                  (char*)pdn + pdn->wOutputOffset,
     1382                  pdm );
    13821383    } else if(lppd->Flags & PD_RETURNIC) {
    13831384        lppd->hDC = CreateICA((char*)pdn + pdn->wDriverOffset,
    1384                               (char*)pdn + pdn->wDeviceOffset,
    1385                               (char*)pdn + pdn->wOutputOffset,
    1386                               pdm );
     1385                  (char*)pdn + pdn->wDeviceOffset,
     1386                  (char*)pdn + pdn->wOutputOffset,
     1387                  pdm );
    13871388    }
    13881389    GlobalUnlock(lppd->hDevNames);
     
    13991400    if(lppd->Flags & PD_RETURNDC) {
    14001401        lppd->hDC = CreateDCA((char*)pdn + pdn->wDriverOffset,
    1401                               (char*)pdn + pdn->wDeviceOffset,
    1402                               (char*)pdn + pdn->wOutputOffset,
    1403                               pdm );
     1402                  (char*)pdn + pdn->wDeviceOffset,
     1403                  (char*)pdn + pdn->wOutputOffset,
     1404                  pdm );
    14041405    } else if(lppd->Flags & PD_RETURNIC) {
    14051406        lppd->hDC = CreateICA((char*)pdn + pdn->wDriverOffset,
    1406                               (char*)pdn + pdn->wDeviceOffset,
    1407                               (char*)pdn + pdn->wOutputOffset,
    1408                               pdm );
     1407                  (char*)pdn + pdn->wDeviceOffset,
     1408                  (char*)pdn + pdn->wOutputOffset,
     1409                  pdm );
    14091410    }
    14101411    GlobalUnlock16(lppd->hDevNames);
     
    14311432 *  * The Paper Orientation Icons are not implemented yet.
    14321433 *  * The Properties Button(s) should call DocumentPropertiesA().
    1433  *  * Settings are not yet taken from a provided DevMode or 
     1434 *  * Settings are not yet taken from a provided DevMode or
    14341435 *    default printer settings.
    14351436 */
    14361437BOOL WINAPI PrintDlgA(
    1437                       LPPRINTDLGA lppd /* [in/out] ptr to PRINTDLG32 struct */
    1438                       )
     1438              LPPRINTDLGA lppd /* [in/out] ptr to PRINTDLG32 struct */
     1439              )
    14391440{
    14401441    BOOL      bRet = FALSE;
     
    14481449    if(TRACE_ON(commdlg)) {
    14491450        char flagstr[1000] = "";
    1450         struct pd_flags *pflag = pd_flags;
    1451         for( ; pflag->name; pflag++) {
    1452             if(lppd->Flags & pflag->flag)
    1453                 strcat(flagstr, pflag->name);
    1454         }
    1455         TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
    1456               "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n"
    1457               "flags %08lx (%s)\n",
    1458               lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,
    1459               lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,
    1460               lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);
     1451    struct pd_flags *pflag = pd_flags;
     1452    for( ; pflag->name; pflag++) {
     1453        if(lppd->Flags & pflag->flag)
     1454            strcat(flagstr, pflag->name);
     1455    }
     1456    TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
     1457          "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n"
     1458          "flags %08lx (%s)\n",
     1459          lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,
     1460          lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,
     1461          lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);
    14611462    }
    14621463
    14631464    if(lppd->lStructSize != sizeof(PRINTDLGA)) {
    14641465        WARN("structure size failure !!!\n");
    1465         COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
    1466         return FALSE;
     1466    COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
     1467    return FALSE;
    14671468    }
    14681469
    14691470    if(lppd->Flags & PD_RETURNDEFAULT) {
    14701471        PRINTER_INFO_2A *pbuf;
    1471         DRIVER_INFO_3A  *dbuf;
    1472         HANDLE hprn;
    1473         DWORD needed;
    1474 
    1475         if(lppd->hDevMode || lppd->hDevNames) {
    1476             WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
    1477             COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
    1478             return FALSE;
    1479         }
     1472    DRIVER_INFO_3A  *dbuf;
     1473    HANDLE hprn;
     1474    DWORD needed;
     1475
     1476    if(lppd->hDevMode || lppd->hDevNames) {
     1477        WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
     1478        COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
     1479        return FALSE;
     1480    }
    14801481        if(!PRINTDLG_OpenDefaultPrinter(&hprn)) {
    1481             WARN("Can't find default printer\n");
    1482             COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
    1483             return FALSE;
    1484         }
    1485 
    1486         GetPrinterA(hprn, 2, NULL, 0, &needed);
    1487         pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
    1488         GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);
    1489 
    1490         GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
    1491         dbuf = HeapAlloc(GetProcessHeap(),0,needed);
    1492         if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
    1493             ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),pbuf->pPrinterName);
    1494             COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
    1495             return FALSE;
    1496         }
    1497         ClosePrinter(hprn);
    1498 
    1499         PRINTDLG_CreateDevNames(&(lppd->hDevNames),
    1500                                   dbuf->pDriverPath,
    1501                                   pbuf->pPrinterName,
    1502                                   pbuf->pPortName);
    1503         lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize +
    1504                                      pbuf->pDevMode->dmDriverExtra);
    1505         ptr = GlobalLock(lppd->hDevMode);
    1506         memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
    1507                pbuf->pDevMode->dmDriverExtra);
    1508         GlobalUnlock(lppd->hDevMode);
    1509         HeapFree(GetProcessHeap(), 0, pbuf);
    1510         HeapFree(GetProcessHeap(), 0, dbuf);
    1511         bRet = TRUE;
     1482        WARN("Can't find default printer\n");
     1483        COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
     1484        return FALSE;
     1485    }
     1486
     1487    GetPrinterA(hprn, 2, NULL, 0, &needed);
     1488    pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
     1489    GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);
     1490
     1491    GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
     1492    dbuf = HeapAlloc(GetProcessHeap(),0,needed);
     1493    if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
     1494        ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),pbuf->pPrinterName);
     1495        COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
     1496        return FALSE;
     1497    }
     1498    ClosePrinter(hprn);
     1499
     1500    PRINTDLG_CreateDevNames(&(lppd->hDevNames),
     1501                  dbuf->pDriverPath,
     1502                  pbuf->pPrinterName,
     1503                  pbuf->pPortName);
     1504    lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize +
     1505                     pbuf->pDevMode->dmDriverExtra);
     1506    ptr = GlobalLock(lppd->hDevMode);
     1507    memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
     1508           pbuf->pDevMode->dmDriverExtra);
     1509    GlobalUnlock(lppd->hDevMode);
     1510    HeapFree(GetProcessHeap(), 0, pbuf);
     1511    HeapFree(GetProcessHeap(), 0, dbuf);
     1512    bRet = TRUE;
    15121513    } else {
    1513         HGLOBAL hDlgTmpl;
    1514         PRINT_PTRA *PrintStructures;
    1515 
    1516     /* load Dialog resources, 
    1517      * depending on Flags indicates Print32 or Print32_setup dialog 
     1514    HGLOBAL hDlgTmpl;
     1515    PRINT_PTRA *PrintStructures;
     1516
     1517    /* load Dialog resources,
     1518     * depending on Flags indicates Print32 or Print32_setup dialog
    15181519     */
    1519         hDlgTmpl = PRINTDLG_GetDlgTemplate(lppd);
    1520         if (!hDlgTmpl) {
    1521             COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    1522             return FALSE;
    1523         }
    1524         ptr = LockResource( hDlgTmpl );
    1525         if (!ptr) {
    1526             COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    1527             return FALSE;
    1528         }
     1520    hDlgTmpl = PRINTDLG_GetDlgTemplate(lppd);
     1521    if (!hDlgTmpl) {
     1522        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     1523        return FALSE;
     1524    }
     1525    ptr = LockResource( hDlgTmpl );
     1526    if (!ptr) {
     1527        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     1528        return FALSE;
     1529    }
    15291530
    15301531        PrintStructures = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
    1531                                     sizeof(PRINT_PTRA));
    1532         PrintStructures->dlg.lpPrintDlg = lppd;
    1533 
    1534         /* and create & process the dialog .
    1535         * -1 is failure, 0 is broken hwnd, everything else is ok.
    1536         */
    1537         bRet = (0<DialogBoxIndirectParamA(hInst, ptr, lppd->hwndOwner,
    1538                                            PrintDlgProcA,
    1539                                            (LPARAM)PrintStructures));
    1540 
    1541         if(bRet) {
    1542             DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
    1543             PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;
    1544             DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo;
    1545 
    1546             if (lppd->hDevMode == 0) {
    1547                 TRACE(" No hDevMode yet... Need to create my own\n");
    1548                 lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE,
    1549                                         lpdm->dmSize + lpdm->dmDriverExtra);
    1550             } else {
    1551                 WORD locks;
    1552                 if((locks = (GlobalFlags(lppd->hDevMode) & GMEM_LOCKCOUNT))) {
    1553                     WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);
    1554                     while(locks--) {
    1555                         GlobalUnlock(lppd->hDevMode);
    1556                         TRACE("Now got %d locks\n", locks);
    1557                     }
    1558                 }
    1559                 lppd->hDevMode = GlobalReAlloc(lppd->hDevMode,
    1560                                                lpdm->dmSize + lpdm->dmDriverExtra,
    1561                                                GMEM_MOVEABLE);
    1562             }
    1563             lpdmReturn = GlobalLock(lppd->hDevMode);
    1564             memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);
    1565 
    1566             if (lppd->hDevNames != 0) {
    1567                 WORD locks;
    1568                 if((locks = (GlobalFlags(lppd->hDevNames) & GMEM_LOCKCOUNT))) {
    1569                     WARN("hDevNames has %d locks on it. Unlocking it now\n", locks);
    1570                     while(locks--)
    1571                         GlobalUnlock(lppd->hDevNames);
    1572                 }
    1573             }
    1574             PRINTDLG_CreateDevNames(&(lppd->hDevNames),
    1575                     di->pDriverPath,
    1576                     pi->pPrinterName,
    1577                     pi->pPortName
    1578             );
    1579             GlobalUnlock(lppd->hDevMode);
    1580         }
    1581         HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
    1582         HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
    1583         HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);
    1584         HeapFree(GetProcessHeap(), 0, PrintStructures);
     1532                    sizeof(PRINT_PTRA));
     1533    PrintStructures->dlg.lpPrintDlg = lppd;
     1534
     1535    /* and create & process the dialog .
     1536    * -1 is failure, 0 is broken hwnd, everything else is ok.
     1537    */
     1538    bRet = (0<DialogBoxIndirectParamA(hInst, ptr, lppd->hwndOwner,
     1539                       PrintDlgProcA,
     1540                       (LPARAM)PrintStructures));
     1541
     1542    if(bRet) {
     1543        DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
     1544        PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;
     1545        DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo;
     1546
     1547        if (lppd->hDevMode == 0) {
     1548            TRACE(" No hDevMode yet... Need to create my own\n");
     1549        lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE,
     1550                    lpdm->dmSize + lpdm->dmDriverExtra);
     1551        } else {
     1552            WORD locks;
     1553        if((locks = (GlobalFlags(lppd->hDevMode) & GMEM_LOCKCOUNT))) {
     1554            WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);
     1555            while(locks--) {
     1556                GlobalUnlock(lppd->hDevMode);
     1557            TRACE("Now got %d locks\n", locks);
     1558            }
     1559        }
     1560        lppd->hDevMode = GlobalReAlloc(lppd->hDevMode,
     1561                           lpdm->dmSize + lpdm->dmDriverExtra,
     1562                           GMEM_MOVEABLE);
     1563        }
     1564        lpdmReturn = GlobalLock(lppd->hDevMode);
     1565        memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);
     1566
     1567        if (lppd->hDevNames != 0) {
     1568            WORD locks;
     1569        if((locks = (GlobalFlags(lppd->hDevNames) & GMEM_LOCKCOUNT))) {
     1570            WARN("hDevNames has %d locks on it. Unlocking it now\n", locks);
     1571            while(locks--)
     1572                GlobalUnlock(lppd->hDevNames);
     1573        }
     1574        }
     1575        PRINTDLG_CreateDevNames(&(lppd->hDevNames),
     1576            di->pDriverPath,
     1577            pi->pPrinterName,
     1578            pi->pPortName
     1579        );
     1580        GlobalUnlock(lppd->hDevMode);
     1581    }
     1582    HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
     1583    HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
     1584    HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);
     1585    HeapFree(GetProcessHeap(), 0, PrintStructures);
    15851586    }
    15861587    if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC))
    15871588        bRet = PRINTDLG_CreateDC(lppd);
    15881589
    1589     TRACE("exit! (%d)\n", bRet);       
    1590     return bRet;   
     1590    TRACE("exit! (%d)\n", bRet);
     1591    return bRet;
    15911592}
    15921593
     
    15941595/***********************************************************************
    15951596 *           PrintDlg   (COMMDLG.20)
    1596  * 
     1597 *
    15971598 *  Displays the the PRINT dialog box, which enables the user to specify
    15981599 *  specific properties of the print job.
     
    16081609
    16091610BOOL16 WINAPI PrintDlg16(
    1610               LPPRINTDLG16 lppd /* [in/out] ptr to PRINTDLG struct */
     1611          LPPRINTDLG16 lppd /* [in/out] ptr to PRINTDLG struct */
    16111612) {
    16121613    BOOL      bRet = FALSE;
     
    16161617    if(TRACE_ON(commdlg)) {
    16171618        char flagstr[1000] = "";
    1618         struct pd_flags *pflag = pd_flags;
    1619         for( ; pflag->name; pflag++) {
    1620             if(lppd->Flags & pflag->flag)
    1621                 strcat(flagstr, pflag->name);
    1622         }
    1623         TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
    1624               "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n"
    1625               "flags %08lx (%s)\n",
    1626               lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,
    1627               lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,
    1628               lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);
     1619    struct pd_flags *pflag = pd_flags;
     1620    for( ; pflag->name; pflag++) {
     1621        if(lppd->Flags & pflag->flag)
     1622            strcat(flagstr, pflag->name);
     1623    }
     1624    TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
     1625          "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n"
     1626          "flags %08lx (%s)\n",
     1627          lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,
     1628          lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,
     1629          lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);
    16291630    }
    16301631
    16311632    if(lppd->lStructSize != sizeof(PRINTDLG16)) {
    16321633        ERR("structure size (%ld/%d)\n",lppd->lStructSize,sizeof(PRINTDLG16));
    1633         COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
    1634         return FALSE;
     1634    COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
     1635    return FALSE;
    16351636    }
    16361637
    16371638    if(lppd->Flags & PD_RETURNDEFAULT) {
    16381639        PRINTER_INFO_2A *pbuf;
    1639         DRIVER_INFO_3A  *dbuf;
    1640         HANDLE hprn;
    1641         DWORD needed;
    1642 
    1643         if(lppd->hDevMode || lppd->hDevNames) {
    1644             WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
    1645             COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
    1646             return FALSE;
    1647         }
     1640    DRIVER_INFO_3A  *dbuf;
     1641    HANDLE hprn;
     1642    DWORD needed;
     1643
     1644    if(lppd->hDevMode || lppd->hDevNames) {
     1645        WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
     1646        COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
     1647        return FALSE;
     1648    }
    16481649        if(!PRINTDLG_OpenDefaultPrinter(&hprn)) {
    1649             WARN("Can't find default printer\n");
    1650             COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
    1651             return FALSE;
    1652         }
    1653 
    1654         GetPrinterA(hprn, 2, NULL, 0, &needed);
    1655         pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
    1656         GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);
    1657         GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
    1658         dbuf = HeapAlloc(GetProcessHeap(),0,needed);
    1659         if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
    1660             ERR("GetPrinterDriverA failed for %s, le %ld, fix your config!\n",
    1661                     pbuf->pPrinterName,GetLastError());
    1662             COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
    1663             return FALSE;
    1664         }
    1665         ClosePrinter(hprn);
    1666         PRINTDLG_CreateDevNames16(&(lppd->hDevNames),
    1667                                 dbuf->pDriverPath,
    1668                                 pbuf->pPrinterName,
    1669                                 pbuf->pPortName);
    1670         lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE,pbuf->pDevMode->dmSize+
    1671                                      pbuf->pDevMode->dmDriverExtra);
    1672         ptr = GlobalLock16(lppd->hDevMode);
    1673         memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
    1674                pbuf->pDevMode->dmDriverExtra);
    1675         GlobalUnlock16(lppd->hDevMode);
    1676         HeapFree(GetProcessHeap(), 0, pbuf);
    1677         HeapFree(GetProcessHeap(), 0, dbuf);
    1678         bRet = TRUE;
     1650        WARN("Can't find default printer\n");
     1651        COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
     1652        return FALSE;
     1653    }
     1654
     1655    GetPrinterA(hprn, 2, NULL, 0, &needed);
     1656    pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
     1657    GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);
     1658    GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
     1659    dbuf = HeapAlloc(GetProcessHeap(),0,needed);
     1660    if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
     1661        ERR("GetPrinterDriverA failed for %s, le %ld, fix your config!\n",
     1662            pbuf->pPrinterName,GetLastError());
     1663        COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
     1664        return FALSE;
     1665    }
     1666    ClosePrinter(hprn);
     1667    PRINTDLG_CreateDevNames16(&(lppd->hDevNames),
     1668                dbuf->pDriverPath,
     1669                pbuf->pPrinterName,
     1670                pbuf->pPortName);
     1671    lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE,pbuf->pDevMode->dmSize+
     1672                     pbuf->pDevMode->dmDriverExtra);
     1673    ptr = GlobalLock16(lppd->hDevMode);
     1674    memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
     1675           pbuf->pDevMode->dmDriverExtra);
     1676    GlobalUnlock16(lppd->hDevMode);
     1677    HeapFree(GetProcessHeap(), 0, pbuf);
     1678    HeapFree(GetProcessHeap(), 0, dbuf);
     1679    bRet = TRUE;
    16791680    } else {
    1680         HGLOBAL hDlgTmpl;
    1681         PRINT_PTRA *PrintStructures;
    1682 
    1683     /* load Dialog resources, 
    1684      * depending on Flags indicates Print32 or Print32_setup dialog 
     1681    HGLOBAL hDlgTmpl;
     1682    PRINT_PTRA *PrintStructures;
     1683
     1684    /* load Dialog resources,
     1685     * depending on Flags indicates Print32 or Print32_setup dialog
    16851686     */
    1686         hDlgTmpl = PRINTDLG_GetDlgTemplate16(lppd);
    1687         if (!hDlgTmpl) {
    1688             COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    1689             return FALSE;
    1690         }
     1687    hDlgTmpl = PRINTDLG_GetDlgTemplate16(lppd);
     1688    if (!hDlgTmpl) {
     1689        COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     1690        return FALSE;
     1691    }
    16911692        PrintStructures = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
    1692                                     sizeof(PRINT_PTRA));
    1693         PrintStructures->dlg.lpPrintDlg16 = lppd;
    1694         PrintStructures->dlg.lpPrintDlg = (LPPRINTDLGA)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(PRINTDLGA));
    1695 #define CVAL(x) PrintStructures->dlg.lpPrintDlg->x = lppd->x;
    1696 #define MVAL(x) PrintStructures->dlg.lpPrintDlg->x = MapSL(lppd->x);
    1697         CVAL(Flags);CVAL(hwndOwner);CVAL(hDC);
    1698         CVAL(nFromPage);CVAL(nToPage);CVAL(nMinPage);CVAL(nMaxPage);
    1699         CVAL(nCopies);CVAL(hInstance);CVAL(lCustData);
    1700         MVAL(lpPrintTemplateName);MVAL(lpSetupTemplateName);
    1701         /* Don't copy rest, it is 16 bit specific */
     1693                    sizeof(PRINT_PTRA));
     1694    PrintStructures->dlg.lpPrintDlg16 = lppd;
     1695    PrintStructures->dlg.lpPrintDlg = (LPPRINTDLGA)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(PRINTDLGA));
     1696#define CVAL(x) PrintStructures->dlg.lpPrintDlg->x = lppd->x;
     1697#define MVAL(x) PrintStructures->dlg.lpPrintDlg->x = MapSL(lppd->x);
     1698    CVAL(Flags);CVAL(hwndOwner);CVAL(hDC);
     1699    CVAL(nFromPage);CVAL(nToPage);CVAL(nMinPage);CVAL(nMaxPage);
     1700    CVAL(nCopies);CVAL(hInstance);CVAL(lCustData);
     1701    MVAL(lpPrintTemplateName);MVAL(lpSetupTemplateName);
     1702    /* Don't copy rest, it is 16 bit specific */
    17021703#undef MVAL
    17031704#undef CVAL
    17041705
    1705         PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(),0,sizeof(DEVMODEA));
    1706 
    1707         /* and create & process the dialog .
    1708         * -1 is failure, 0 is broken hwnd, everything else is ok.
    1709         */
    1710         bRet =  (0<DialogBoxIndirectParam16(
    1711                 hInst, hDlgTmpl, lppd->hwndOwner,
    1712                 (DLGPROC16)GetProcAddress16(GetModuleHandle16("COMMDLG"),(LPCSTR)21),
    1713                 (LPARAM)PrintStructures
    1714                 )
    1715         );
    1716         if (!PrintStructures->lpPrinterInfo) bRet = FALSE;
    1717         if(bRet) {
    1718             DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
    1719             PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;
    1720             DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo;
    1721 
    1722             if (lppd->hDevMode == 0) {
    1723                 TRACE(" No hDevMode yet... Need to create my own\n");
    1724                 lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE,
    1725                                         lpdm->dmSize + lpdm->dmDriverExtra);
    1726             } else {
    1727                 WORD locks;
    1728                 if((locks = (GlobalFlags16(lppd->hDevMode)&GMEM_LOCKCOUNT))) {
    1729                     WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);
    1730                     while(locks--) {
    1731                         GlobalUnlock16(lppd->hDevMode);
    1732                         TRACE("Now got %d locks\n", locks);
    1733                     }
    1734                 }
    1735                 lppd->hDevMode = GlobalReAlloc16(lppd->hDevMode,
    1736                                                lpdm->dmSize + lpdm->dmDriverExtra,
    1737                                                GMEM_MOVEABLE);
    1738             }
    1739             lpdmReturn = GlobalLock16(lppd->hDevMode);
    1740             memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);
    1741 
    1742             if (lppd->hDevNames != 0) {
    1743                 WORD locks;
    1744                 if((locks = (GlobalFlags16(lppd->hDevNames)&GMEM_LOCKCOUNT))) {
    1745                     WARN("hDevNames has %d locks on it. Unlocking it now\n", locks);
    1746                     while(locks--)
    1747                         GlobalUnlock16(lppd->hDevNames);
    1748                 }
    1749             }
    1750             PRINTDLG_CreateDevNames16(&(lppd->hDevNames),
    1751                     di->pDriverPath,
    1752                     pi->pPrinterName,
    1753                     pi->pPortName
    1754             );
    1755             GlobalUnlock16(lppd->hDevMode);
    1756         }
    1757         if (!(lppd->Flags & (PD_ENABLESETUPTEMPLATEHANDLE | PD_ENABLESETUPTEMPLATE)))
     1706    PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(),0,sizeof(DEVMODEA));
     1707
     1708    /* and create & process the dialog .
     1709    * -1 is failure, 0 is broken hwnd, everything else is ok.
     1710    */
     1711    bRet =  (0<DialogBoxIndirectParam16(
     1712        hInst, hDlgTmpl, lppd->hwndOwner,
     1713        (DLGPROC16)GetProcAddress16(GetModuleHandle16("COMMDLG"),(LPCSTR)21),
     1714        (LPARAM)PrintStructures
     1715        )
     1716    );
     1717    if (!PrintStructures->lpPrinterInfo) bRet = FALSE;
     1718    if(bRet) {
     1719        DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
     1720        PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;
     1721        DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo;
     1722
     1723        if (lppd->hDevMode == 0) {
     1724            TRACE(" No hDevMode yet... Need to create my own\n");
     1725        lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE,
     1726                    lpdm->dmSize + lpdm->dmDriverExtra);
     1727        } else {
     1728            WORD locks;
     1729        if((locks = (GlobalFlags16(lppd->hDevMode)&GMEM_LOCKCOUNT))) {
     1730            WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);
     1731            while(locks--) {
     1732                GlobalUnlock16(lppd->hDevMode);
     1733            TRACE("Now got %d locks\n", locks);
     1734            }
     1735        }
     1736        lppd->hDevMode = GlobalReAlloc16(lppd->hDevMode,
     1737                           lpdm->dmSize + lpdm->dmDriverExtra,
     1738                           GMEM_MOVEABLE);
     1739        }
     1740        lpdmReturn = GlobalLock16(lppd->hDevMode);
     1741        memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);
     1742
     1743        if (lppd->hDevNames != 0) {
     1744            WORD locks;
     1745        if((locks = (GlobalFlags16(lppd->hDevNames)&GMEM_LOCKCOUNT))) {
     1746            WARN("hDevNames has %d locks on it. Unlocking it now\n", locks);
     1747            while(locks--)
     1748                GlobalUnlock16(lppd->hDevNames);
     1749        }
     1750        }
     1751        PRINTDLG_CreateDevNames16(&(lppd->hDevNames),
     1752            di->pDriverPath,
     1753            pi->pPrinterName,
     1754            pi->pPortName
     1755        );
     1756        GlobalUnlock16(lppd->hDevMode);
     1757    }
     1758    if (!(lppd->Flags & (PD_ENABLESETUPTEMPLATEHANDLE | PD_ENABLESETUPTEMPLATE)))
    17581759            GlobalFree16(hDlgTmpl); /* created from the 32 bits resource */
    1759         HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
    1760         HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
    1761         HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);
    1762         HeapFree(GetProcessHeap(), 0, PrintStructures);
     1760    HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
     1761    HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
     1762    HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);
     1763    HeapFree(GetProcessHeap(), 0, PrintStructures);
    17631764    }
    17641765    if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC))
    17651766        bRet = PRINTDLG_CreateDC16(lppd);
    17661767
    1767     TRACE("exit! (%d)\n", bRet);       
    1768     return bRet;   
     1768    TRACE("exit! (%d)\n", bRet);
     1769    return bRet;
    17691770}
    17701771#endif
     
    17981799
    17991800typedef struct {
    1800     LPPAGESETUPDLGA     dlga;
    1801 
    1802     PRINTDLGA           pdlg;
     1801    LPPAGESETUPDLGA dlga;
     1802
     1803    PRINTDLGA       pdlg;
    18031804} PageSetupData;
    18041805
     
    18081809
    18091810    if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATEHANDLE) {
    1810         hDlgTmpl = lppd->hPageSetupTemplate;
    1811     } else if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATE) {     
    1812         hResInfo = FindResourceA(lppd->hInstance,
    1813                                 lppd->lpPageSetupTemplateName, RT_DIALOGA);
    1814         hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
     1811    hDlgTmpl = lppd->hPageSetupTemplate;
     1812    } else if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATE) {
     1813    hResInfo = FindResourceA(lppd->hInstance,
     1814                lppd->lpPageSetupTemplateName, RT_DIALOGA);
     1815    hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
    18151816    } else {
    1816         hResInfo = FindResourceA(COMDLG32_hInstance,(LPCSTR)PAGESETUPDLGORD,RT_DIALOGA);
    1817         hDlgTmpl = LoadResource(COMDLG32_hInstance,hResInfo);
     1817    hResInfo = FindResourceA(COMDLG32_hInstance,(LPCSTR)PAGESETUPDLGORD,RT_DIALOGA);
     1818    hDlgTmpl = LoadResource(COMDLG32_hInstance,hResInfo);
    18181819    }
    18191820    return hDlgTmpl;
     
    18231824_c_10mm2size(PAGESETUPDLGA *dlga,DWORD size) {
    18241825    if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)
    1825         return 10*size*10/25.4;
     1826    return 10*size*10/25.4;
    18261827    /* If we don't have a flag, we can choose one. Use millimeters
    18271828     * to avoid confusing me
     
    18361837_c_inch2size(PAGESETUPDLGA *dlga,DWORD size) {
    18371838    if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)
    1838         return size;
     1839    return size;
    18391840    if (dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS)
    1840         return (size*254)/10;
     1841    return (size*254)/10;
    18411842    /* if we don't have a flag, we can choose one. Use millimeters
    18421843     * to avoid confusing me
     
    18501851    strcpy(strout,"<undef>");
    18511852    if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) {
    1852         sprintf(strout,"%.2fmm",(size*1.0)/100.0);
    1853         return;
     1853    sprintf(strout,"%.2fmm",(size*1.0)/100.0);
     1854    return;
    18541855    }
    18551856    if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) {
    1856         sprintf(strout,"%.2fin",(size*1.0)/1000.0);
    1857         return;
     1857    sprintf(strout,"%.2fin",(size*1.0)/1000.0);
     1858    return;
    18581859    }
    18591860    pda->dlga->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS;
     
    18641865static DWORD
    18651866_c_str2size(PageSetupData *pda,LPCSTR strin) {
    1866     float       val;
    1867     char        rest[200];
     1867    float   val;
     1868    char    rest[200];
    18681869
    18691870    rest[0]='\0';
    18701871    if (!sscanf(strin,"%f%s",&val,rest))
    1871         return 0;
     1872    return 0;
    18721873
    18731874    if (!strcmp(rest,"in") || !strcmp(rest,"inch")) {
    1874         if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)
    1875             return 1000*val;
    1876         else
    1877             return val*25.4*100;
     1875    if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)
     1876        return 1000*val;
     1877    else
     1878        return val*25.4*100;
    18781879    }
    18791880    if (!strcmp(rest,"cm")) { rest[0]='m'; val = val*10.0; }
     
    18811882
    18821883    if (!strcmp(rest,"mm")) {
    1883         if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS)
    1884             return 100*val;
    1885         else
    1886             return 1000.0*val/25.4;
     1884    if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS)
     1885        return 100*val;
     1886    else
     1887        return 1000.0*val/25.4;
    18871888    }
    18881889    if (rest[0]=='\0') {
    1889         /* use application supplied default */
    1890         if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) {
    1891             /* 100*mm */
    1892             return 100.0*val;
    1893         }
    1894         if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) {
    1895             /* 1000*inch */
    1896             return 1000.0*val;
    1897         }
     1890    /* use application supplied default */
     1891    if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) {
     1892        /* 100*mm */
     1893        return 100.0*val;
     1894    }
     1895    if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) {
     1896        /* 1000*inch */
     1897        return 1000.0*val;
     1898    }
    18981899    }
    18991900    ERR("Did not find a conversion for type '%s'!\n",rest);
     
    19081909static BOOL
    19091910PRINTDLG_PS_UpdateDlgStruct(HWND hDlg, PageSetupData *pda) {
    1910     DEVNAMES    *dn;
    1911     DEVMODEA    *dm;
    1912     LPSTR       devname,portname;
    1913     char        papername[64];
    1914     char        buf[200];
    1915    
     1911    DEVNAMES    *dn;
     1912    DEVMODEA    *dm;
     1913    LPSTR   devname,portname;
     1914    char    papername[64];
     1915    char    buf[200];
     1916
    19161917    dn = GlobalLock(pda->pdlg.hDevNames);
    19171918    dm = GlobalLock(pda->pdlg.hDevMode);
    1918     devname     = ((char*)dn)+dn->wDeviceOffset;
    1919     portname    = ((char*)dn)+dn->wOutputOffset;
     1919    devname = ((char*)dn)+dn->wDeviceOffset;
     1920    portname    = ((char*)dn)+dn->wOutputOffset;
    19201921    PRINTDLG_SetUpPaperComboBox(hDlg,cmb2,devname,portname,dm);
    19211922    PRINTDLG_SetUpPaperComboBox(hDlg,cmb3,devname,portname,dm);
    19221923
    19231924    if (GetDlgItemTextA(hDlg,cmb2,papername,sizeof(papername))>0) {
    1924         PRINTDLG_PaperSize(&(pda->pdlg),papername,&(pda->dlga->ptPaperSize));
    1925         pda->dlga->ptPaperSize.x = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.x);
    1926         pda->dlga->ptPaperSize.y = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.y);
     1925        PRINTDLG_PaperSize(&(pda->pdlg),papername,&(pda->dlga->ptPaperSize));
     1926    pda->dlga->ptPaperSize.x = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.x);
     1927    pda->dlga->ptPaperSize.y = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.y);
    19271928    } else
    1928         FIXME("could not get dialog text for papersize cmbbox?\n");
     1929    FIXME("could not get dialog text for papersize cmbbox?\n");
    19291930#define GETVAL(id,val) if (GetDlgItemTextA(hDlg,id,buf,sizeof(buf))>0) { val = _c_str2size(pda,buf); } else { FIXME("could not get dlgitemtexta for %x\n",id); }
    19301931    GETVAL(edt4,pda->dlga->rtMargin.left);
     
    19361937    /* If we are in landscape, swap x and y of page size */
    19371938    if (IsDlgButtonChecked(hDlg, rad2)) {
    1938         DWORD tmp;
    1939         tmp = pda->dlga->ptPaperSize.x;
    1940         pda->dlga->ptPaperSize.x = pda->dlga->ptPaperSize.y;
    1941         pda->dlga->ptPaperSize.y = tmp;
     1939    DWORD tmp;
     1940    tmp = pda->dlga->ptPaperSize.x;
     1941    pda->dlga->ptPaperSize.x = pda->dlga->ptPaperSize.y;
     1942    pda->dlga->ptPaperSize.y = tmp;
    19421943    }
    19431944    GlobalUnlock(pda->pdlg.hDevNames);
     
    19511952static BOOL
    19521953PRINTDLG_PS_ChangePrinter(HWND hDlg, PageSetupData *pda) {
    1953     DEVNAMES    *dn;
    1954     DEVMODEA    *dm;
    1955     LPSTR       devname,portname;
    1956    
     1954    DEVNAMES    *dn;
     1955    DEVMODEA    *dm;
     1956    LPSTR   devname,portname;
     1957
    19571958    dn = GlobalLock(pda->pdlg.hDevNames);
    19581959    dm = GlobalLock(pda->pdlg.hDevMode);
    1959     devname     = ((char*)dn)+dn->wDeviceOffset;
    1960     portname    = ((char*)dn)+dn->wOutputOffset;
     1960    devname = ((char*)dn)+dn->wDeviceOffset;
     1961    portname    = ((char*)dn)+dn->wOutputOffset;
    19611962    PRINTDLG_SetUpPaperComboBox(hDlg,cmb2,devname,portname,dm);
    19621963    PRINTDLG_SetUpPaperComboBox(hDlg,cmb3,devname,portname,dm);
     
    19731974    case IDOK:
    19741975        if (!PRINTDLG_PS_UpdateDlgStruct(hDlg, pda))
    1975             return(FALSE);
    1976         EndDialog(hDlg, TRUE);
    1977         return TRUE ;
     1976        return(FALSE);
     1977    EndDialog(hDlg, TRUE);
     1978    return TRUE ;
    19781979
    19791980    case IDCANCEL:
    19801981        EndDialog(hDlg, FALSE);
    1981         return FALSE ;
     1982    return FALSE ;
    19821983
    19831984    case psh3: {
    1984         pda->pdlg.Flags         = 0;
    1985         pda->pdlg.hwndOwner     = hDlg;
    1986         if (PrintDlgA(&(pda->pdlg)))
    1987             PRINTDLG_PS_ChangePrinter(hDlg,pda);
    1988         return TRUE;
     1985    pda->pdlg.Flags     = 0;
     1986    pda->pdlg.hwndOwner = hDlg;
     1987    if (PrintDlgA(&(pda->pdlg)))
     1988        PRINTDLG_PS_ChangePrinter(hDlg,pda);
     1989    return TRUE;
    19891990    }
    19901991    }
    19911992    FIXME("loword (lparam) %d, wparam 0x%x, lparam %08lx, STUB mostly.\n",
    1992             LOWORD(lParam),wParam,lParam
     1993        LOWORD(lParam),wParam,lParam
    19931994    );
    19941995    return FALSE;
     
    19992000PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    20002001{
    2001     PageSetupData       *pda;
    2002     BOOL                res = FALSE;
     2002    PageSetupData   *pda;
     2003    BOOL        res = FALSE;
    20032004
    20042005    if (uMsg==WM_INITDIALOG) {
    2005         res = TRUE;
     2006    res = TRUE;
    20062007        pda = (PageSetupData*)lParam;
    2007         SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",lParam);
    2008         if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {
    2009             res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam);
    2010             if (!res) {
    2011                 FIXME("Setup page hook failed?\n");
    2012                 res = TRUE;
    2013             }
    2014         }
    2015         if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) {
    2016             FIXME("PagePaintHook not yet implemented!\n");
    2017         }
    2018         if (pda->dlga->Flags & PSD_DISABLEPRINTER)
    2019             EnableWindow(GetDlgItem(hDlg, psh3), FALSE);   
    2020         if (pda->dlga->Flags & PSD_DISABLEMARGINS) {
    2021             EnableWindow(GetDlgItem(hDlg, edt4), FALSE);   
    2022             EnableWindow(GetDlgItem(hDlg, edt5), FALSE);   
    2023             EnableWindow(GetDlgItem(hDlg, edt6), FALSE);   
    2024             EnableWindow(GetDlgItem(hDlg, edt7), FALSE);   
    2025         }
    2026         /* width larger as height -> landscape */
    2027         if (pda->dlga->ptPaperSize.x > pda->dlga->ptPaperSize.y)
     2008    SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",lParam);
     2009    if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {
     2010        res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam);
     2011        if (!res) {
     2012        FIXME("Setup page hook failed?\n");
     2013        res = TRUE;
     2014        }
     2015    }
     2016    if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) {
     2017        FIXME("PagePaintHook not yet implemented!\n");
     2018    }
     2019    if (pda->dlga->Flags & PSD_DISABLEPRINTER)
     2020            EnableWindow(GetDlgItem(hDlg, psh3), FALSE);
     2021    if (pda->dlga->Flags & PSD_DISABLEMARGINS) {
     2022            EnableWindow(GetDlgItem(hDlg, edt4), FALSE);
     2023            EnableWindow(GetDlgItem(hDlg, edt5), FALSE);
     2024            EnableWindow(GetDlgItem(hDlg, edt6), FALSE);
     2025            EnableWindow(GetDlgItem(hDlg, edt7), FALSE);
     2026    }
     2027    /* width larger as height -> landscape */
     2028    if (pda->dlga->ptPaperSize.x > pda->dlga->ptPaperSize.y)
    20282029            CheckRadioButton(hDlg, rad1, rad2, rad2);
    2029         else /* this is default if papersize is not set */
     2030    else /* this is default if papersize is not set */
    20302031            CheckRadioButton(hDlg, rad1, rad2, rad1);
    2031         if (pda->dlga->Flags & PSD_DISABLEORIENTATION) {
    2032             EnableWindow(GetDlgItem(hDlg,rad1),FALSE);
    2033             EnableWindow(GetDlgItem(hDlg,rad2),FALSE);
    2034         }
    2035         /* We fill them out enabled or not */
    2036         if (pda->dlga->Flags & PSD_MARGINS) {
    2037             char str[100];
    2038             _c_size2str(pda,pda->dlga->rtMargin.left,str);
    2039             SetDlgItemTextA(hDlg,edt4,str);
    2040             _c_size2str(pda,pda->dlga->rtMargin.top,str);
    2041             SetDlgItemTextA(hDlg,edt5,str);
    2042             _c_size2str(pda,pda->dlga->rtMargin.right,str);
    2043             SetDlgItemTextA(hDlg,edt6,str);
    2044             _c_size2str(pda,pda->dlga->rtMargin.bottom,str);
    2045             SetDlgItemTextA(hDlg,edt7,str);
    2046         } else {
    2047             /* default is 1 inch */
    2048             DWORD size = _c_inch2size(pda->dlga,1000);
    2049             char        str[20];
    2050             _c_size2str(pda,size,str);
    2051             SetDlgItemTextA(hDlg,edt4,str);
    2052             SetDlgItemTextA(hDlg,edt5,str);
    2053             SetDlgItemTextA(hDlg,edt6,str);
    2054             SetDlgItemTextA(hDlg,edt7,str);
    2055         }
    2056         PRINTDLG_PS_ChangePrinter(hDlg,pda);
    2057         if (pda->dlga->Flags & PSD_DISABLEPAPER) {
    2058             EnableWindow(GetDlgItem(hDlg,cmb2),FALSE);
    2059             EnableWindow(GetDlgItem(hDlg,cmb3),FALSE);
    2060         }
    2061         return TRUE;
     2032    if (pda->dlga->Flags & PSD_DISABLEORIENTATION) {
     2033        EnableWindow(GetDlgItem(hDlg,rad1),FALSE);
     2034        EnableWindow(GetDlgItem(hDlg,rad2),FALSE);
     2035    }
     2036    /* We fill them out enabled or not */
     2037    if (pda->dlga->Flags & PSD_MARGINS) {
     2038        char str[100];
     2039        _c_size2str(pda,pda->dlga->rtMargin.left,str);
     2040        SetDlgItemTextA(hDlg,edt4,str);
     2041        _c_size2str(pda,pda->dlga->rtMargin.top,str);
     2042        SetDlgItemTextA(hDlg,edt5,str);
     2043        _c_size2str(pda,pda->dlga->rtMargin.right,str);
     2044        SetDlgItemTextA(hDlg,edt6,str);
     2045        _c_size2str(pda,pda->dlga->rtMargin.bottom,str);
     2046        SetDlgItemTextA(hDlg,edt7,str);
    20622047    } else {
    2063         pda = (PageSetupData*)GetPropA(hDlg,"__WINE_PAGESETUPDLGDATA");
    2064         if (!pda) {
    2065             WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
    2066             return FALSE;
    2067         }
    2068         if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {
    2069             res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam);
    2070             if (res) return res;
    2071         }
     2048        /* default is 1 inch */
     2049        DWORD size = _c_inch2size(pda->dlga,1000);
     2050        char    str[20];
     2051        _c_size2str(pda,size,str);
     2052        SetDlgItemTextA(hDlg,edt4,str);
     2053        SetDlgItemTextA(hDlg,edt5,str);
     2054        SetDlgItemTextA(hDlg,edt6,str);
     2055        SetDlgItemTextA(hDlg,edt7,str);
     2056    }
     2057    PRINTDLG_PS_ChangePrinter(hDlg,pda);
     2058    if (pda->dlga->Flags & PSD_DISABLEPAPER) {
     2059        EnableWindow(GetDlgItem(hDlg,cmb2),FALSE);
     2060        EnableWindow(GetDlgItem(hDlg,cmb3),FALSE);
     2061    }
     2062    return TRUE;
     2063    } else {
     2064    pda = (PageSetupData*)GetPropA(hDlg,"__WINE_PAGESETUPDLGDATA");
     2065    if (!pda) {
     2066        WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
     2067        return FALSE;
     2068    }
     2069    if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {
     2070        res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam);
     2071        if (res) return res;
     2072    }
    20722073    }
    20732074    switch (uMsg) {
     
    20822083 */
    20832084BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) {
    2084     HGLOBAL             hDlgTmpl;
    2085     LPVOID              ptr;
    2086     BOOL                bRet;
    2087     PageSetupData       *pda;
    2088     PRINTDLGA           pdlg;
     2085    HGLOBAL     hDlgTmpl;
     2086    LPVOID      ptr;
     2087    BOOL        bRet;
     2088    PageSetupData   *pda;
     2089    PRINTDLGA       pdlg;
    20892090
    20902091#ifdef __WIN32OS2__
     
    20942095    if(TRACE_ON(commdlg)) {
    20952096        char flagstr[1000] = "";
    2096         struct pd_flags *pflag = psd_flags;
    2097         for( ; pflag->name; pflag++) {
    2098             if(setupdlg->Flags & pflag->flag) {
    2099                 strcat(flagstr, pflag->name);
    2100                 strcat(flagstr, "|");
    2101             }
    2102         }
    2103         TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
    2104               "hinst %08x, flags %08lx (%s)\n",
    2105               setupdlg, setupdlg->hwndOwner, setupdlg->hDevMode,
    2106               setupdlg->hDevNames,
    2107               setupdlg->hInstance, setupdlg->Flags, flagstr);
     2097    struct pd_flags *pflag = psd_flags;
     2098    for( ; pflag->name; pflag++) {
     2099        if(setupdlg->Flags & pflag->flag) {
     2100            strcat(flagstr, pflag->name);
     2101            strcat(flagstr, "|");
     2102        }
     2103    }
     2104    TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
     2105          "hinst %08x, flags %08lx (%s)\n",
     2106          setupdlg, setupdlg->hwndOwner, setupdlg->hDevMode,
     2107          setupdlg->hDevNames,
     2108          setupdlg->hInstance, setupdlg->Flags, flagstr);
    21082109    }
    21092110
    21102111    /* First get default printer data, we need it right after that. */
    21112112    memset(&pdlg,0,sizeof(pdlg));
    2112     pdlg.lStructSize    = sizeof(pdlg);
    2113     pdlg.Flags          = PD_RETURNDEFAULT;
     2113    pdlg.lStructSize    = sizeof(pdlg);
     2114    pdlg.Flags      = PD_RETURNDEFAULT;
    21142115    bRet = PrintDlgA(&pdlg);
    21152116    if (!bRet) return FALSE;
     
    21172118    /* short cut exit, just return default values */
    21182119    if (setupdlg->Flags & PSD_RETURNDEFAULT) {
    2119         setupdlg->hDevMode      = pdlg.hDevMode;
    2120         setupdlg->hDevNames     = pdlg.hDevNames;
    2121         /* FIXME: Just return "A4" for now. */
    2122         PRINTDLG_PaperSize(&pdlg,"A4",&setupdlg->ptPaperSize);
    2123         setupdlg->ptPaperSize.x=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.x);
    2124         setupdlg->ptPaperSize.y=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.y);
    2125         return TRUE;
     2120    setupdlg->hDevMode  = pdlg.hDevMode;
     2121    setupdlg->hDevNames = pdlg.hDevNames;
     2122    /* FIXME: Just return "A4" for now. */
     2123        PRINTDLG_PaperSize(&pdlg,"A4",&setupdlg->ptPaperSize);
     2124    setupdlg->ptPaperSize.x=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.x);
     2125    setupdlg->ptPaperSize.y=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.y);
     2126    return TRUE;
    21262127    }
    21272128    hDlgTmpl = PRINTDLG_GetPGSTemplate(setupdlg);
    21282129    if (!hDlgTmpl) {
    2129         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    2130         return FALSE;
     2130    COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     2131    return FALSE;
    21312132    }
    21322133    ptr = LockResource( hDlgTmpl );
    21332134    if (!ptr) {
    2134         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    2135         return FALSE;
     2135    COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     2136    return FALSE;
    21362137    }
    21372138    pda = HeapAlloc(GetProcessHeap(),0,sizeof(*pda));
     
    21402141
    21412142    bRet = (0<DialogBoxIndirectParamA(
    2142                 setupdlg->hInstance,
    2143                 ptr,
    2144                 setupdlg->hwndOwner,
    2145                 PageDlgProcA,
    2146                 (LPARAM)pda)
     2143        setupdlg->hInstance,
     2144        ptr,
     2145        setupdlg->hwndOwner,
     2146        PageDlgProcA,
     2147        (LPARAM)pda)
    21472148    );
    21482149    return bRet;
     
    21552156    dprintf(("PageSetupDlgA %x NOT IMPLEMENTED", setupdlg));
    21562157#endif
    2157         FIXME("(%p), stub!\n",setupdlg);
    2158         return FALSE;
     2158    FIXME("(%p), stub!\n",setupdlg);
     2159    return FALSE;
    21592160}
    21602161
     
    21752176
    21762177    if (uMsg!=WM_INITDIALOG) {
    2177         PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);   
    2178         if (!PrintStructures)
    2179             return FALSE;
     2178        PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);
     2179    if (!PrintStructures)
     2180        return FALSE;
    21802181    } else {
    21812182        PrintStructures = (PRINT_PTRA*) lParam;
    2182         SetWindowLongA(hDlg, DWL_USER, lParam);
    2183         res = PRINTDLG_WMInitDialog16(hDlg, wParam, PrintStructures);
    2184 
    2185         if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) {
    2186             res = CallWindowProc16(
    2187                 (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook,
    2188                 hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg16
    2189             );
    2190         }
    2191         return res;
    2192     }
    2193  
     2183    SetWindowLongA(hDlg, DWL_USER, lParam);
     2184    res = PRINTDLG_WMInitDialog16(hDlg, wParam, PrintStructures);
     2185
    21942186    if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) {
    21952187        res = CallWindowProc16(
    2196                 (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook,
    2197                 hDlg,uMsg, wParam, lParam
    2198         );
    2199         if(LOWORD(res)) return res;
     2188        (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook,
     2189        hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg16
     2190        );
     2191    }
     2192    return res;
     2193    }
     2194
     2195    if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) {
     2196        res = CallWindowProc16(
     2197        (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook,
     2198        hDlg,uMsg, wParam, lParam
     2199    );
     2200    if(LOWORD(res)) return res;
    22002201    }
    22012202
    22022203    switch (uMsg) {
    22032204    case WM_COMMAND: {
    2204         /* We need to map those for the 32bit window procedure, compare
    2205           * with 32Ato16 mapper in winproc.c
    2206           */
     2205    /* We need to map those for the 32bit window procedure, compare
     2206      * with 32Ato16 mapper in winproc.c
     2207      */
    22072208        return PRINTDLG_WMCommand(
    2208                 hDlg,
    2209                 MAKEWPARAM(wParam,HIWORD(lParam)),
    2210                 LOWORD(lParam),
    2211                 PrintStructures
    2212         );
     2209        hDlg,
     2210        MAKEWPARAM(wParam,HIWORD(lParam)),
     2211        LOWORD(lParam),
     2212        PrintStructures
     2213    );
    22132214    }
    22142215    case WM_DESTROY:
    2215         DestroyIcon(PrintStructures->hCollateIcon);
    2216         DestroyIcon(PrintStructures->hNoCollateIcon);
     2216    DestroyIcon(PrintStructures->hCollateIcon);
     2217    DestroyIcon(PrintStructures->hNoCollateIcon);
    22172218    /* FIXME: don't forget to delete the paper orientation icons here! */
    22182219
    22192220        return FALSE;
    2220     }   
     2221    }
    22212222    return res;
    22222223}
     
    22272228 */
    22282229LRESULT WINAPI PrintSetupDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
    2229                                    LPARAM lParam)
     2230                   LPARAM lParam)
    22302231{
    22312232  switch (wMsg)
     
    22382239      switch (wParam) {
    22392240      case IDOK:
    2240         EndDialog(hWnd, TRUE);
    2241         return(TRUE);
     2241    EndDialog(hWnd, TRUE);
     2242    return(TRUE);
    22422243      case IDCANCEL:
    2243         EndDialog(hWnd, FALSE);
    2244         return(TRUE);
     2244    EndDialog(hWnd, FALSE);
     2245    return(TRUE);
    22452246      }
    22462247      return(FALSE);
     
    22512252
    22522253/***********************************************************************
    2253  *      PrintDlgExA (COMDLG32.@)
     2254 *  PrintDlgExA (COMDLG32.@)
    22542255 */
    22552256HRESULT WINAPI PrintDlgExA(LPVOID lpPrintDlgExA) /* [???] FIXME: LPPRINTDLGEXA */
    22562257{
    2257         FIXME("stub\n");
    2258         return E_NOTIMPL;
     2258    FIXME("stub\n");
     2259    return E_NOTIMPL;
    22592260}
    22602261/***********************************************************************
    2261  *      PrintDlgExW (COMDLG32.@)
     2262 *  PrintDlgExW (COMDLG32.@)
    22622263 */
    22632264HRESULT WINAPI PrintDlgExW(LPVOID lpPrintDlgExW) /* [???] FIXME: LPPRINTDLGEXW */
    22642265{
    2265         FIXME("stub\n");
    2266         return E_NOTIMPL;
    2267 }
     2266    FIXME("stub\n");
     2267    return E_NOTIMPL;
     2268}
  • trunk/src/crtdll/crtdll.cpp

    r5472 r6645  
     1/* $Id: crtdll.cpp,v 1.30 2001-09-05 12:14:23 bird Exp $ */
    12/*
    23 * The C RunTime DLL
    3  * 
     4 *
    45 * Implements C run-time functionality as known from UNIX.
    56 *
    6  * TODO: 
     7 * TODO:
    78 *   - Check setjmp(3)
    89 *   - fix *ALL* functions for the FS: wrapper problem
     
    7273// Definitions for internal functions
    7374//
    74 void            qsort1 (char*, char*, size_t,
     75void        qsort1 (char*, char*, size_t,
    7576                    int (* CDECL)(const void*, const void*));
    7677
     
    444445
    445446/*********************************************************************
    446  *      _cscanf                                 (CRTDLL.67)
     447 *  _cscanf                     (CRTDLL.67)
    447448 */
    448449INT CDECL CRTDLL__cscanf( char *s, va_list arg )
     
    604605
    605606/*********************************************************************
    606  *      _ftime                                  (CRTDLL.112)
     607 *  _ftime                  (CRTDLL.112)
    607608 */
    608609void CDECL CRTDLL__ftime( struct timeb *timebuf )
     
    618619LONG CDECL CRTDLL__ftol(void)
    619620{
    620         /* don't just do DO_FPU("fistp",retval), because the rounding
    621         * mode must also be set to "round towards zero"... */
    622         double fl;
    623         POP_FPU(fl);
    624         return (LONG)fl;
     621    /* don't just do DO_FPU("fistp",retval), because the rounding
     622    * mode must also be set to "round towards zero"... */
     623    double fl;
     624    POP_FPU(fl);
     625    return (LONG)fl;
    625626}
    626627
     
    775776
    776777/*********************************************************************
    777  *                  _ltoa       (CRTDLL.179)
     778 *                  _ltoa   (CRTDLL.179)
    778779 */
    779780LPSTR  CDECL CRTDLL__ltoa(long x,LPSTR buf,INT radix)
     
    784785
    785786/*********************************************************************
    786  *                  _matherr    (CRTDLL.181)
     787 *                  _matherr    (CRTDLL.181)
    787788 */
    788789double CDECL CRTDLL__matherr( struct exception * excep )
     
    881882
    882883/*********************************************************************
    883  *           CRTDLL__searchenv   (CRTDLL.260)
     884 *           CRTDLL__searchenv   (CRTDLL.260)
    884885 */
    885886void CDECL CRTDLL__searchenv(char *file, char *var,char *path )
     
    891892
    892893/*********************************************************************
    893  *           CRTDLL__seterrormode       (CRTDLL.261)
     894 *           CRTDLL__seterrormode   (CRTDLL.261)
    894895 */
    895896void CDECL CRTDLL__seterrormode(int uMode)
     
    902903
    903904/*********************************************************************
    904  *           CRTDLL__setjmp     (CRTDLL.262)
     905 *           CRTDLL__setjmp     (CRTDLL.262)
    905906 */
    906907int CDECL CRTDLL__setjmp( jmp_buf env )
     
    937938
    938939/*********************************************************************
    939  *      _sopen                                  (CRTDLL.268)
     940 *  _sopen                  (CRTDLL.268)
    940941 */
    941942int CDECL CRTDLL__sopen( const char *s, int i1, int i2, va_list arg )
     
    947948
    948949/*********************************************************************
    949  *           CRTDLL__spawnl     (CRTDLL.269)
     950 *           CRTDLL__spawnl     (CRTDLL.269)
    950951 */
    951952int CDECL CRTDLL__spawnl(int nMode, char* szPath, char* szArgv0, va_list arg)
     
    957958
    958959/*********************************************************************
    959  *           CRTDLL__spawnle     (CRTDLL.270)
     960 *           CRTDLL__spawnle     (CRTDLL.270)
    960961 */
    961962int CDECL CRTDLL__spawnle( int mode, char *path, char **szArgv0, va_list arg )
     
    967968
    968969/*********************************************************************
    969  *           CRTDLL__spawnlp     (CRTDLL.271)
     970 *           CRTDLL__spawnlp     (CRTDLL.271)
    970971 */
    971972int CDECL CRTDLL__spawnlp(int nMode, char* szPath, char* szArgv0, va_list arg)
     
    977978
    978979/*********************************************************************
    979  *           CRTDLL__spawnlpe   (CRTDLL.272)
     980 *           CRTDLL__spawnlpe   (CRTDLL.272)
    980981 */
    981982int CDECL CRTDLL__spawnlpe( int mode, char *path, char *szArgv0, va_list arg )
     
    987988
    988989/*********************************************************************
    989  *           CRTDLL__spawnv     (CRTDLL.273)
     990 *           CRTDLL__spawnv     (CRTDLL.273)
    990991 */
    991992int CDECL CRTDLL__spawnv( int i, char *s1, char ** s2 )
     
    997998
    998999/*********************************************************************
    999  *           CRTDLL__spawnvp     (CRTDLL.275)
     1000 *           CRTDLL__spawnvp     (CRTDLL.275)
    10001001 */
    10011002int CDECL CRTDLL__spawnvp( int i, char *s1, char ** s2 )
     
    10061007
    10071008/*********************************************************************
    1008  *           CRTDLL__spawnv     (CRTDLL.276)
     1009 *           CRTDLL__spawnv     (CRTDLL.276)
    10091010 */
    10101011int CDECL CRTDLL__spawnvpe( int i, char *s1, char ** s2, char ** s3 )
     
    10161017
    10171018/*********************************************************************
    1018  *           CRTDLL__statusfp    (CRTDLL.279)
     1019 *           CRTDLL__statusfp    (CRTDLL.279)
    10191020 */
    10201021unsigned int CDECL CRTDLL__statusfp( void )
     
    10231024  return (_status87());
    10241025}
    1025        
    1026 
    1027 /*********************************************************************
    1028  *           _ultoa              (CRTDLL.309)
     1026
     1027
     1028/*********************************************************************
     1029 *           _ultoa      (CRTDLL.309)
    10291030 */
    10301031LPSTR  CDECL CRTDLL__ultoa(long x,LPSTR buf,INT radix)
     
    10361037
    10371038/*********************************************************************
    1038  *           CRTDLL__ungetch    (CRTDLL.311)
     1039 *           CRTDLL__ungetch    (CRTDLL.311)
    10391040 */
    10401041int CDECL CRTDLL__ungetch( int i )
     
    10461047
    10471048/*********************************************************************
    1048  *           _utime              (CRTDLL.314)
     1049 *           _utime      (CRTDLL.314)
    10491050 */
    10501051int CDECL CRTDLL__utime( char *path, struct utimbuf * times )
     
    10561057
    10571058/*********************************************************************
    1058  *      _vsnprintf                              (CRTDLL.315)
     1059 *  _vsnprintf              (CRTDLL.315)
    10591060 */
    10601061int CDECL CRTDLL__vsnprintf( char *s, size_t bufsize, const char *format, va_list arg )
     
    11001101
    11011102/*********************************************************************
    1102  *                  abs         (CRTDLL.336)
     1103 *                  abs     (CRTDLL.336)
    11031104 */
    11041105double CDECL CRTDLL_abs(double d)
     
    11121113
    11131114/*********************************************************************
    1114  *                  acos        (CRTDLL.337)
     1115 *                  acos    (CRTDLL.337)
    11151116 */
    11161117double CDECL CRTDLL_acos( double x )
     
    11221123
    11231124/*********************************************************************
    1124  *                  asctime     (CRTDLL.338)
     1125 *                  asctime (CRTDLL.338)
    11251126 */
    11261127char * CDECL CRTDLL_asctime( const struct tm *timeptr )
     
    11321133
    11331134/*********************************************************************
    1134  *                  asin        (CRTDLL.339)
     1135 *                  asin    (CRTDLL.339)
    11351136 */
    11361137double CDECL CRTDLL_asin( double x )
     
    11421143
    11431144/*********************************************************************
    1144  *                  atan        (CRTDLL.340)
     1145 *                  atan    (CRTDLL.340)
    11451146 */
    11461147double CDECL CRTDLL_atan(double d)
     
    11541155
    11551156/*********************************************************************
    1156  *                  atan2       (CRTDLL.341)
     1157 *                  atan2   (CRTDLL.341)
    11571158 */
    11581159double CDECL CRTDLL_atan2( double y, double x )
     
    11641165
    11651166/*********************************************************************
    1166  *                  atof        (CRTDLL.343)
     1167 *                  atof    (CRTDLL.343)
    11671168 */
    11681169double CDECL CRTDLL_atof( const char *nptr )
     
    11741175
    11751176/*********************************************************************
    1176  *                  atoi        (CRTDLL.344)
     1177 *                  atoi    (CRTDLL.344)
    11771178 */
    11781179int CDECL CRTDLL_atoi(LPSTR str)
     
    11861187
    11871188/*********************************************************************
    1188  *                  atol        (CRTDLL.345)
     1189 *                  atol    (CRTDLL.345)
    11891190 */
    11901191long CDECL CRTDLL_atol(LPSTR str)
     
    11981199
    11991200/*********************************************************************
    1200  *                  bsearch     (CRTDLL.346)
     1201 *                  bsearch (CRTDLL.346)
    12011202 */
    12021203void *CDECL CRTDLL_bsearch (const void *key, const void *base, size_t num, size_t width,
     
    12051206  int left, right, median, sign;
    12061207  const void *element;
    1207  
     1208
    12081209  if (width == 0)
    12091210    return 0;
     
    12261227
    12271228/*********************************************************************
    1228  *                  ceil        (CRTDLL.348)
     1229 *                  ceil    (CRTDLL.348)
    12291230 */
    12301231double CDECL CRTDLL_ceil(double d)
     
    12371238
    12381239/*********************************************************************
    1239  *                  clock       (CRTDLL.350)
     1240 *                  clock   (CRTDLL.350)
    12401241 */
    12411242clock_t CDECL CRTDLL_clock( void )
     
    12471248
    12481249/*********************************************************************
    1249  *                  cos         (CRTDLL.351)
     1250 *                  cos     (CRTDLL.351)
    12501251 */
    12511252double CDECL CRTDLL_cos(double d)
     
    12591260
    12601261/*********************************************************************
    1261  *                  cosh        (CRTDLL.352)
     1262 *                  cosh    (CRTDLL.352)
    12621263 */
    12631264double CDECL CRTDLL_cosh( double x )
     
    12691270
    12701271/*********************************************************************
    1271  *                  ctime       (CRTDLL.353)
     1272 *                  ctime   (CRTDLL.353)
    12721273 */
    12731274char * CDECL CRTDLL_ctime( const time_t *timer )
     
    12791280
    12801281/*********************************************************************
    1281  *                  difftime    (CRTDLL.354)
     1282 *                  difftime    (CRTDLL.354)
    12821283 */
    12831284double CDECL CRTDLL_difftime( time_t t1, time_t t0 )
     
    12891290
    12901291/*********************************************************************
    1291  *                  div         (CRTDLL.355)
     1292 *                  div     (CRTDLL.355)
    12921293 */
    12931294ULONG CDECL CRTDLL_div( int number, int denom )
     
    13031304
    13041305/*********************************************************************
    1305  *                  exp         (CRTDLL.357)
     1306 *                  exp     (CRTDLL.357)
    13061307 */
    13071308double CDECL CRTDLL_exp( double x )
     
    13131314
    13141315/*********************************************************************
    1315  *                  fabs        (CRTDLL.358)
     1316 *                  fabs    (CRTDLL.358)
    13161317 */
    13171318double CDECL CRTDLL_fabs(double d)
     
    13251326
    13261327/*********************************************************************
    1327  *                  floor               (CRTDLL.367)
     1328 *                  floor       (CRTDLL.367)
    13281329 */
    13291330double CDECL CRTDLL_floor(double d)
     
    13371338
    13381339/*********************************************************************
    1339  *                  fmod        (CRTDLL.368)
     1340 *                  fmod    (CRTDLL.368)
    13401341 */
    13411342double CDECL CRTDLL_fmod(double x, double y )
     
    13471348
    13481349/*********************************************************************
    1349  *                  frexp         (CRTDLL.377)
     1350 *                  frexp     (CRTDLL.377)
    13501351 */
    13511352double CDECL CRTDLL_frexp( double value, int *exp )
     
    14891490
    14901491/*********************************************************************
    1491  *                  labs        (CRTDLL.416)
     1492 *                  labs    (CRTDLL.416)
    14921493 */
    14931494long int CDECL CRTDLL_labs( long int j )
     
    14991500
    15001501/*********************************************************************
    1501  *                  ldexp       (CRTDLL.417)
    1502  */
    1503 double CDECL CRTDLL_ldexp( double x, int exp ) 
     1502 *                  ldexp   (CRTDLL.417)
     1503 */
     1504double CDECL CRTDLL_ldexp( double x, int exp )
    15041505{
    15051506  dprintf2(("CRTDLL: ldexp\n"));
     
    15091510
    15101511/*********************************************************************
    1511  *                  ldiv        (CRTDLL.418)
    1512  */
    1513 ldiv_t CDECL CRTDLL_ldiv( long int numer, long int denom ) 
     1512 *                  ldiv    (CRTDLL.418)
     1513 */
     1514ldiv_t CDECL CRTDLL_ldiv( long int numer, long int denom )
    15141515{
    15151516  dprintf2(("CRTDLL: ldiv\n"));
     
    15191520
    15201521/*********************************************************************
    1521  *                  localeconv  (CRTDLL.419)
     1522 *                  localeconv  (CRTDLL.419)
    15221523 */
    15231524struct lconv * CDECL CRTDLL_localeconv(void)
     
    15291530
    15301531/*********************************************************************
    1531  *                  localtime   (CRTDLL.420)
     1532 *                  localtime   (CRTDLL.420)
    15321533 */
    15331534struct tm * CDECL CRTDLL_localtime( const time_t *timer )
     
    15391540
    15401541/*********************************************************************
    1541  *                  log         (CRTDLL.421)
     1542 *                  log     (CRTDLL.421)
    15421543 */
    15431544double CDECL CRTDLL_log( double x )
     
    15491550
    15501551/*********************************************************************
    1551  *                  log10       (CRTDLL.422)
     1552 *                  log10   (CRTDLL.422)
    15521553 */
    15531554double CDECL CRTDLL_log10( double x )
     
    15811582 *                  pow      (CRTDLL.436)
    15821583 */
    1583 double CDECL CRTDLL_pow( double x, double y )   
     1584double CDECL CRTDLL_pow( double x, double y )
    15841585{
    15851586    dprintf2(("CRTDLL: pow(%08xh, %08xh)\n",x, y));
     
    16211622
    16221623/*********************************************************************
    1623  *      scanf                                   (CRTDLL.448)
     1624 *  scanf                   (CRTDLL.448)
    16241625 */
    16251626int CDECL CRTDLL_scanf( const char *format, va_list arg )
     
    17051706
    17061707/*********************************************************************
    1707  *      sscanf                                  (CRTDLL.458)
     1708 *  sscanf                  (CRTDLL.458)
    17081709 */
    17091710int CDECL CRTDLL_sscanf( const char *s, const char *format, va_list arg )
     
    17821783
    17831784/*********************************************************************
    1784  *      ungetc                                  (CRTDLL.492)
     1785 *  ungetc                  (CRTDLL.492)
    17851786 */
    17861787INT CDECL CRTDLL_ungetc(int c, FILE *f)
     
    18121813
    18131814/*********************************************************************
    1814  *           CRTDLL__setjmp3     (CRTDLL.600)
     1815 *           CRTDLL__setjmp3     (CRTDLL.600)
    18151816 */
    18161817int CDECL CRTDLL__setjmp3( jmp_buf env )
  • trunk/src/crtdll/crtdll_main.c

    r4667 r6645  
     1/* $Id: crtdll_main.c,v 1.2 2001-09-05 12:14:24 bird Exp $ */
    12/*
    23 * The C RunTime DLL
    3  * 
     4 *
    45 * Implements C run-time functionality as known from UNIX.
    56 *
     
    1314Unresolved issues Uwe Bonnes 970904:
    1415- tested with ftp://ftp.remcomp.com/pub/remcomp/lcc-win32.zip, a C-Compiler
    15                 for Win32, based on lcc, from Jacob Navia
     16        for Win32, based on lcc, from Jacob Navia
    1617UB 000416:
    1718- probably not thread safe
    1819*/
    1920
    20 /* NOTE: This file also implements the wcs* functions. They _ARE_ in 
     21/* NOTE: This file also implements the wcs* functions. They _ARE_ in
    2122 * the newer Linux libcs, but use 4 byte wide characters, so are unusable,
    2223 * since we need 2 byte wide characters. - Marcus Meissner, 981031
     
    6364UINT CRTDLL_winminor_dll;     /* CRTDLL.330 */
    6465UINT CRTDLL_winver_dll;       /* CRTDLL.331 */
    65 INT  CRTDLL_doserrno = 0; 
     66INT  CRTDLL_doserrno = 0;
    6667INT  CRTDLL_errno = 0;
    6768const INT  CRTDLL__sys_nerr = 43;
     
    7778 *                  CRTDLL_MainInit  (CRTDLL.init)
    7879 */
    79  
     80
    8081BOOL WINAPI CRTDLL_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
    8182{
    8283  FS_OS2
    83    
     84
    8485    // call i/o initializer in file.c
    85     if (fdwReason == DLL_PROCESS_ATTACH) 
     86    if (fdwReason == DLL_PROCESS_ATTACH)
    8687    {
    8788      __CRTDLL__init_io();
    8889    }
    89    
     90
    9091  /*
    9192    PH 2000/11/21 this code doesn't look very useful
    92    
     93
    9394    if (fdwReason == DLL_PROCESS_ATTACH) {
    9495      _fdopen(0,"r");
     
    103104      }
    104105  */
    105  
     106
    106107  FS_WIN32
    107108  return TRUE;
     
    176177        char *cmdline;
    177178        char  **xargv;
    178         int     xargc,end,last_arg,afterlastspace;
    179         DWORD   version;
    180 
    181         TRACE("(%p,%p,%p,%ld).\n",
    182                 argc,argv,environ,flag
    183         );
    184 
    185         if (CRTDLL_acmdln_dll != NULL)
    186                 HeapFree(GetProcessHeap(), 0, CRTDLL_acmdln_dll);
    187 
    188         CRTDLL_acmdln_dll = cmdline = CRTDLL__strdup( GetCommandLineA() );
    189         TRACE("got '%s'\n", cmdline);
    190 
    191         version = GetVersion();
    192         CRTDLL_osver_dll       = version >> 16;
    193         CRTDLL_winminor_dll    = version & 0xFF;
    194         CRTDLL_winmajor_dll    = (version>>8) & 0xFF;
    195         CRTDLL_baseversion_dll = version >> 16;
    196         CRTDLL_winver_dll      = ((version >> 8) & 0xFF) + ((version & 0xFF) << 8);
    197         CRTDLL_baseminor_dll   = (version >> 16) & 0xFF;
    198         CRTDLL_basemajor_dll   = (version >> 24) & 0xFF;
    199         CRTDLL_osversion_dll   = version & 0xFFFF;
    200         CRTDLL_osminor_dll     = version & 0xFF;
    201         CRTDLL_osmajor_dll     = (version>>8) & 0xFF;
    202 
    203         /* missing threading init */
    204 
    205         end=0;last_arg=0;xargv=NULL;xargc=0;afterlastspace=0;
    206         while (1)
    207         {
    208             if ((cmdline[end]==' ') || (cmdline[end]=='\0'))
    209             {
    210                 if (cmdline[end]=='\0')
    211                     last_arg=1;
    212                 else
    213                     cmdline[end]='\0';
    214                 /* alloc xargc + NULL entry */
    215                         xargv=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv,
    216                                              sizeof(char*)*(xargc+1));
    217                 if (strlen(cmdline+afterlastspace))
    218                 {
    219                     xargv[xargc] = CRTDLL__strdup(cmdline+afterlastspace);
    220                     xargc++;
     179    int xargc,end,last_arg,afterlastspace;
     180    DWORD   version;
     181
     182    TRACE("(%p,%p,%p,%ld).\n",
     183        argc,argv,environ,flag
     184    );
     185
     186    if (CRTDLL_acmdln_dll != NULL)
     187        HeapFree(GetProcessHeap(), 0, CRTDLL_acmdln_dll);
     188
     189    CRTDLL_acmdln_dll = cmdline = CRTDLL__strdup( GetCommandLineA() );
     190    TRACE("got '%s'\n", cmdline);
     191
     192    version = GetVersion();
     193    CRTDLL_osver_dll       = version >> 16;
     194    CRTDLL_winminor_dll    = version & 0xFF;
     195    CRTDLL_winmajor_dll    = (version>>8) & 0xFF;
     196    CRTDLL_baseversion_dll = version >> 16;
     197    CRTDLL_winver_dll      = ((version >> 8) & 0xFF) + ((version & 0xFF) << 8);
     198    CRTDLL_baseminor_dll   = (version >> 16) & 0xFF;
     199    CRTDLL_basemajor_dll   = (version >> 24) & 0xFF;
     200    CRTDLL_osversion_dll   = version & 0xFFFF;
     201    CRTDLL_osminor_dll     = version & 0xFF;
     202    CRTDLL_osmajor_dll     = (version>>8) & 0xFF;
     203
     204    /* missing threading init */
     205
     206    end=0;last_arg=0;xargv=NULL;xargc=0;afterlastspace=0;
     207    while (1)
     208    {
     209        if ((cmdline[end]==' ') || (cmdline[end]=='\0'))
     210        {
     211        if (cmdline[end]=='\0')
     212            last_arg=1;
     213        else
     214            cmdline[end]='\0';
     215        /* alloc xargc + NULL entry */
     216            xargv=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv,
     217                                     sizeof(char*)*(xargc+1));
     218        if (strlen(cmdline+afterlastspace))
     219        {
     220            xargv[xargc] = CRTDLL__strdup(cmdline+afterlastspace);
     221            xargc++;
    221222                    if (!last_arg) /* need to seek to the next arg ? */
    222                     {
    223                         end++;
    224                         while (cmdline[end]==' ')
    225                             end++;
    226         }
    227                     afterlastspace=end;
    228                 }
    229                 else
    230                 {
    231                     xargv[xargc] = NULL; /* the last entry is NULL */
    232                     break;
    233                 }
    234             }
    235             else
    236                 end++;
    237         }
    238         CRTDLL_argc_dll = xargc;
    239         *argc           = xargc;
    240         CRTDLL_argv_dll = xargv;
    241         *argv           = xargv;
    242 
    243         TRACE("found %d arguments\n",
    244                 CRTDLL_argc_dll);
    245         CRTDLL_environ_dll = *environ = GetEnvironmentStringsA();
    246         return environ;
     223            {
     224            end++;
     225            while (cmdline[end]==' ')
     226                end++;
     227    }
     228            afterlastspace=end;
     229        }
     230        else
     231        {
     232            xargv[xargc] = NULL; /* the last entry is NULL */
     233            break;
     234        }
     235        }
     236        else
     237        end++;
     238    }
     239    CRTDLL_argc_dll = xargc;
     240    *argc       = xargc;
     241    CRTDLL_argv_dll = xargv;
     242    *argv       = xargv;
     243
     244    TRACE("found %d arguments\n",
     245        CRTDLL_argc_dll);
     246    CRTDLL_environ_dll = *environ = GetEnvironmentStringsA();
     247    return environ;
    247248}
    248249
     
    253254DWORD CDECL CRTDLL__initterm(_INITTERMFUN *start,_INITTERMFUN *end)
    254255{
    255         _INITTERMFUN    *current;
    256 
    257         TRACE("(%p,%p)\n",start,end);
    258         current=start;
    259         while (current<end) {
    260                 if (*current) (*current)();
    261                 current++;
    262         }
    263         return 0;
     256    _INITTERMFUN    *current;
     257
     258    TRACE("(%p,%p)\n",start,end);
     259    current=start;
     260    while (current<end) {
     261        if (*current) (*current)();
     262        current++;
     263    }
     264    return 0;
    264265}
    265266
     
    309310INT CDECL CRTDLL_rand()
    310311{
    311     return (rand() & CRTDLL_RAND_MAX); 
     312    return (rand() & CRTDLL_RAND_MAX);
    312313}
    313314
     
    319320{
    320321  // return (_rotl(value, shift));
    321  
     322
    322323    shift &= 31;
    323324    return (x << shift) | (x >> (32-shift));
     
    331332{
    332333  // return (_lrotl(value, shift));
    333  
     334
    334335    shift &= 31;
    335336    return (x << shift) | (x >> (32-shift));
     
    343344{
    344345  // return (_lrotr(value, shift));
    345  
     346
    346347    shift &= 0x1f;
    347348    return (x >> shift) | (x << (32-shift));
     
    355356{
    356357  // return (_rotr(value, shift));
    357  
     358
    358359    shift &= 0x1f;
    359360    return (x >> shift) | (x << (32-shift));
     
    367368{
    368369  // return (vswprintf(s, t, format, arg));
    369  
     370
    370371    return wvsprintfW( buffer, spec, args );
    371372}
     
    388389{
    389390  return (setlocale(category, locale));
    390  
     391
    391392  /*
    392393    LPSTR categorystr;
     
    437438{
    438439  // return (_fullpath(buf, path, size));
    439  
     440
    440441  if (!buf)
    441442  {
     
    455456{
    456457  // _splitpath( path, drive, dir, fname, ext);
    457  
     458
    458459  /* drive includes :
    459460     directory includes leading and trailing (forward and backward slashes)
     
    519520{
    520521  // _makepath(path, drive, dir, fname, ext);
    521  
     522
    522523    char ch;
    523524    TRACE("CRTDLL__makepath got %s %s %s %s\n", drive, directory,
     
    567568{
    568569  // return (_errno());
    569  
     570
    570571  return &CRTDLL_errno;
    571572}
     
    574575/*********************************************************************
    575576 *                  __doserrno       (CRTDLL.26)
    576  * 
     577 *
    577578 * Return the address of the DOS errno (holding the last OS error).
    578579 * @@@PH Note: veeeery strange ...
     
    583584{
    584585  // return (__doserrno());
    585  
     586
    586587  return &CRTDLL_doserrno;
    587588}
     
    601602{
    602603  // return (_strerror((char*)s));
    603  
     604
    604605  static char strerrbuff[256];
    605606  sprintf(strerrbuff,"%s: %s\n",err,CRTDLL_strerror(CRTDLL_errno));
     
    616617{
    617618  // perror( s );
    618  
     619
    619620  char *err_str = CRTDLL_strerror(CRTDLL_errno);
    620621  CRTDLL_fprintf(CRTDLL_stderr,"%s: %s\n",err,err_str);
    621622  CRTDLL_free(err_str);
    622623}
    623  
     624
    624625
    625626/*********************************************************************
     
    631632 * The caller does not own the string returned.
    632633 */
    633 extern char *strerror(int errnum); 
     634extern char *strerror(int errnum);
    634635
    635636LPSTR CDECL CRTDLL_strerror (INT err)
     
    645646{
    646647  //return (signal(sig, ptr));
    647  
     648
    648649  FIXME("(%d %p):stub.\n", sig, ptr);
    649650  return (void*)-1;
     
    667668{
    668669  // return (getenv(name));
    669  
     670
    670671     LPSTR environ = GetEnvironmentStringsA();
    671672     LPSTR pp,pos = NULL;
     
    674675     for (pp = environ; (*pp); pp = pp + strlen(pp) +1)
    675676       {
    676         pos =strchr(pp,'=');
    677         if (pos)
    678            length = pos -pp;
    679         else
    680            length = strlen(pp);
    681         if (!strncmp(pp,name,length)) break;
     677    pos =strchr(pp,'=');
     678    if (pos)
     679       length = pos -pp;
     680    else
     681       length = strlen(pp);
     682    if (!strncmp(pp,name,length)) break;
    682683       }
    683      if ((pp)&& (pos)) 
     684     if ((pp)&& (pos))
    684685       {
    685         pp = pos+1;
    686         TRACE("got %s\n",pp);
     686    pp = pos+1;
     687    TRACE("got %s\n",pp);
    687688       }
    688689     FreeEnvironmentStringsA( environ );
     
    695696 */
    696697INT CDECL CRTDLL__except_handler2 (
    697         PEXCEPTION_RECORD rec,
    698         PEXCEPTION_FRAME frame,
    699         PCONTEXT context,
    700         PEXCEPTION_FRAME  *dispatcher)
    701 {
    702         FIXME ("exception %lx flags=%lx at %p handler=%p %p %p stub\n",
    703         rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
    704         frame->Handler, context, dispatcher);
    705         return ExceptionContinueSearch;
     698    PEXCEPTION_RECORD rec,
     699    PEXCEPTION_FRAME frame,
     700    PCONTEXT context,
     701    PEXCEPTION_FRAME  *dispatcher)
     702{
     703    FIXME ("exception %lx flags=%lx at %p handler=%p %p %p stub\n",
     704    rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
     705    frame->Handler, context, dispatcher);
     706    return ExceptionContinueSearch;
    706707}
    707708
     
    724725{
    725726  // return (_toascii(c));
    726  
     727
    727728  return c & 0x7f;
    728729}
     
    754755{
    755756  // return (_iscsym(c));
    756  
     757
    757758  return (isalnum(c) || c == '_');
    758759}
     
    773774{
    774775  // return (_iscsymf(c));
    775  
     776
    776777  return (isalpha(c) || c == '_');
    777778}
     
    846847    {
    847848      if (cf((LPVOID*)match, (LPVOID*)pStart) == 0)
    848         return pStart; /* found */
     849    return pStart; /* found */
    849850      pStart += elem_size;
    850851    } while (--size);
     
    914915{
    915916  // return (_toupper(n));
    916  
     917
    917918  return toupper(c);
    918919}
     
    925926{
    926927  // return (_tolower(n));
    927  
     928
    928929  return tolower(c);
    929930}
     
    946947{
    947948  // return (_cabs(c));
    948  
     949
    949950  return sqrt(c.real * c.real + c.imaginary * c.imaginary);
    950951}
     
    10061007 *
    10071008 * Reset the state of the floating point processor.
    1008  * 
     1009 *
    10091010 * PARAMS
    10101011 *   None.
  • trunk/src/crtdll/dir.c

    r4675 r6645  
     1/* $Id: dir.c,v 1.5 2001-09-05 12:14:24 bird Exp $ */
    12/*
    23 * CRTDLL drive/directory functions
    3  * 
     4 *
    45 * Copyright 1996,1998 Marcus Meissner
    56 * Copyright 1996 Jukka Iivonen
     
    5758 * RETURNS
    5859 * Sucess:  0
    59  * 
     60 *
    6061 * Failure: -1
    6162 */
     
    6465  dprintf(("CRTDLL: _chdir(%s)\n",
    6566          newdir));
    66  
     67
    6768  if (!SetCurrentDirectoryA(newdir))
    6869  {
     
    8485 * RETURNS
    8586 * Sucess:  0
    86  * 
    87  * Failure: 1 
     87 *
     88 * Failure: 1
    8889 */
    8990BOOL CDECL CRTDLL__chdrive(INT newdrive)
     
    9192  char buffer[3] = "A:";
    9293  buffer[0] += newdrive - 1;
    93  
     94
    9495  dprintf(("CRTDLL: _chdrive(%s)\n",
    9596          buffer));
    96  
     97
    9798  if (!SetCurrentDirectoryA( buffer ))
    9899  {
     
    108109/*********************************************************************
    109110 *                  _findclose     (CRTDLL.098)
    110  * 
     111 *
    111112 * Free the resources from a search handle created from _findfirst.
    112113 *
     
    123124  dprintf(("CRTDLL: _findclose(%08xh)\n",
    124125          hand));
    125  
     126
    126127  if (!FindClose((HANDLE)hand))
    127128  {
     
    141142 * PARAMS
    142143 *   fspec [in]  File specification string for search, e.g "C:\*.BAT"
    143  * 
     144 *
    144145 *   ft [out]    A pointer to a find_t structure to populate.
    145146 *
     
    155156  WIN32_FIND_DATAA find_data;
    156157  HANDLE hfind;
    157  
     158
    158159  dprintf(("CRTDLL: _findfirst(%s)\n",
    159160          fspec));
     
    173174/*********************************************************************
    174175 *                  _findnext     (CRTDLL.100)
    175  * 
     176 *
    176177 * Return the next matching file/directory from a search hadle.
    177178 *
    178179 * PARAMS
    179180 *   hand [in] Search handle from a pervious call to _findfirst
    180  * 
     181 *
    181182 *   ft [out]  A pointer to a find_t structure to populate.
    182183 *
     
    190191{
    191192  WIN32_FIND_DATAA find_data;
    192  
     193
    193194  dprintf(("CRTDLL: _findnext(%08xh)\n",
    194195          hand));
    195  
     196
    196197  if (!FindNextFileA(hand, &find_data))
    197198  {
     
    224225{
    225226  // return (_getcwd(buf, size));
    226  
     227
    227228  char dir[_MAX_PATH];
    228229  int dir_len = GetCurrentDirectoryA(_MAX_PATH,dir);
    229  
     230
    230231  dprintf(("CRTDLL: _getcwd()\n"));
    231  
     232
    232233  if (dir_len < 1)
    233234    return NULL; /* FIXME: Real return value untested */
     
    258259{
    259260  // return (_getdcwd(drive, buffer, maxlen));
    260  
     261
    261262  static CHAR* dummy;
    262  
     263
    263264  dprintf(("CRTDLL: _getdcwd()\n"));
    264  
     265
    265266  if (!drive || drive == CRTDLL__getdrive())
    266267    return CRTDLL__getcwd(buf,size); /* current */
     
    305306  DWORD ret[4];
    306307  UINT err;
    307  
     308
    308309  dprintf(("CRTDLL: _getdiskfree(%08xh)\n", disk));
    309  
     310
    310311  if (disk > 26)
    311312    return ERROR_INVALID_PARAMETER; /* CRTDLL doesn't set errno here */
     
    335336{
    336337  // return DRIVE_GetCurrentDrive() + 1;
    337  
     338
    338339  char buffer[MAX_PATH];
    339  
     340
    340341  dprintf(("CRTDLL: _getdrive()\n"));
    341342
    342   if (!GetCurrentDirectoryA( sizeof(buffer), buffer )) 
    343     return 0;
    344   if (buffer[1] != ':') 
     343  if (!GetCurrentDirectoryA( sizeof(buffer), buffer ))
     344    return 0;
     345  if (buffer[1] != ':')
    345346    return 0;
    346347  return toupper(buffer[0]) - 'A' + 1;
     
    357358  dprintf(("CRTDLL: _mkdir(%s)\n",
    358359          newdir));
    359  
     360
    360361  if (CreateDirectoryA(newdir,NULL))
    361362    return 0;
     
    368369 *                  _rmdir           (CRTDLL.255)
    369370 *
    370  * Delete a directory 
     371 * Delete a directory
    371372 *
    372373 */
     
    375376  dprintf(("CRTDLL: _rmdir(%s)\n",
    376377          dir));
    377  
     378
    378379  if (RemoveDirectoryA(dir))
    379380    return 0;
  • trunk/src/crtdll/exit.c

    r4667 r6645  
     1/* $Id: exit.c,v 1.2 2001-09-05 12:14:24 bird Exp $ */
    12/*
    23 * CRTDLL exit/abort/atexit functions
    3  * 
     4 *
    45 * Copyright 1996,1998 Marcus Meissner
    56 * Copyright 1996 Jukka Iivonen
     
    1011 * and whether they return to the caller (really!).
    1112 *            return      do
    12  *  Name      to caller?  cleanup? 
     13 *  Name      to caller?  cleanup?
    1314 *  _c_exit     Y           N
    1415 *  _cexit      Y           Y
     
    5455
    5556/*********************************************************************
    56  *      __dllonexit                             (CRTDLL.25)
     57 *  __dllonexit                     (CRTDLL.25)
    5758 */
    5859VOID CDECL CRTDLL___dllonexit ()
    59 {       
     60{
    6061  dprintf(("__dllonexit not implemented.\n"));
    6162  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
     
    6465
    6566/*********************************************************************
    66  *      _abnormal_termination                   (CRTDLL.36)
     67 *  _abnormal_termination           (CRTDLL.36)
    6768 */
    6869int CDECL CRTDLL__abnormal_termination(void)
     
    8384{
    8485  dprintf2(("CRTDLL: _amsg_exit\n"));
    85  
     86
    8687  // fprintf(stderr,strerror(errnum));
    8788  // ExitProcess(-1);
    88  
     89
    8990  CRTDLL_fprintf(CRTDLL_stderr,"\nrun-time error:\nError Code %d\n",errnum);
    9091  CRTDLL__exit(255);
     
    9596 *                  _assert     (CRTDLL.041)
    9697 *
    97  * Print an assertion message and call abort(). Really only present 
     98 * Print an assertion message and call abort(). Really only present
    9899 * for win binaries. Winelib programs would typically use libc's
    99100 * version.
     
    102103{
    103104  dprintf2(("CRTDLL: _assert\n"));
    104  
     105
    105106  CRTDLL_fprintf(CRTDLL_stderr,"Assertion failed: %s, file %s, line %d\n\n",
    106107                 (char*)str,(char*)file, line);
    107108  CRTDLL_abort();
    108  
     109
    109110  // _assert(str, file, line);
    110111}
     
    119120  dprintf2(("_c_exit(%d)\n",ret));
    120121  FIXME("not calling CRTDLL cleanup\n");
    121  
     122
    122123  /* dont exit, return to caller */
    123  
     124
    124125  ExitProcess(ret);
    125126}
     
    135136  FIXME("not calling CRTDLL cleanup\n");
    136137  /* dont exit, return to caller */
    137  
     138
    138139  ExitProcess(ret);
    139140}
     
    145146VOID CDECL CRTDLL__exit(LONG ret)
    146147{
    147   dprintf2(("CRTDLL: _exit (%08xh)\n", 
     148  dprintf2(("CRTDLL: _exit (%08xh)\n",
    148149            ret));
    149150  TRACE(":exit code %ld\n",ret);
     
    199200{
    200201  dprintf2(("CRTDLL: abort\n"));
    201  
     202
    202203  CRTDLL_fprintf(CRTDLL_stderr,"\nabnormal program termination\n");
    203204  CRTDLL__exit(3);
     
    207208
    208209/*********************************************************************
    209  *                  atexit      (CRTDLL.342)
     210 *                  atexit  (CRTDLL.342)
    210211 *
    211212 * Register a function to be called when the process terminates.
     
    214215{
    215216  dprintf(("CRTDLL: atexit\n"));
    216  
     217
    217218  return CRTDLL__onexit(func) == func ? 0 : -1;
    218  
     219
    219220  // if (_atexit_n >= sizeof (_atexit_v) / sizeof (_atexit_v[0]))
    220221  //   return -1;
  • trunk/src/crtdll/file.c

    r4671 r6645  
     1/* $Id: file.c,v 1.3 2001-09-05 12:14:24 bird Exp $ */
    12/*
    23 * CRTDLL file functions
    3  * 
     4 *
    45 * Copyright 1996,1998 Marcus Meissner
    56 * Copyright 1996 Jukka Iivonen
     
    89 *
    910 * Implementation Notes:
    10  * Mapping is performed between FILE*, fd and HANDLE's. This allows us to 
    11  * implement all calls using the Win32 API, support remapping fd's to 
     11 * Mapping is performed between FILE*, fd and HANDLE's. This allows us to
     12 * implement all calls using the Win32 API, support remapping fd's to
    1213 * FILES and do some other tricks as well (like closeall, _get_osfhandle).
    1314 * For mix and matching with the host libc, processes can use the Win32 HANDLE
     
    128129  else
    129130    while(__CRTDLL_fdstart < __CRTDLL_fdend &&
    130           __CRTDLL_handles[__CRTDLL_fdstart] != INVALID_HANDLE_VALUE)
     131      __CRTDLL_handles[__CRTDLL_fdstart] != INVALID_HANDLE_VALUE)
    131132      __CRTDLL_fdstart++;
    132133
     
    143144{
    144145  TRACE(":fd (%d) allocating FILE*\n",fd);
    145   if (fd < 0 || fd >= __CRTDLL_fdend || 
     146  if (fd < 0 || fd >= __CRTDLL_fdend ||
    146147      __CRTDLL_handles[fd] == INVALID_HANDLE_VALUE)
    147148  {
     
    178179
    179180  TRACE(":handles (%d)(%d)(%d)\n",__CRTDLL_handles[0],
    180         __CRTDLL_handles[1],__CRTDLL_handles[2]);
     181    __CRTDLL_handles[1],__CRTDLL_handles[2]);
    181182
    182183  for (i = 0; i < 3; i++)
     
    195196{
    196197  // return (_access(path, mode));
    197  
     198
    198199  DWORD attr = GetFileAttributesA(filename);
    199200
     
    202203    if (!filename)
    203204    {
    204         /* FIXME: Should GetFileAttributesA() return this? */
     205    /* FIXME: Should GetFileAttributesA() return this? */
    205206      __CRTDLL__set_errno(ERROR_INVALID_DATA);
    206207      return -1;
     
    303304{
    304305  // return (__eof(_fd));
    305  
     306
    306307  DWORD curpos,endpos;
    307308  HANDLE hand = __CRTDLL__fdtoh(fd);
     
    338339{
    339340  // return (_fcloseall());
    340  
     341
    341342  int num_closed = 0, i = 3;
    342343
     
    361362{
    362363  // return (_fdopen(handle, mode));
    363  
     364
    364365  CRTDLL_FILE* file = __CRTDLL__alloc_fp(fd);
    365366
     
    378379{
    379380  // return (_fgetchar());
    380  
     381
    381382  return CRTDLL_fgetc(CRTDLL_stdin);
    382383}
     
    390391 * becomes negative. We ensure that _cnt is always 0 after any read
    391392 * so this function is always called. Our implementation simply calls
    392  * fgetc as all the underlying buffering is handled by Wines 
     393 * fgetc as all the underlying buffering is handled by Wines
    393394 * implementation of the Win32 file I/O calls.
    394395 */
     
    410411{
    411412  // return (_fileno(f));
    412  
     413
    413414  TRACE(":FILE* (%p) fd (%d)\n",file,file->_file);
    414415  return file->_file;
     
    440441{
    441442  // return (_flushall());
    442  
     443
    443444  int num_flushed = 0, i = 3;
    444445
     
    447448    {
    448449      if (CRTDLL__commit(i) == -1)
    449         if (__CRTDLL_files[i])
    450           __CRTDLL_files[i]->_flag |= _IOERR;
     450    if (__CRTDLL_files[i])
     451      __CRTDLL_files[i]->_flag |= _IOERR;
    451452      num_flushed++;
    452453    }
     
    465466{
    466467  // return(_fputchar(c));
    467  
     468
    468469  return CRTDLL_fputc(c, CRTDLL_stdout);
    469470}
     
    484485/*********************************************************************
    485486 *                  _fstat        (CRTDLL.111)
    486  * 
     487 *
    487488 * Get information about an open file.
    488489 */
     
    490491{
    491492  // return (_fstat(file, buf));
    492  
     493
    493494  DWORD dw;
    494495  BY_HANDLE_FILE_INFORMATION hfi;
     
    548549  {
    549550    /* FIXME: I'm not convinced that I should be copying the
    550      * handle here - it may be leaked if the app doesn't 
     551     * handle here - it may be leaked if the app doesn't
    551552     * close it (and the API docs dont say that it should)
    552553     * Not duplicating it means that it can't be inherited
     
    557558     */
    558559    DuplicateHandle(GetCurrentProcess(),hand,GetCurrentProcess(),
    559                     &newhand,0,TRUE,DUPLICATE_SAME_ACCESS );
     560            &newhand,0,TRUE,DUPLICATE_SAME_ACCESS );
    560561  }
    561562  return newhand;
     
    588589{
    589590  // return (_lseek(handle, offset, origin));
    590  
     591
    591592  LONG ret;
    592593  HANDLE hand = __CRTDLL__fdtoh(fd);
     
    777778{
    778779  // return (_setmode(fh, mode));
    779  
     780
    780781  if (mode & _O_TEXT)
    781782    FIXME("fd (%d) mode (%d) TEXT not implemented\n",fd,mode);
     
    790791{
    791792  // return(_stat(s1, n));
    792  
     793
    793794  DWORD dw;
    794795  WIN32_FILE_ATTRIBUTE_DATA hfi;
     
    826827    {
    827828      unsigned int ext = tolower(path[plen-1]) | (tolower(path[plen-2]) << 8)
    828         | (tolower(path[plen-3]) << 16);
     829    | (tolower(path[plen-3]) << 16);
    829830      if (ext == EXE || ext == BAT || ext == CMD || ext == COM)
    830         mode |= CRTDLL_S_IEXEC;
     831    mode |= CRTDLL_S_IEXEC;
    831832    }
    832833  }
     
    843844  buf->st_mtime = buf->st_ctime = dw;
    844845  TRACE("\n%d %d %d %d %d %d\n", buf->st_mode,buf->st_nlink,buf->st_size,
    845         buf->st_atime,buf->st_mtime, buf->st_ctime);
     846    buf->st_atime,buf->st_mtime, buf->st_ctime);
    846847  return 0;
    847848}
     
    856857{
    857858  // return (_tell(i));
    858  
     859
    859860  return CRTDLL__lseek(fd, 0, SEEK_CUR);
    860861}
     
    863864/*********************************************************************
    864865 *                  _tempnam           (CRTDLL.305)
    865  * 
     866 *
    866867 */
    867868LPSTR CDECL CRTDLL__tempnam(LPCSTR dir, LPCSTR prefix)
    868869{
    869870  // return (_tempnam(dir, prefix));
    870  
     871
    871872  char tmpbuf[MAX_PATH];
    872873
     
    890891{
    891892  // return (_umask(i));
    892  
     893
    893894  INT old_umask = __CRTDLL_umask;
    894895  TRACE("umask (%d)\n",umask);
     
    976977{
    977978  // return (fclose(fp));
    978  
     979
    979980  return CRTDLL__close(file->_file);
    980981}
     
    989990{
    990991  // return (feof(fp));
    991  
     992
    992993  return file->_flag & _IOEOF;
    993994}
     
    10021003{
    10031004  // return (ferror(fp));
    1004  
     1005
    10051006  return file->_flag & _IOERR;
    10061007}
     
    10241025{
    10251026  // return (fgetc(fp));
    1026  
     1027
    10271028  char c;
    10281029  if (CRTDLL__read(file->_file,&c,1) != 1)
     
    10501051{
    10511052  // return (fgets(s, n, fp));
    1052  
     1053
    10531054  int    cc;
    10541055  LPSTR  buf_start = s;
    10551056
    10561057  TRACE(":file(%p) fd (%d) str (%p) len (%d)\n",
    1057         file,file->_file,s,size);
     1058    file,file->_file,s,size);
    10581059
    10591060  /* BAD, for the whole WINE process blocks... just done this way to test
     
    10881089{
    10891090  // return (fputs(s, fp));
    1090  
     1091
    10911092  return CRTDLL_fwrite(s,strlen(s),1,file);
    10921093}
     
    10991100{
    11001101    // return (fprintf(file, format, arg));
    1101  
     1102
    11021103    va_list valist;
    11031104    INT res;
     
    11181119{
    11191120  // return (fopen( filename, mode));
    1120  
     1121
    11211122  CRTDLL_FILE* file;
    11221123  INT flags = 0, plus = 0, fd;
     
    11821183{
    11831184  // return (fputc(c, fp));
    1184  
     1185
    11851186  return CRTDLL__write(file->_file, &c, 1) == 1? c : EOF;
    11861187}
     
    11931194{
    11941195  // return (fread(ptr, size, n, fp));
    1195  
     1196
    11961197  DWORD read = CRTDLL__read(file->_file,ptr, size * nmemb);
    11971198  if (read <= 0)
     
    12031204/*********************************************************************
    12041205 *                  freopen    (CRTDLL.379)
    1205  * 
     1206 *
    12061207 */
    12071208CRTDLL_FILE* CDECL CRTDLL_freopen(LPCSTR path, LPCSTR mode,CRTDLL_FILE* file)
    12081209{
    12091210  // return (freopen(filename, mode, fp));
    1210  
     1211
    12111212  CRTDLL_FILE* newfile;
    12121213  INT fd;
     
    12561257{
    12571258  // return (fsetpos(fp, pos));
    1258  
     1259
    12591260  return CRTDLL__lseek(file->_file,*pos,SEEK_SET);
    12601261}
     
    13921393{
    13931394  // return (fseek(file, offset, whence));
    1394  
     1395
    13951396  return CRTDLL__lseek(file->_file,offset,whence);
    13961397}
     
    14031404{
    14041405  // return (ftell(fp));
    1405  
     1406
    14061407  return CRTDLL__tell(file->_file);
    14071408}
     
    14281429{
    14291430  // return (getchar());
    1430  
     1431
    14311432  return CRTDLL_fgetc(CRTDLL_stdin);
    14321433}
     
    14591460     */
    14601461    for(cc = CRTDLL_fgetc(CRTDLL_stdin); cc != EOF && cc != '\n';
    1461         cc = CRTDLL_fgetc(CRTDLL_stdin))
    1462         if(cc != '\r') *buf++ = (char)cc;
     1462    cc = CRTDLL_fgetc(CRTDLL_stdin))
     1463    if(cc != '\r') *buf++ = (char)cc;
    14631464
    14641465    *buf = '\0';
     
    14971498{
    14981499  // return puts( s );
    1499  
     1500
    15001501  return CRTDLL_fputs(s, CRTDLL_stdout);
    15011502}
     
    15111512{
    15121513  // rewind(fp);
    1513  
     1514
    15141515  TRACE(":file (%p) fd (%d)\n",file,file->_file);
    15151516  CRTDLL__lseek(file->_file,0,SEEK_SET);
     
    15241525{
    15251526  // return (remove(file));
    1526  
     1527
    15271528  TRACE(":path (%s)\n",path);
    15281529  if (DeleteFileA(path))
     
    15401541{
    15411542  // return (rename(old, new2));
    1542  
     1543
    15431544  TRACE(":from %s to %s\n",oldpath,newpath);
    15441545  if (MoveFileExA( oldpath, newpath, MOVEFILE_REPLACE_EXISTING))
     
    15561557{
    15571558  // setbuf(fp, buf);
    1558  
     1559
    15591560  TRACE(":file (%p) fd (%d) buf (%p)\n", file, file->_file,buf);
    15601561  if (buf)
     
    15691570 *
    15701571 * lcclnk from lcc-win32 relies on a terminating dot in the name returned
    1571  * 
     1572 *
    15721573 */
    15731574LPSTR CDECL CRTDLL_tmpnam(LPSTR s)
    15741575{
    15751576  // return (tmpnam(s));
    1576  
     1577
    15771578  char tmpbuf[MAX_PATH];
    15781579  char* prefix = "TMP";
     
    15991600{
    16001601  // return (vfprintf(file, format, args));
    1601  
     1602
    16021603  /* FIXME: We should parse the format string, calculate the maximum,
    16031604   * length of each arg, malloc a buffer, print to it, and fwrite that.
  • trunk/src/crtdll/initterm.cpp

    r5135 r6645  
     1/* $Id: initterm.cpp,v 1.7 2001-09-05 12:14:25 bird Exp $ */
    12/*
    23 * DLL entry point
     
    5556   case DLL_THREAD_ATTACH:
    5657   case DLL_THREAD_DETACH:
    57         return CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);
     58    return CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);
    5859
    5960   case DLL_PROCESS_DETACH:
    60         CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);
    61         ctordtorTerm();
    62         return TRUE;
     61    CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);
     62    ctordtorTerm();
     63    return TRUE;
    6364   }
    6465   return FALSE;
     
    9091         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9192
    92         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
    93          if(dllHandle == 0) 
    94                 return 0UL;
     93    dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     94         if(dllHandle == 0)
     95        return 0UL;
    9596
    9697         break;
    9798      case 1 :
    9899         if(dllHandle) {
    99                 UnregisterLxDll(dllHandle);
     100        UnregisterLxDll(dllHandle);
    100101         }
    101102         break;
  • trunk/src/crtdll/memory.c

    r4671 r6645  
     1/* $Id: memory.c,v 1.3 2001-09-05 12:14:25 bird Exp $ */
    12/*
    23 * CRTDLL memory functions
    3  * 
     4 *
    45 * Copyright 1996,1998 Marcus Meissner
    56 * Copyright 1996 Jukka Iivonen
     
    3233    VOID* result;
    3334    if(!(result = HeapAlloc(GetProcessHeap(),0,size)) && new_handler)
    34         (*new_handler)();
     35    (*new_handler)();
    3536    return result;
    3637}
     
    7980{
    8081  // return (_heapchk());
    81  
     82
    8283  if (!HeapValidate( GetProcessHeap(), 0, NULL))
    8384  {
     
    9798{
    9899  // return (_heapmin());
    99  
     100
    100101  if (!HeapCompact( GetProcessHeap(), 0 ))
    101102  {
     
    116117{
    117118  // return (_heapset(fill));
    118  
     119
    119120  INT retVal;
    120121  struct _heapinfo heap;
     
    144145  phe.wFlags = next->_useflag == _USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0;
    145146
    146   if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY && 
     147  if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY &&
    147148      !HeapValidate( GetProcessHeap(), 0, phe.lpData ))
    148149  {
     
    180181{
    181182  // return (_msize(ptr));
    182  
     183
    183184  LONG size = HeapSize(GetProcessHeap(),0,mem);
    184185  if (size == -1)
     
    215216/*********************************************************************
    216217 *                  malloc        (CRTDLL.424)
    217  * 
     218 *
    218219 * Alocate memory from the heap.
    219220 */
  • trunk/src/crtdll/spawn.c

    r4672 r6645  
     1/* $Id: spawn.c,v 1.3 2001-09-05 12:14:25 bird Exp $ */
    12/*
    23 * CRTDLL spawn functions
    3  * 
     4 *
    45 * Copyright 1996,1998 Marcus Meissner
    56 * Copyright 1996 Jukka Iivonen
     
    2425 * Implementation Notes:
    2526 * MT Safe - But only because of missing functionality.
    26  * 
     27 *
    2728 * After translating input arguments into the required format for
    2829 * CreateProcess(), the internal function __CRTDLL__spawn() is
     
    8283
    8384  if (!CreateProcessA(exe, args, NULL, NULL, TRUE,
    84                       flags == _P_DETACH ? DETACHED_PROCESS : 0,
    85                       env, NULL, &si, &pi))
     85              flags == _P_DETACH ? DETACHED_PROCESS : 0,
     86              env, NULL, &si, &pi))
    8687  {
    8788    __CRTDLL__set_errno(GetLastError());
     
    157158{
    158159  // return (_spawnve(i, s1, s2, s3));
    159  
     160
    160161  LPSTR args = __CRTDLL__argvtos(argv,' ');
    161162  LPSTR envs = __CRTDLL__argvtos(envv,0);
     
    186187{
    187188  // return system(string);
    188  
     189
    189190    /* FIXME: should probably launch cmd interpreter in COMSPEC */
    190191    return __CRTDLL__spawn(_P_WAIT, NULL, x, NULL);
Note: See TracChangeset for help on using the changeset viewer.